mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 21:39:11 +02:00
lcl: carbon: handle laz,wake event via handler, needed because carbon modal forms create their own sub loops, see bug #23601
git-svn-id: trunk@39832 -
This commit is contained in:
parent
929ce8fe33
commit
db44871558
@ -75,7 +75,7 @@ type
|
|||||||
FAppLoop: TApplicationMainLoop;
|
FAppLoop: TApplicationMainLoop;
|
||||||
FAppStdEvents: Boolean;
|
FAppStdEvents: Boolean;
|
||||||
fMenuEnabled: Boolean;
|
fMenuEnabled: Boolean;
|
||||||
FAEventHandlerRef: array[0..10] of EventHandlerRef;
|
FAEventHandlerRef: array[0..5] of EventHandlerRef;
|
||||||
{$ifdef CarbonUseCocoa}
|
{$ifdef CarbonUseCocoa}
|
||||||
pool: NSAutoreleasePool;
|
pool: NSAutoreleasePool;
|
||||||
{$endif}
|
{$endif}
|
||||||
|
@ -361,6 +361,26 @@ begin
|
|||||||
Application.IntfAppActivate;
|
Application.IntfAppActivate;
|
||||||
end;
|
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}
|
{$IFDEF DebugEventLoop}
|
||||||
DebugLn('EventKind: ',CurEventKind.Chars);
|
DebugLn('EventKind: ',CurEventKind.Chars);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if (CurEventKind.Chars = LCLCarbonEventKindWake) and IsMultiThread then
|
if (CurEventKind.Chars = LCLCarbonEventKindUser) then
|
||||||
begin
|
begin
|
||||||
// a thread is waiting -> synchronize
|
|
||||||
CheckSynchronize;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1195,6 +1213,10 @@ begin
|
|||||||
InstallApplicationEventHandler(RegisterEventHandler(@CarbonApp_Activated),
|
InstallApplicationEventHandler(RegisterEventHandler(@CarbonApp_Activated),
|
||||||
1, @TmpSpec, nil, @FAEventHandlerRef[4]);
|
1, @TmpSpec, nil, @FAEventHandlerRef[4]);
|
||||||
|
|
||||||
|
TmpSpec := MakeEventSpec(LCLCarbonEventClass, LCLCarbonEventKindWake);
|
||||||
|
InstallApplicationEventHandler(RegisterEventHandler(@CarbonApp_LazWake),
|
||||||
|
1, @TmpSpec, nil, @FAEventHandlerRef[5]);
|
||||||
|
|
||||||
FOpenEventHandlerUPP := NewAEEventHandlerUPP(AEEventHandlerProcPtr(@CarbonApp_Open));
|
FOpenEventHandlerUPP := NewAEEventHandlerUPP(AEEventHandlerProcPtr(@CarbonApp_Open));
|
||||||
FQuitEventHandlerUPP := NewAEEventHandlerUPP(AEEventHandlerProcPtr(@CarbonApp_Quit));
|
FQuitEventHandlerUPP := NewAEEventHandlerUPP(AEEventHandlerProcPtr(@CarbonApp_Quit));
|
||||||
OSError(
|
OSError(
|
||||||
@ -1225,7 +1247,7 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
FUserTerm:=True;
|
FUserTerm:=True;
|
||||||
QuitApplicationEventLoop;
|
QuitApplicationEventLoop;
|
||||||
for i:=0 to 4 do
|
for i:=Low(FAEventHandlerRef) to High(FAEventHandlerRef) do
|
||||||
OSError(MacOSALL.RemoveEventHandler(FAEventHandlerRef[i]),
|
OSError(MacOSALL.RemoveEventHandler(FAEventHandlerRef[i]),
|
||||||
TClass(Self), SName, 'RemoveEventHandler');
|
TClass(Self), SName, 'RemoveEventHandler');
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user