1{.$define COCOA_USE_NATIVE_MODAL}
2
3// There's an issue identified with passing boolean parameters.
4// with FPC 3.0.4. see: https://bugs.freepascal.org/view.php?id=34411
5//
6// In short: Boolean is being passed only as 8-bits value, leaving
7// other registers untouched. Apple code (compiler) however,
8// reads the entire 32-bit value of the register.
9// x86_64 ABI is not entirely complete regarding the proper ways
10//
11// The issue is presumably only for 64-bit platform.
12// The workaround is possible! the issue should be fixed in future
13// release of FPC, but 3.0.4 is the offical supported by LCL.
14{$if FPC_FULLVERSION>=30200}
15{$undef BOOLFIX}
16{$else}
17{$define BOOLFIX}
18{$endif}
19
20
21// Originally LCL-Cocoa would override "run" method and have direct control
22// over the event loop. However that presumed to cause issues in macOS 10.15
23// The code was changed not to override "run" loop, but instead override
24// the first request to process an event, and run LCL loop from there.
25// Such approach is some what an ugly solution, yet it's reliable, in a sense
26// that Cocoa performs ALL of this methods.
27{$define COCOALOOPOVERRIDE}
28
29// Not override "run" method. Catch any FPC exception
30// The biggest problem of the Native approach - LCL "runloop" method is not called
31// at all. Thus if LCL implementation is changed, CocoaWS needs to be updated
32{.$define COCOALOOPNATIVE}
33
34{$if not defined(COCOALOOPOVERRIDE) and not defined(COCOALOOPNATIVE)}
35// the first call to nextEventMatchingMask_untilDate_inMode_dequeue would
36// cause an LCL event processing loop to be called.
37// the call stays there until, LCL application is terminated
38{$define COCOALOOPHIJACK}
39{$endif}
40
41{$ifdef COCOALOOPOVERRIDE}
42  // The proper switching modal dialogs depends on NSApp.isRunning method
43  // The method returns true (on macOS 10.15 and later), only with "run" method
44  // called direclty.
45  // (there's an internal flag, that's defines the value of the property)
46  // Since LCL needs the direct control over the event loop (with Loopoverride)
47  // it canot call the inherited NSapp.run. (or the control is lossed to Cocoa)
48  //
49  // Instead, CocoaWS can set isRunning property to true, in TWO ways
50  //   1) (COCOAPPRUNNING_OVERRIDEPROPERTY)
51  //      override isRunning method and return TRUE when wanted
52  //   2) (COCOAPPRUNNING_SETINTPROPERTY)
53  //      using KeyValue APIs set the internal property
54  // Either method is not entirely good, but it makes modal switching work.
55  //
56  // The actual problem (of not having isRunning set to true), is the following:
57  // 1) Create a window.
58  // 2) Show a modal dialog.
59  // 3) Close the modal window
60  // 4) the focus stays in the closed and hidden modal window...
61  // with NSApp.isRunning, the focus goes back to the previously active window
62
63  {$define COCOAPPRUNNING_OVERRIDEPROPERTY}
64  {.$define COCOAPPRUNNING_SETINTPROPERTY}
65{$endif}
66
67// COCOA_NATIVEACTIVATION allows to prevent COCOA_ACTIVATION_REORDER
68{$ifndef COCOA_NATIVEACTIVATION}
69// The order of the windows needs to be restored, when the application
70// is reactivated. This is due to the LCL modality used.
71//
72// However, resorting windows is impacting 10.15 File Dialogs.
73// File Dialogs are duplicated with an external application.
74// The File Dialog is loosing its accessory view (file type selection).
75{$define COCOA_ACTIVATION_REORDER}
76{$endif}
77