mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 05:19:14 +02:00
Gtk2: fixed visibility of THintWindow when switching desktops.issue #24363
git-svn-id: trunk@41001 -
This commit is contained in:
parent
516dfebcfc
commit
45c5cd91e9
@ -302,6 +302,7 @@ type
|
|||||||
function GetDesktopWidget: PGtkWidget;
|
function GetDesktopWidget: PGtkWidget;
|
||||||
//function X11Raise(AHandle: HWND): boolean; currently not used
|
//function X11Raise(AHandle: HWND): boolean; currently not used
|
||||||
function GetWindowManager: String;
|
function GetWindowManager: String;
|
||||||
|
function IsCurrentDesktop(AWindow: PGdkWindow): Boolean;
|
||||||
function X11GetActiveWindow: HWND;
|
function X11GetActiveWindow: HWND;
|
||||||
|
|
||||||
procedure HideAllHints;
|
procedure HideAllHints;
|
||||||
|
@ -4263,6 +4263,65 @@ begin
|
|||||||
@XClient)<>0;
|
@XClient)<>0;
|
||||||
end;}
|
end;}
|
||||||
|
|
||||||
|
function TGtk2WidgetSet.IsCurrentDesktop(AWindow: PGdkWindow): Boolean;
|
||||||
|
var
|
||||||
|
Display: PDisplay;
|
||||||
|
ScreenNum: Integer;
|
||||||
|
RootWin: TWindow;
|
||||||
|
WMAtom: TAtom;
|
||||||
|
|
||||||
|
typeReturned: TAtom;
|
||||||
|
formatReturned: Integer;
|
||||||
|
nitemsReturned: PtrInt;
|
||||||
|
unused: PtrInt;
|
||||||
|
WidgetIndex, DesktopIndex: Pointer;
|
||||||
|
WidgetWin: TWindow;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
if AWindow = nil then
|
||||||
|
exit;
|
||||||
|
Display := gdk_x11_get_default_xdisplay;
|
||||||
|
if Display = nil then
|
||||||
|
exit;
|
||||||
|
ScreenNum := gdk_x11_get_default_screen;
|
||||||
|
RootWin := XRootWindow(Display, ScreenNum);
|
||||||
|
WMAtom := XInternAtom(Display,'_NET_WM_DESKTOP', True);
|
||||||
|
WidgetWin := gdk_x11_drawable_get_xid(PGdkDrawable(AWindow));
|
||||||
|
|
||||||
|
if (WMAtom > 0) and (WidgetWin <> 0) then
|
||||||
|
begin
|
||||||
|
WidgetIndex := nil;
|
||||||
|
DesktopIndex := nil;
|
||||||
|
// first get our desktop num (virtual desktop !)
|
||||||
|
if XGetWindowProperty(Display, WidgetWin, WMAtom, 0, 4, False, XA_CARDINAL,
|
||||||
|
@typeReturned, @formatReturned, @nitemsReturned,
|
||||||
|
@unused, @WidgetIndex) = Success then
|
||||||
|
begin
|
||||||
|
if (typeReturned = XA_CARDINAL) and (formatReturned = 32) and
|
||||||
|
(WidgetIndex <> nil) then
|
||||||
|
begin
|
||||||
|
// now get current active desktop index
|
||||||
|
WMAtom := XInternAtom(Display,'_NET_CURRENT_DESKTOP', True);
|
||||||
|
if XGetWindowProperty(Display, RootWin, WMAtom, 0, 4, False,
|
||||||
|
XA_CARDINAL, @typeReturned, @formatReturned, @nitemsReturned,
|
||||||
|
@unused, @DesktopIndex) = Success then
|
||||||
|
begin
|
||||||
|
if (typeReturned = XA_CARDINAL) and (formatReturned = 32) and
|
||||||
|
(DesktopIndex <> nil) then
|
||||||
|
Result := PtrUint(WidgetIndex^) = PtrUint(DesktopIndex^);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if WidgetIndex <> nil then
|
||||||
|
XFree(WidgetIndex);
|
||||||
|
if DesktopIndex <> nil then
|
||||||
|
XFree(DesktopIndex);
|
||||||
|
WidgetIndex := nil;
|
||||||
|
DesktopIndex := nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TGtk2WidgetSet.GetWindowManager: String;
|
function TGtk2WidgetSet.GetWindowManager: String;
|
||||||
{used to get window manager name, so we can handle different wm's behaviour
|
{used to get window manager name, so we can handle different wm's behaviour
|
||||||
eg. kde vs. gnome}
|
eg. kde vs. gnome}
|
||||||
@ -4382,8 +4441,10 @@ begin
|
|||||||
if g_object_get_data(PGObject(Window),'lclhintwindow') <> nil then
|
if g_object_get_data(PGObject(Window),'lclhintwindow') <> nil then
|
||||||
begin
|
begin
|
||||||
if gdk_window_is_visible(PGDKWindow(List^.Data)) then
|
if gdk_window_is_visible(PGDKWindow(List^.Data)) then
|
||||||
|
begin
|
||||||
g_object_set_data(PGObject(Window),'lclneedrestorevisible',Pointer(1));
|
g_object_set_data(PGObject(Window),'lclneedrestorevisible',Pointer(1));
|
||||||
gdk_window_hide(PGDKWindow(List^.Data));
|
gdk_window_hide(PGDKWindow(List^.Data));
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -180,9 +180,40 @@ begin
|
|||||||
end;
|
end;
|
||||||
GDK_WINDOW_STATE:
|
GDK_WINDOW_STATE:
|
||||||
begin
|
begin
|
||||||
|
|
||||||
if (GDK_WINDOW_STATE_WITHDRAWN and event^.window_state.changed_mask) = 1 then
|
if (GDK_WINDOW_STATE_WITHDRAWN and event^.window_state.changed_mask) = 1 then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
{$IFDEF HASX}
|
||||||
WInfo := GetWidgetInfo(Widget);
|
WInfo := GetWidgetInfo(Widget);
|
||||||
|
if (event^.window_state.new_window_state = GDK_WINDOW_STATE_ICONIFIED) then
|
||||||
|
begin
|
||||||
|
if not Gtk2WidgetSet.IsCurrentDesktop(event^.window_state.window) then
|
||||||
|
begin
|
||||||
|
WInfo := GetWidgetInfo(Widget);
|
||||||
|
if (WInfo <> nil) and (WInfo^.LCLObject = Application.MainForm) then
|
||||||
|
begin
|
||||||
|
g_object_set_data(PGObject(Widget), 'lclhintrestore', Pointer(1));
|
||||||
|
GTK2WidgetSet.HideAllHints;
|
||||||
|
WInfo^.FormWindowState := Event^.window_state;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if (event^.window_state.new_window_state <> GDK_WINDOW_STATE_ICONIFIED) and
|
||||||
|
(WInfo <> nil) and (WInfo^.LCLObject = Application.MainForm) and
|
||||||
|
(event^.window_state.changed_mask = GDK_WINDOW_STATE_ICONIFIED) and
|
||||||
|
(WInfo^.FormWindowState.new_window_state = GDK_WINDOW_STATE_ICONIFIED) and
|
||||||
|
(g_object_get_data(PGObject(Widget), 'lclhintrestore') <> nil) then
|
||||||
|
begin
|
||||||
|
g_object_set_data(PGObject(Widget), 'lclhintrestore', nil);
|
||||||
|
Gtk2WidgetSet.RestoreAllHints;
|
||||||
|
WInfo^.FormWindowState := Event^.window_state;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
{$ELSE}
|
||||||
|
WInfo := GetWidgetInfo(Widget);
|
||||||
|
{$ENDIF}
|
||||||
if (WInfo <> nil) then
|
if (WInfo <> nil) then
|
||||||
begin
|
begin
|
||||||
if (WInfo^.FormWindowState.new_window_state <> event^.window_state.new_window_state)
|
if (WInfo^.FormWindowState.new_window_state <> event^.window_state.new_window_state)
|
||||||
|
Loading…
Reference in New Issue
Block a user