mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 20:21:04 +02:00
Cocoa: Fix #40569: Merge branch 'cocoa/ontop', fsStayOnTop improved
This commit is contained in:
commit
f35f68c5b6
@ -70,8 +70,8 @@ type
|
|||||||
procedure application_openFiles(sender: NSApplication; filenames: NSArray);
|
procedure application_openFiles(sender: NSApplication; filenames: NSArray);
|
||||||
procedure applicationDidHide(notification: NSNotification);
|
procedure applicationDidHide(notification: NSNotification);
|
||||||
procedure applicationDidUnhide(notification: NSNotification);
|
procedure applicationDidUnhide(notification: NSNotification);
|
||||||
procedure applicationWillBecomeActive(notification: NSNotification);
|
|
||||||
procedure applicationDidBecomeActive(notification: NSNotification);
|
procedure applicationDidBecomeActive(notification: NSNotification);
|
||||||
|
procedure applicationWillResignActive(notification: NSNotification);
|
||||||
procedure applicationDidResignActive(notification: NSNotification);
|
procedure applicationDidResignActive(notification: NSNotification);
|
||||||
procedure applicationDidChangeScreenParameters(notification: NSNotification);
|
procedure applicationDidChangeScreenParameters(notification: NSNotification);
|
||||||
procedure applicationWillFinishLaunching(notification: NSNotification);
|
procedure applicationWillFinishLaunching(notification: NSNotification);
|
||||||
|
@ -599,49 +599,23 @@ begin
|
|||||||
Application.IntfAppRestore;
|
Application.IntfAppRestore;
|
||||||
end;
|
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);
|
procedure TAppDelegate.applicationDidBecomeActive(notification: NSNotification);
|
||||||
var
|
var
|
||||||
i : integer;
|
i : integer;
|
||||||
begin
|
begin
|
||||||
{$ifdef COCOA_ACTIVATION_REORDER}
|
|
||||||
// Cocoa changes level and order of windows to it's liking
|
// Cocoa changes level and order of windows to it's liking
|
||||||
// (it happens between Will- and DidBecomeActive)
|
// (it happens between Will- and DidBecomeActive)
|
||||||
// for example Model windows becoming level 8,
|
// for example Model windows becoming level 8,
|
||||||
// even if LCL set them to level 0 before.
|
// even if LCL set them to level 0 before.
|
||||||
// As a result the OrderedIndex also goes messed up.
|
// As a result the OrderedIndex also goes messed up.
|
||||||
// It's being restored here
|
// It's being restored here
|
||||||
for i := orderArrayCount -1 downto 0 do
|
for i := orderArrayCount-1 downto 0 do
|
||||||
begin
|
begin
|
||||||
if not orderArray^[i].vis then continue;
|
if not orderArray^[i].vis then
|
||||||
|
continue;
|
||||||
|
if orderArray^[i].lvl=NSNormalWindowLevel then
|
||||||
|
continue;
|
||||||
orderArray^[i].win.setLevel( orderArray^[i].lvl );
|
orderArray^[i].win.setLevel( orderArray^[i].lvl );
|
||||||
orderArray^[i].win.setOrderedIndex( orderArray^[i].ord );
|
|
||||||
orderArray^[i].win.orderFrontRegardless;
|
orderArray^[i].win.orderFrontRegardless;
|
||||||
end;
|
end;
|
||||||
orderArrayCount := 0;
|
orderArrayCount := 0;
|
||||||
@ -650,11 +624,52 @@ begin
|
|||||||
Freemem(orderArray);
|
Freemem(orderArray);
|
||||||
orderArray := nil;
|
orderArray := nil;
|
||||||
end;
|
end;
|
||||||
{$endif}
|
|
||||||
|
|
||||||
Application.IntfAppActivate;
|
Application.IntfAppActivate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TAppDelegate.applicationWillResignActive(notification: NSNotification
|
||||||
|
);
|
||||||
|
var
|
||||||
|
baseWindowNumber: NSInteger;
|
||||||
|
windows: NSArray;
|
||||||
|
window: NSWindow;
|
||||||
|
form: TObject;
|
||||||
|
info: PWinLevelOrder;
|
||||||
|
begin
|
||||||
|
windows := NSApp.orderedWindows;
|
||||||
|
|
||||||
|
baseWindowNumber:= 0;
|
||||||
|
for window in windows do begin
|
||||||
|
if window.level=NSNormalWindowLevel then begin
|
||||||
|
baseWindowNumber:= window.windowNumber;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
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 );
|
||||||
|
end;
|
||||||
|
|
||||||
|
for window in windows do begin
|
||||||
|
form:= window.lclGetTarget;
|
||||||
|
if form is TCustomForm then begin
|
||||||
|
if TCustomForm(form).FormStyle=fsStayOnTop then begin
|
||||||
|
window.setLevel( NSNormalWindowLevel );
|
||||||
|
window.orderWindow_relativeTo( NSWindowAbove, baseWindowNumber );
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TAppDelegate.applicationDidResignActive(notification: NSNotification);
|
procedure TAppDelegate.applicationDidResignActive(notification: NSNotification);
|
||||||
begin
|
begin
|
||||||
Application.IntfAppDeactivate;
|
Application.IntfAppDeactivate;
|
||||||
|
@ -214,17 +214,6 @@ const
|
|||||||
{ fsSplash } kCGFloatingWindowLevelKey,
|
{ fsSplash } kCGFloatingWindowLevelKey,
|
||||||
{ fsSystemStayOnTop } kCGFloatingWindowLevelKey // NSModalPanelWindowLevel
|
{ fsSystemStayOnTop } kCGFloatingWindowLevelKey // NSModalPanelWindowLevel
|
||||||
);
|
);
|
||||||
// Window levels make the form always stay on top, so if it is supposed to
|
|
||||||
// stay on top of the app only, then a workaround is to hide it while the app
|
|
||||||
// is deactivated
|
|
||||||
FormStyleToHideOnDeactivate: array[TFormStyle] of Boolean = (
|
|
||||||
{ fsNormal } False,
|
|
||||||
{ fsMDIChild } False,
|
|
||||||
{ fsMDIForm } False,
|
|
||||||
{ fsStayOnTop } True,
|
|
||||||
{ fsSplash } false,
|
|
||||||
{ fsSystemStayOnTop } False
|
|
||||||
);
|
|
||||||
|
|
||||||
HintWindowLevel = 11; // NSPopUpMenuWindowLevel
|
HintWindowLevel = 11; // NSPopUpMenuWindowLevel
|
||||||
|
|
||||||
@ -241,11 +230,6 @@ var
|
|||||||
lvl : NSInteger;
|
lvl : NSInteger;
|
||||||
begin
|
begin
|
||||||
lvl := CGWindowLevelForKey(FormStyleToWindowLevelKey[AFormStyle]);
|
lvl := CGWindowLevelForKey(FormStyleToWindowLevelKey[AFormStyle]);
|
||||||
{$ifdef BOOLFIX}
|
|
||||||
win.setHidesOnDeactivate_(Ord(FormStyleToHideOnDeactivate[AFormStyle]));
|
|
||||||
{$else}
|
|
||||||
win.setHidesOnDeactivate(FormStyleToHideOnDeactivate[AFormStyle]);
|
|
||||||
{$endif}
|
|
||||||
win.setLevel(lvl);
|
win.setLevel(lvl);
|
||||||
if win.isKindOfClass(TCocoaWindow) then
|
if win.isKindOfClass(TCocoaWindow) then
|
||||||
TCocoaWindow(win).keepWinLevel := lvl;
|
TCocoaWindow(win).keepWinLevel := lvl;
|
||||||
|
Loading…
Reference in New Issue
Block a user