Cocoa: save window info when Application DeActive

This commit is contained in:
rich2014 2023-10-24 23:15:59 +08:00
parent 8d606b37f4
commit 4c33927499
2 changed files with 11 additions and 28 deletions

View File

@ -70,7 +70,6 @@ type
procedure application_openFiles(sender: NSApplication; filenames: NSArray);
procedure applicationDidHide(notification: NSNotification);
procedure applicationDidUnhide(notification: NSNotification);
procedure applicationWillBecomeActive(notification: NSNotification);
procedure applicationDidBecomeActive(notification: NSNotification);
procedure applicationWillResignActive(notification: NSNotification);
procedure applicationDidResignActive(notification: NSNotification);

View File

@ -599,33 +599,6 @@ begin
Application.IntfAppRestore;
end;
procedure TAppDelegate.applicationWillBecomeActive(notification: NSNotification
);
{$ifdef COCOA_ACTIVATION_REORDER}
var
app : NSApplication;
i: integer;
vis: Boolean;
info: PWinLevelOrder;
ord: NSArray;
{$endif}
begin
{$ifdef COCOA_ACTIVATION_REORDER}
app := NSApplication(NSApp);
ord := app.orderedWindows;
orderArrayCount := ord.count;
orderArray := GetMem(orderArrayCount * sizeof(TWinLevelOrder));
for i := 0 to orderArrayCount - 1 do
begin
info := @orderArray^[i];
info^.win := ord.objectAtIndex(i);
info^.lvl := info^.win.level;
info^.ord := info^.win.orderedIndex;
info^.vis := info^.win.isVisible;
end;
{$endif}
end;
procedure TAppDelegate.applicationDidBecomeActive(notification: NSNotification);
var
i : integer;
@ -661,9 +634,20 @@ var
windows: NSArray;
window: NSWindow;
form: TObject;
info: PWinLevelOrder;
begin
windows := NSApp.orderedWindows;
orderArrayCount := windows.count;
orderArray := GetMem(orderArrayCount * sizeof(TWinLevelOrder));
info:= orderArray^;
for window in windows do begin
info^.win := window;
info^.lvl := window.level;
info^.ord := window.orderedIndex;
info^.vis := window.isVisible;
inc( info );
form:= window.lclGetTarget;
if form is TCustomForm then begin
if TCustomForm(form).FormStyle<>fsSystemStayOnTop then