diff --git a/lcl/interfaces/carbon/carbonint.pas b/lcl/interfaces/carbon/carbonint.pas index d35b5ceb92..749f8c8954 100644 --- a/lcl/interfaces/carbon/carbonint.pas +++ b/lcl/interfaces/carbon/carbonint.pas @@ -75,7 +75,7 @@ type FAppLoop: TApplicationMainLoop; FAppStdEvents: Boolean; fMenuEnabled: Boolean; - FAEventHandlerRef: array[0..10] of EventHandlerRef; + FAEventHandlerRef: array[0..5] of EventHandlerRef; {$ifdef CarbonUseCocoa} pool: NSAutoreleasePool; {$endif} diff --git a/lcl/interfaces/carbon/carbonobject.inc b/lcl/interfaces/carbon/carbonobject.inc index e91c537721..6895c05b61 100644 --- a/lcl/interfaces/carbon/carbonobject.inc +++ b/lcl/interfaces/carbon/carbonobject.inc @@ -361,6 +361,26 @@ begin Application.IntfAppActivate; end; +{------------------------------------------------------------------------------ + Name: CarbonApp_Activated + Handles application activation + ------------------------------------------------------------------------------} +function CarbonApp_LazWake(ANextHandler: EventHandlerCallRef; + AEvent: EventRef; + {%H-}AWidget: TCarbonWidget): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF} +begin + {$IFDEF VerboseAppEvent} + DebugLn('CarbonApp_LazWake'); + {$ENDIF} + + Result := CallNextEventHandler(ANextHandler, AEvent); + + if IsMultiThread then + begin + // a thread is waiting -> synchronize + CheckSynchronize; + end; +end; {------------------------------------------------------------------------------ @@ -613,10 +633,8 @@ begin {$IFDEF DebugEventLoop} DebugLn('EventKind: ',CurEventKind.Chars); {$ENDIF} - if (CurEventKind.Chars = LCLCarbonEventKindWake) and IsMultiThread then + if (CurEventKind.Chars = LCLCarbonEventKindUser) then begin - // a thread is waiting -> synchronize - CheckSynchronize; end; end; @@ -1195,6 +1213,10 @@ begin InstallApplicationEventHandler(RegisterEventHandler(@CarbonApp_Activated), 1, @TmpSpec, nil, @FAEventHandlerRef[4]); + TmpSpec := MakeEventSpec(LCLCarbonEventClass, LCLCarbonEventKindWake); + InstallApplicationEventHandler(RegisterEventHandler(@CarbonApp_LazWake), + 1, @TmpSpec, nil, @FAEventHandlerRef[5]); + FOpenEventHandlerUPP := NewAEEventHandlerUPP(AEEventHandlerProcPtr(@CarbonApp_Open)); FQuitEventHandlerUPP := NewAEEventHandlerUPP(AEEventHandlerProcPtr(@CarbonApp_Quit)); OSError( @@ -1225,7 +1247,7 @@ begin {$ENDIF} FUserTerm:=True; QuitApplicationEventLoop; - for i:=0 to 4 do + for i:=Low(FAEventHandlerRef) to High(FAEventHandlerRef) do OSError(MacOSALL.RemoveEventHandler(FAEventHandlerRef[i]), TClass(Self), SName, 'RemoveEventHandler'); end;