cocoa: update event loops handling. Suppressing the explicit LCL sync message. Internal handling of PostAsyncCallQueue. Patch by David Jenkins. #35547

git-svn-id: trunk@61207 -
This commit is contained in:
dmitry 2019-05-12 01:16:12 +00:00
parent 96567e8916
commit e1fb95fb10
2 changed files with 30 additions and 20 deletions

View File

@ -492,6 +492,9 @@ begin
or (tp = NSOtherMouseDragged);
end;
type
TCrackerApplication = class(TApplication);
function TCocoaApplication.nextEventMatchingMask_untilDate_inMode_dequeue(
mask: NSUInteger; expiration: NSDate; mode: NSString; deqFlag: LCLObjCBoolean
): NSEvent;
@ -505,22 +508,35 @@ begin
Result:=inherited nextEventMatchingMask_untilDate_inMode_dequeue(mask,
expiration, mode, deqFlag);
{$endif}
if Assigned(Result)
and ((mode = NSEventTrackingRunLoopMode) or mode.isEqualToString(NSEventTrackingRunLoopMode))
and Assigned(TrackedControl)
then
if Assigned(Result) then
begin
if Result.type_ = NSLeftMouseUp then
if (Result.type_ = NSApplicationDefined)
and (Result.subtype = LCLEventSubTypeMessage)
and (Result.data1 = LM_NULL)
and (Result.data2 = WidgetSet.AppHandle)
then
begin
//todo: send callback!
TrackedControl := nil;
CheckSynchronize;
NSApp.updateWindows;
TCrackerApplication(Application).ProcessAsyncCallQueue;
Result := nil
end
else
if isMouseMoveEvent(Result.type_) then
else if ((mode = NSEventTrackingRunLoopMode) or mode.isEqualToString(NSEventTrackingRunLoopMode))
and Assigned(TrackedControl)
then
begin
cb := TrackedControl.lclGetCallback;
if Assigned(cb) then cb.MouseMove(Result);
end;
if Result.type_ = NSLeftMouseUp then
begin
//todo: send callback!
TrackedControl := nil;
end
else
if isMouseMoveEvent(Result.type_) then
begin
cb := TrackedControl.lclGetCallback;
if Assigned(cb) then cb.MouseMove(Result);
end
end;
end;
end;

View File

@ -108,10 +108,7 @@ begin
{$endif}
if event <> nil then
begin
if (event.type_ = NSApplicationDefined) and (event.subtype = LCLEventSubTypeMessage) and (event.data1 = LM_NULL) and (event.data2 = AppHandle) then
CheckSynchronize
else
NSApp.sendEvent(event);
NSApp.sendEvent(event);
NSApp.updateWindows;
end;
@ -140,10 +137,7 @@ begin
{$endif}
if event <> nil then
begin
if (event.type_ = NSApplicationDefined) and (event.subtype = LCLEventSubTypeMessage) and (event.data1 = LM_NULL) and (event.data2 = AppHandle) then
CheckSynchronize
else
NSApp.sendEvent(event);
NSApp.sendEvent(event);
NSApp.updateWindows;
end;