objc2_application_services/generated/HIServices/
Processes.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "objc2")]
6use objc2::__framework_prelude::*;
7use objc2_core_foundation::*;
8
9use crate::*;
10
11/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/knoprocess?language=objc)
12pub const kNoProcess: c_uint = 0;
13/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/ksystemprocess?language=objc)
14pub const kSystemProcess: c_uint = 1;
15/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/kcurrentprocess?language=objc)
16pub const kCurrentProcess: c_uint = 2;
17
18/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/launchflags?language=objc)
19pub type LaunchFlags = u16;
20
21/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/launchcontinue?language=objc)
22pub const launchContinue: c_uint = 0x4000;
23/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/launchnofileflags?language=objc)
24pub const launchNoFileFlags: c_uint = 0x0800;
25/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/launchuseminimum?language=objc)
26pub const launchUseMinimum: c_uint = 0x0400;
27/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/launchdontswitch?language=objc)
28pub const launchDontSwitch: c_uint = 0x0200;
29/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/launchallow24bit?language=objc)
30pub const launchAllow24Bit: c_uint = 0x0100;
31/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/launchinhibitdaemon?language=objc)
32pub const launchInhibitDaemon: c_uint = 0x0080;
33
34/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/appparameters_themsgevent?language=objc)
35#[repr(C, packed(2))]
36#[derive(Clone, Copy, Debug, PartialEq)]
37pub struct AppParameters_theMsgEvent {
38    pub what: u16,
39    pub message: u32,
40    pub when: u32,
41    pub r#where: Point,
42    pub modifiers: u16,
43}
44
45#[cfg(feature = "objc2")]
46unsafe impl Encode for AppParameters_theMsgEvent {
47    const ENCODING: Encoding = Encoding::Struct(
48        "?",
49        &[
50            <u16>::ENCODING,
51            <u32>::ENCODING,
52            <u32>::ENCODING,
53            <Point>::ENCODING,
54            <u16>::ENCODING,
55        ],
56    );
57}
58
59#[cfg(feature = "objc2")]
60unsafe impl RefEncode for AppParameters_theMsgEvent {
61    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/appparameters?language=objc)
65#[repr(C, packed(2))]
66#[derive(Clone, Copy, Debug, PartialEq)]
67pub struct AppParameters {
68    pub theMsgEvent: AppParameters_theMsgEvent,
69    pub eventRefCon: u32,
70    pub messageLength: u32,
71}
72
73#[cfg(feature = "objc2")]
74unsafe impl Encode for AppParameters {
75    const ENCODING: Encoding = Encoding::Struct(
76        "AppParameters",
77        &[
78            <AppParameters_theMsgEvent>::ENCODING,
79            <u32>::ENCODING,
80            <u32>::ENCODING,
81        ],
82    );
83}
84
85#[cfg(feature = "objc2")]
86unsafe impl RefEncode for AppParameters {
87    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
88}
89
90/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/appparametersptr?language=objc)
91pub type AppParametersPtr = *mut AppParameters;
92
93/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/extendedblock?language=objc)
94pub const extendedBlock: c_uint = 0x4C43;
95
96/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/modereserved?language=objc)
97pub const modeReserved: c_uint = 0x01000000;
98/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/modecontrolpanel?language=objc)
99pub const modeControlPanel: c_uint = 0x00080000;
100/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/modelaunchdontswitch?language=objc)
101pub const modeLaunchDontSwitch: c_uint = 0x00040000;
102/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/modedeskaccessory?language=objc)
103pub const modeDeskAccessory: c_uint = 0x00020000;
104/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/modemultilaunch?language=objc)
105pub const modeMultiLaunch: c_uint = 0x00010000;
106/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/modeneedsuspendresume?language=objc)
107pub const modeNeedSuspendResume: c_uint = 0x00004000;
108/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/modecanbackground?language=objc)
109pub const modeCanBackground: c_uint = 0x00001000;
110/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/modedoesactivateonfgswitch?language=objc)
111pub const modeDoesActivateOnFGSwitch: c_uint = 0x00000800;
112/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/modeonlybackground?language=objc)
113pub const modeOnlyBackground: c_uint = 0x00000400;
114/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/modegetfrontclicks?language=objc)
115pub const modeGetFrontClicks: c_uint = 0x00000200;
116/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/modegetappdiedmsg?language=objc)
117pub const modeGetAppDiedMsg: c_uint = 0x00000100;
118/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/mode32bitcompatible?language=objc)
119pub const mode32BitCompatible: c_uint = 0x00000080;
120/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/modehighleveleventaware?language=objc)
121pub const modeHighLevelEventAware: c_uint = 0x00000040;
122/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/modelocalandremotehlevents?language=objc)
123pub const modeLocalAndRemoteHLEvents: c_uint = 0x00000020;
124/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/modestationeryaware?language=objc)
125pub const modeStationeryAware: c_uint = 0x00000010;
126/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/modeusetexteditservices?language=objc)
127pub const modeUseTextEditServices: c_uint = 0x00000008;
128/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/modedisplaymanageraware?language=objc)
129pub const modeDisplayManagerAware: c_uint = 0x00000004;
130
131/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/processapplicationtransformstate?language=objc)
132pub type ProcessApplicationTransformState = u32;
133
134/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/kprocesstransformtoforegroundapplication?language=objc)
135pub const kProcessTransformToForegroundApplication: c_uint = 1;
136/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/kprocesstransformtobackgroundapplication?language=objc)
137pub const kProcessTransformToBackgroundApplication: c_uint = 2;
138/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/kprocesstransformtouielementapplication?language=objc)
139pub const kProcessTransformToUIElementApplication: c_uint = 4;
140
141/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/sizeresourcerec?language=objc)
142#[repr(C, packed(2))]
143#[derive(Clone, Copy, Debug, PartialEq)]
144pub struct SizeResourceRec {
145    pub flags: u16,
146    pub preferredHeapSize: u32,
147    pub minimumHeapSize: u32,
148}
149
150#[cfg(feature = "objc2")]
151unsafe impl Encode for SizeResourceRec {
152    const ENCODING: Encoding = Encoding::Struct(
153        "SizeResourceRec",
154        &[<u16>::ENCODING, <u32>::ENCODING, <u32>::ENCODING],
155    );
156}
157
158#[cfg(feature = "objc2")]
159unsafe impl RefEncode for SizeResourceRec {
160    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
161}
162
163/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/sizeresourcerecptr?language=objc)
164pub type SizeResourceRecPtr = *mut SizeResourceRec;
165
166/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/sizeresourcerechandle?language=objc)
167pub type SizeResourceRecHandle = *mut SizeResourceRecPtr;
168
169/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/kquitbeforenormaltimemask?language=objc)
170pub const kQuitBeforeNormalTimeMask: c_uint = 1;
171/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/kquitatnormaltimemask?language=objc)
172pub const kQuitAtNormalTimeMask: c_uint = 2;
173/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/kquitbeforefbasquitmask?language=objc)
174pub const kQuitBeforeFBAsQuitMask: c_uint = 4;
175/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/kquitbeforeshellquitsmask?language=objc)
176pub const kQuitBeforeShellQuitsMask: c_uint = 8;
177/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/kquitbeforeterminatorappquitsmask?language=objc)
178pub const kQuitBeforeTerminatorAppQuitsMask: c_uint = 16;
179/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/kquitnevermask?language=objc)
180pub const kQuitNeverMask: c_uint = 32;
181/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/kquitoptionsmask?language=objc)
182pub const kQuitOptionsMask: c_uint = 0x7F;
183/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/kquitnotquitduringinstallmask?language=objc)
184pub const kQuitNotQuitDuringInstallMask: c_uint = 0x0100;
185/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/kquitnotquitduringlogoutmask?language=objc)
186pub const kQuitNotQuitDuringLogoutMask: c_uint = 0x0200;
187
188extern "C-unwind" {
189    /// Return the ProcessSerialNumber of the current application.
190    ///
191    /// Use [ NSRunningApplication currentApplication]
192    ///
193    /// Return the canonical process serial number to the caller.
194    ///
195    /// All applications ( things which can appear in the Dock or which are not documents and are launched by the Finder or Dock ) on Mac OS 10 have a unique process serial number.
196    /// This number is created when the application launches, and remains until the application quits. Other system services, like AppleEvents, use the ProcessSerialNumber to specify an
197    /// application.
198    ///
199    /// During launch, every application 'checks in' with the Process Manager. Before this checkin, the application can not receive events or draw to the screen. Prior to Mac OS 10.2, this
200    /// 'check in' happened before the applications's main() function was entered. In Mac OS 10.2 and later, this 'check in' does not happen until the first time the application calls a Process
201    /// Manager function, or until it enters CFRunLoopRun() for the main runloop. This allows tools and other executables which do not need to receive events to link against more of the higher
202    /// level toolbox frameworks, but may cause a problem if the application expects to be able to retrieve events or use CoreGraphics services before this checkin has occurred.-
203    ///
204    /// An application can force the connection to the Process Manager to be set up by calling any Process Manager routine, but the recommended way to do this is to call
205    /// GetCurrentProcess() to ask for the current application's PSN. This will initialize the connection to the Process Manager if it has not already been set up and 'check in' the application
206    /// with the system.
207    ///
208    /// This function is named MacGetCurrentProcess() on non Macintosh platforms and GetCurrentProcess on the Macintosh. However, even Macintosh code can use the
209    /// GetCurrentProcess() name since there is a macro which maps back to GetCurrentProcess().
210    ///
211    /// Lastly, it is usually not necessary to call GetCurrentProcess() to get the 'current' process psn merely to pass it to another Process Manager routine. Instead, just construct a
212    /// ProcessSerialNumber with 0 in highLongOfPSN and kCurrentProcess in lowLongOfPSN and pass that. For example, to make the current process the frontmost process, use
213    ///
214    /// ```text
215    /// ProcessSerialNumber psn = { 0, kCurrentProcess };
216    /// OSErr err = SetFrontProcess(
217    /// &
218    /// psn );
219    /// ```
220    /// If you need to pass a ProcessSerialNumber to another application or use it in an AppleEvent, you do need to get the canonical PSN with this routine.
221    ///
222    ///
223    /// Parameter `pPSN`: where the current processes process serial number is returned
224    ///
225    /// Returns: An operating system status code.
226    ///
227    /// # Safety
228    ///
229    /// `p_psn` must be a valid pointer.
230    #[deprecated]
231    pub fn GetCurrentProcess(p_psn: *mut ProcessSerialNumber) -> OSErr;
232}
233
234extern "C-unwind" {
235    /// Return the ProcessSerialNumber of the front application
236    ///
237    /// DEPRECATED:   Use +[NSWorkspace runningApplications] and look for the entry withisActive == YES.
238    ///
239    /// Parameter `pPSN`: where the front application process serial number is returned
240    ///
241    /// Returns: An operating system status code
242    ///
243    /// # Safety
244    ///
245    /// `p_psn` must be a valid pointer.
246    #[deprecated]
247    pub fn GetFrontProcess(p_psn: *mut ProcessSerialNumber) -> OSErr;
248}
249
250extern "C-unwind" {
251    /// Return the process serial number following the given process
252    ///
253    /// DEPRECATED:
254    /// Use +[NSWorkspace runningApplications:] which returns the full array of all running applications.
255    /// If this function is called with the process serial number where { .highLongOfPSN = 0, .lowLongOfPSN = 0 }, this return the process serial number of the first application.
256    /// If called with a valid process serial number, it returns the next higher application, or procNotFound when the last process serial number has been returned.
257    ///
258    /// Parameter `pPSN`: On input, a process serial number; on exit, the next process serial number or { 0, 0 }
259    ///
260    /// Returns: An operating system status code.  procNotFound signal the previous item was the last application in the array of running applications.
261    ///
262    /// # Safety
263    ///
264    /// `p_psn` must be a valid pointer.
265    #[deprecated]
266    pub fn GetNextProcess(p_psn: *mut ProcessSerialNumber) -> OSErr;
267}
268
269/// # Safety
270///
271/// `psn` must be a valid pointer.
272#[deprecated]
273#[inline]
274pub unsafe extern "C-unwind" fn ProcessInformationCopyDictionary(
275    psn: *const ProcessSerialNumber,
276    info_to_return: u32,
277) -> Option<CFRetained<CFDictionary>> {
278    extern "C-unwind" {
279        fn ProcessInformationCopyDictionary(
280            psn: *const ProcessSerialNumber,
281            info_to_return: u32,
282        ) -> Option<NonNull<CFDictionary>>;
283    }
284    let ret = unsafe { ProcessInformationCopyDictionary(psn, info_to_return) };
285    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
286}
287
288extern "C-unwind" {
289    /// Make the application with the given PSN into the front application, if possible.
290    ///
291    /// :
292    /// To make your own application frontmost, use [[NSApplication activate].
293    /// To make another application frontmost, use the activateWithOptions
294    /// method of the appropriate NSRunningApplication object for that application.
295    ///
296    /// Parameter `pPSN`: the ProcessSerialNumber of the application to be made frontmost
297    ///
298    /// # Safety
299    ///
300    /// `p_psn` must be a valid pointer.
301    #[deprecated]
302    pub fn SetFrontProcess(p_psn: *const ProcessSerialNumber) -> OSErr;
303}
304
305/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/ksetfrontprocessfrontwindowonly?language=objc)
306pub const kSetFrontProcessFrontWindowOnly: c_uint = 1 << 0;
307/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/ksetfrontprocesscausedbyuser?language=objc)
308pub const kSetFrontProcessCausedByUser: c_uint = 1 << 1;
309
310extern "C-unwind" {
311    /// # Safety
312    ///
313    /// `in_process` must be a valid pointer.
314    #[deprecated]
315    pub fn SetFrontProcessWithOptions(
316        in_process: *const ProcessSerialNumber,
317        in_options: OptionBits,
318    ) -> OSStatus;
319}
320
321extern "C-unwind" {
322    /// # Safety
323    ///
324    /// `psn` must be a valid pointer.
325    #[deprecated]
326    pub fn WakeUpProcess(psn: *const ProcessSerialNumber) -> OSErr;
327}
328
329extern "C-unwind" {
330    /// # Safety
331    ///
332    /// - `psn1` must be a valid pointer.
333    /// - `psn2` must be a valid pointer.
334    /// - `result` must be a valid pointer.
335    #[deprecated]
336    pub fn SameProcess(
337        psn1: *const ProcessSerialNumber,
338        psn2: *const ProcessSerialNumber,
339        result: *mut Boolean,
340    ) -> OSErr;
341}
342
343extern "C-unwind" {
344    #[deprecated]
345    pub fn ExitToShell();
346}
347
348extern "C-unwind" {
349    /// # Safety
350    ///
351    /// `in_process` must be a valid pointer.
352    #[deprecated]
353    pub fn KillProcess(in_process: *const ProcessSerialNumber) -> OSErr;
354}
355
356extern "C-unwind" {
357    /// # Safety
358    ///
359    /// - `psn` must be a valid pointer.
360    /// - `name` must be a valid pointer.
361    #[deprecated]
362    pub fn CopyProcessName(psn: *const ProcessSerialNumber, name: *mut *const CFString)
363        -> OSStatus;
364}
365
366extern "C-unwind" {
367    /// # Safety
368    ///
369    /// - `psn` must be a valid pointer.
370    /// - `pid` must be a valid pointer.
371    #[cfg(feature = "libc")]
372    #[deprecated]
373    pub fn GetProcessPID(psn: *const ProcessSerialNumber, pid: *mut libc::pid_t) -> OSStatus;
374}
375
376extern "C-unwind" {
377    /// # Safety
378    ///
379    /// `psn` must be a valid pointer.
380    #[cfg(feature = "libc")]
381    #[deprecated]
382    pub fn GetProcessForPID(pid: libc::pid_t, psn: *mut ProcessSerialNumber) -> OSStatus;
383}
384
385/// ***********************************************************************
386/// Process Visibility.
387/// ***********************************************************************
388///
389/// # Safety
390///
391/// `psn` must be a valid pointer.
392#[deprecated]
393#[inline]
394pub unsafe extern "C-unwind" fn IsProcessVisible(psn: *const ProcessSerialNumber) -> bool {
395    extern "C-unwind" {
396        fn IsProcessVisible(psn: *const ProcessSerialNumber) -> Boolean;
397    }
398    let ret = unsafe { IsProcessVisible(psn) };
399    ret != 0
400}
401
402/// # Safety
403///
404/// `psn` must be a valid pointer.
405#[deprecated]
406#[inline]
407pub unsafe extern "C-unwind" fn ShowHideProcess(
408    psn: *const ProcessSerialNumber,
409    visible: bool,
410) -> OSErr {
411    extern "C-unwind" {
412        fn ShowHideProcess(psn: *const ProcessSerialNumber, visible: Boolean) -> OSErr;
413    }
414    unsafe { ShowHideProcess(psn, visible as _) }
415}
416
417extern "C-unwind" {
418    /// # Safety
419    ///
420    /// `psn` must be a valid pointer.
421    pub fn TransformProcessType(
422        psn: *const ProcessSerialNumber,
423        transform_state: ProcessApplicationTransformState,
424    ) -> OSStatus;
425}
426
427/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/initdev?language=objc)
428pub const initDev: c_uint = 0;
429/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/hitdev?language=objc)
430pub const hitDev: c_uint = 1;
431/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/closedev?language=objc)
432pub const closeDev: c_uint = 2;
433/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/nuldev?language=objc)
434pub const nulDev: c_uint = 3;
435/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/updatedev?language=objc)
436pub const updateDev: c_uint = 4;
437/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/activdev?language=objc)
438pub const activDev: c_uint = 5;
439/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/deactivdev?language=objc)
440pub const deactivDev: c_uint = 6;
441/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/keyevtdev?language=objc)
442pub const keyEvtDev: c_uint = 7;
443/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/macdev?language=objc)
444pub const macDev: c_uint = 8;
445/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/undodev?language=objc)
446pub const undoDev: c_uint = 9;
447/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/cutdev?language=objc)
448pub const cutDev: c_uint = 10;
449/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/copydev?language=objc)
450pub const copyDev: c_uint = 11;
451/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/pastedev?language=objc)
452pub const pasteDev: c_uint = 12;
453/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/cleardev?language=objc)
454pub const clearDev: c_uint = 13;
455/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/cursordev?language=objc)
456pub const cursorDev: c_uint = 14;
457
458/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/cdevgenerr?language=objc)
459pub const cdevGenErr: c_int = -1;
460/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/cdevmemerr?language=objc)
461pub const cdevMemErr: c_int = 0;
462/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/cdevreserr?language=objc)
463pub const cdevResErr: c_int = 1;
464/// [Apple's documentation](https://developer.apple.com/documentation/applicationservices/cdevunset?language=objc)
465pub const cdevUnset: c_int = 3;