cocoa: restoring the use of CocoaLoopOverride for a better control of the message loop. bug #36405

git-svn-id: trunk@62413 -
This commit is contained in:
dmitry 2019-12-18 19:18:15 +00:00
parent a896e7f941
commit 810d3c4e27
3 changed files with 13 additions and 7 deletions

View File

@ -20,7 +20,7 @@
// the first request to process an event, and run LCL loop from there.
// Such approach is some what an ugly solution, yet it's reliable, in a sense
// that Cocoa performs ALL of this methods.
{.$define COCOALOOPOVERRIDE}
{$define COCOALOOPOVERRIDE}
// Not override "run" method. Catch any FPC exception
// The biggest problem of the Native approach - LCL "runloop" method is not called

View File

@ -86,6 +86,7 @@ type
modals : NSMutableDictionary;
inputclient : TCocoaInputClient;
inputctx : NSTextInputContext;
isfinishLaunch: Boolean;
procedure dealloc; override;
{$ifdef COCOALOOPOVERRIDE}
@ -120,7 +121,7 @@ type
TCocoaWidgetSet = class(TWidgetSet)
private
FTerminating: Boolean;
FNSApp: NSApplication;
FNSApp: TCocoaApplication;
FNSApp_Delegate: TAppDelegate;
FCurrentCursor: HCursor;
FCaptureControl: HWND;
@ -224,7 +225,7 @@ type
function RawImage_DescriptionToBitmapType(ADesc: TRawImageDescription; out bmpType: TCocoaBitmapType): Boolean;
function GetImagePixelData(AImage: CGImageRef; out bitmapByteCount: PtrUInt): Pointer;
class function Create32BitAlphaBitmap(ABitmap, AMask: TCocoaBitmap): TCocoaBitmap;
property NSApp: NSApplication read FNSApp;
property NSApp: TCocoaApplication read FNSApp;
property CurrentCursor: HCursor read FCurrentCursor write FCurrentCursor;
property CaptureControl: HWND read FCaptureControl;
// the winapi compatibility methods

View File

@ -38,7 +38,7 @@ begin
ScreenInfo.PixelsPerInchY := CocoaBasePPI;
{ Creates the application NSApp object }
FNSApp := TCocoaApplication.sharedApplication;
FNSApp := TCocoaApplication(TCocoaApplication.sharedApplication);
FNSApp_Delegate := TAppDelegate.alloc.init;
FNSApp.setDelegate(FNSApp_Delegate);
@ -69,9 +69,6 @@ end;
------------------------------------------------------------------------------}
procedure TCocoaWidgetSet.AppRun(const ALoop: TApplicationMainLoop);
begin
{$ifdef COCOALOOPOVERRIDE}
NSApp.finishLaunching;
{$endif}
if Assigned(ALoop) then
begin
TCocoaApplication(NSApp).aloop:=ALoop;
@ -84,6 +81,14 @@ var
event: NSEvent;
pool:NSAutoReleasePool;
begin
{$ifdef COCOALOOPOVERRIDE}
if not fNSApp.isfinishLaunch then
begin
FNSApp.finishLaunching;
FNSApp.isfinishLaunch := true;
end;
{$endif}
repeat
pool := NSAutoreleasePool.alloc.init;
{$ifdef BOOLFIX}