mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 02:59:17 +02:00
cocoa: resolve windows-level wrong use. A drawback - lost SystemOnTop setting, now behave similar to OnTop. (similar to Windows). #34939
git-svn-id: trunk@61162 -
This commit is contained in:
parent
398156e28e
commit
9e4ab0beb5
@ -212,21 +212,15 @@ const
|
|||||||
NSAppKitVersionNumber10_14 = 1641.10;
|
NSAppKitVersionNumber10_14 = 1641.10;
|
||||||
|
|
||||||
|
|
||||||
const
|
function NSNormalWindowLevel: NSInteger; inline;
|
||||||
//kCGBaseWindowLevelKey = 0;
|
function NSFloatingWindowLevel: NSInteger; inline;
|
||||||
//kCGMinimumWindowLevelKey = 1;
|
function NSSubmenuWindowLevel: NSInteger; inline;
|
||||||
//kCGDesktopWindowLevelKey = 2;
|
function NSTornOffMenuWindowLevel: NSInteger; inline;
|
||||||
//kCGBackstopMenuLevelKey = 3;
|
function NSMainMenuWindowLevel: NSInteger; inline;
|
||||||
NSNormalWindowLevel = 4;
|
function NSStatusWindowLevel: NSInteger; inline;
|
||||||
NSFloatingWindowLevel = 5;
|
function NSModalPanelWindowLevel: NSInteger; inline;
|
||||||
NSSubmenuWindowLevel = 6;
|
function NSPopUpMenuWindowLevel: NSInteger; inline;
|
||||||
NSTornOffMenuWindowLevel = 6;
|
function NSScreenSaverWindowLevel: NSInteger; inline;
|
||||||
//kCGDockWindowLevelKey = 7; deprecated
|
|
||||||
NSMainMenuWindowLevel = 8;
|
|
||||||
NSStatusWindowLevel = 9;
|
|
||||||
NSModalPanelWindowLevel = 10;
|
|
||||||
NSPopUpMenuWindowLevel = 11;
|
|
||||||
NSScreenSaverWindowLevel = 12;
|
|
||||||
//kCGScreenSaverWindowLevelKey = 13;
|
//kCGScreenSaverWindowLevelKey = 13;
|
||||||
//kCGMaximumWindowLevelKey = 14;
|
//kCGMaximumWindowLevelKey = 14;
|
||||||
//kCGOverlayWindowLevelKey = 15;
|
//kCGOverlayWindowLevelKey = 15;
|
||||||
@ -273,5 +267,50 @@ const
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
function NSNormalWindowLevel: NSInteger;
|
||||||
|
begin
|
||||||
|
Result:=CGWindowLevelForKey(kCGNormalWindowLevelKey);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function NSFloatingWindowLevel: NSInteger;
|
||||||
|
begin
|
||||||
|
Result:=CGWindowLevelForKey(kCGFloatingWindowLevelKey);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function NSSubmenuWindowLevel: NSInteger;
|
||||||
|
begin
|
||||||
|
Result:=CGWindowLevelForKey(kCGTornOffMenuWindowLevelKey);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function NSTornOffMenuWindowLevel: NSInteger;
|
||||||
|
begin
|
||||||
|
Result:=CGWindowLevelForKey(kCGTornOffMenuWindowLevelKey);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function NSMainMenuWindowLevel: NSInteger;
|
||||||
|
begin
|
||||||
|
Result:=CGWindowLevelForKey(kCGMainMenuWindowLevelKey);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function NSStatusWindowLevel: NSInteger;
|
||||||
|
begin
|
||||||
|
Result:=CGWindowLevelForKey(kCGStatusWindowLevelKey);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function NSModalPanelWindowLevel: NSInteger;
|
||||||
|
begin
|
||||||
|
Result:=CGWindowLevelForKey(kCGModalPanelWindowLevelKey);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function NSPopUpMenuWindowLevel: NSInteger;
|
||||||
|
begin
|
||||||
|
Result:=CGWindowLevelForKey(kCGPopUpMenuWindowLevelKey);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function NSScreenSaverWindowLevel: NSInteger;
|
||||||
|
begin
|
||||||
|
Result:=CGWindowLevelForKey(kCGScreenSaverWindowLevelKey);
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -182,16 +182,17 @@ uses
|
|||||||
CocoaInt;
|
CocoaInt;
|
||||||
|
|
||||||
const
|
const
|
||||||
// The documentation says we should use NSNormalWindowLevel=4 for normal forms,
|
// The documentation is using constants like "NSNormalWindowLevel=4" for normal forms,
|
||||||
// but in practice this causes the issue http://bugs.freepascal.org/view.php?id=28473
|
// however, these are macros of a function call to CGWindowLevelKey()
|
||||||
// The only value that works is zero =(
|
// where "Key" values of kCGNormalWindowLevelKey=4.
|
||||||
FormStyleToWindowLevel: array[TFormStyle] of NSInteger = (
|
|
||||||
{ fsNormal } 0,
|
FormStyleToWindowLevelKey: array[TFormStyle] of NSInteger = (
|
||||||
{ fsMDIChild } 0,
|
{ fsNormal } kCGNormalWindowLevelKey,
|
||||||
{ fsMDIForm } 0,
|
{ fsMDIChild } kCGNormalWindowLevelKey,
|
||||||
{ fsStayOnTop } 9, // NSStatusWindowLevel
|
{ fsMDIForm } kCGNormalWindowLevelKey,
|
||||||
{ fsSplash } 9, // NSStatusWindowLevel
|
{ fsStayOnTop } kCGFloatingWindowLevelKey,
|
||||||
{ fsSystemStayOnTop } 10 // NSModalPanelWindowLevel
|
{ fsSplash } kCGFloatingWindowLevelKey,
|
||||||
|
{ fsSystemStayOnTop } kCGFloatingWindowLevelKey // NSModalPanelWindowLevel
|
||||||
);
|
);
|
||||||
// Window levels make the form always stay on top, so if it is supposed to
|
// 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
|
// stay on top of the app only, then a workaround is to hide it while the app
|
||||||
@ -200,8 +201,8 @@ const
|
|||||||
{ fsNormal } False,
|
{ fsNormal } False,
|
||||||
{ fsMDIChild } False,
|
{ fsMDIChild } False,
|
||||||
{ fsMDIForm } False,
|
{ fsMDIForm } False,
|
||||||
{ fsStayOnTop } True,
|
{ fsStayOnTop } false,
|
||||||
{ fsSplash } True,
|
{ fsSplash } false,
|
||||||
{ fsSystemStayOnTop } False
|
{ fsSystemStayOnTop } False
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -219,24 +220,12 @@ procedure WindowSetFormStyle(win: NSWindow; AFormStyle: TFormStyle);
|
|||||||
var
|
var
|
||||||
lvl : NSInteger;
|
lvl : NSInteger;
|
||||||
begin
|
begin
|
||||||
if not (AFormStyle in [fsNormal, fsMDIChild, fsMDIForm]) then
|
lvl := CGWindowLevelForKey(FormStyleToWindowLevelKey[AFormStyle]);
|
||||||
begin
|
{$ifdef BOOLFIX}
|
||||||
lvl := FormStyleToWindowLevel[AFormStyle];
|
win.setHidesOnDeactivate_(Ord(FormStyleToHideOnDeactivate[AFormStyle]));
|
||||||
{$ifdef BOOLFIX}
|
{$else}
|
||||||
win.setHidesOnDeactivate_(Ord(FormStyleToHideOnDeactivate[AFormStyle]));
|
win.setHidesOnDeactivate(FormStyleToHideOnDeactivate[AFormStyle]);
|
||||||
{$else}
|
{$endif}
|
||||||
win.setHidesOnDeactivate(FormStyleToHideOnDeactivate[AFormStyle]);
|
|
||||||
{$endif}
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
lvl := 0;
|
|
||||||
{$ifdef BOOLFIX}
|
|
||||||
win.setHidesOnDeactivate_(Ord(false));
|
|
||||||
{$else}
|
|
||||||
win.setHidesOnDeactivate(false);
|
|
||||||
{$endif}
|
|
||||||
end;
|
|
||||||
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