mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-12 10:19:15 +02:00
cocoa: add Idle observer, notify application when cocoa enters Idle state
git-svn-id: trunk@38944 -
This commit is contained in:
parent
c639b7f82f
commit
983bc213aa
@ -42,7 +42,7 @@ uses
|
|||||||
CocoaProc,
|
CocoaProc,
|
||||||
// LCL
|
// LCL
|
||||||
LCLStrConsts, LMessages, LCLMessageGlue, LCLProc, LCLIntf, LCLType,
|
LCLStrConsts, LMessages, LCLMessageGlue, LCLProc, LCLIntf, LCLType,
|
||||||
Controls,
|
Controls, Forms,
|
||||||
IntfGraphics, Graphics, CocoaWSFactory;
|
IntfGraphics, Graphics, CocoaWSFactory;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
@ -43,16 +43,30 @@ begin
|
|||||||
FNSApp.setDelegate(delegate);
|
FNSApp.setDelegate(delegate);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
type
|
||||||
|
CFRunLoopObserverContextRef = ^CFRunLoopObserverContext;
|
||||||
|
function CFRunLoopObserverCreate(allocator: CFAllocatorRef; activities: CFOptionFlags; repeats: Boolean; order: CFIndex; callout: CFRunLoopObserverCallBack; context: CFRunLoopObserverContextRef): CFRunLoopObserverRef; mwpascal; external name '_CFRunLoopObserverCreate';
|
||||||
|
|
||||||
|
procedure RunLoopObserverCallback(observer: CFRunLoopObserverRef; activity: CFRunLoopActivity; info: UnivPtr); mwpascal;
|
||||||
|
begin
|
||||||
|
if activity = kCFRunLoopBeforeWaiting then
|
||||||
|
Application.Idle(False);
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCocoaWidgetSet.AppRun
|
Method: TCocoaWidgetSet.AppRun
|
||||||
Params: ALoop
|
Params: ALoop
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TCocoaWidgetSet.AppRun(const ALoop: TApplicationMainLoop);
|
procedure TCocoaWidgetSet.AppRun(const ALoop: TApplicationMainLoop);
|
||||||
|
var
|
||||||
|
Observer: CFRunLoopObserverRef;
|
||||||
begin
|
begin
|
||||||
{$IFDEF VerboseObject}
|
{$IFDEF VerboseObject}
|
||||||
DebugLn('TCocoaWidgetSet.AppRun');
|
DebugLn('TCocoaWidgetSet.AppRun');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
Observer := CFRunLoopObserverCreate(kCFAllocatorDefault, kCFRunLoopBeforeWaiting, True, 0, @RunLoopObserverCallBack, nil);
|
||||||
|
CFRunLoopAddObserver(CFRunLoopGetCurrent, Observer, kCFRunLoopCommonModes);
|
||||||
{ Enters main message loop }
|
{ Enters main message loop }
|
||||||
NSApp.run;
|
NSApp.run;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user