mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-05 22:20:32 +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,
|
||||
// LCL
|
||||
LCLStrConsts, LMessages, LCLMessageGlue, LCLProc, LCLIntf, LCLType,
|
||||
Controls,
|
||||
Controls, Forms,
|
||||
IntfGraphics, Graphics, CocoaWSFactory;
|
||||
|
||||
type
|
||||
|
@ -43,16 +43,30 @@ begin
|
||||
FNSApp.setDelegate(delegate);
|
||||
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
|
||||
Params: ALoop
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCocoaWidgetSet.AppRun(const ALoop: TApplicationMainLoop);
|
||||
var
|
||||
Observer: CFRunLoopObserverRef;
|
||||
begin
|
||||
{$IFDEF VerboseObject}
|
||||
DebugLn('TCocoaWidgetSet.AppRun');
|
||||
{$ENDIF}
|
||||
|
||||
Observer := CFRunLoopObserverCreate(kCFAllocatorDefault, kCFRunLoopBeforeWaiting, True, 0, @RunLoopObserverCallBack, nil);
|
||||
CFRunLoopAddObserver(CFRunLoopGetCurrent, Observer, kCFRunLoopCommonModes);
|
||||
{ Enters main message loop }
|
||||
NSApp.run;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user