Gtk2: fixed visibility of THintWindow when switching desktops.issue #24363

git-svn-id: trunk@41001 -
This commit is contained in:
zeljko 2013-05-02 15:09:58 +00:00
parent 516dfebcfc
commit 45c5cd91e9
3 changed files with 94 additions and 1 deletions

View File

@ -302,6 +302,7 @@ type
function GetDesktopWidget: PGtkWidget;
//function X11Raise(AHandle: HWND): boolean; currently not used
function GetWindowManager: String;
function IsCurrentDesktop(AWindow: PGdkWindow): Boolean;
function X11GetActiveWindow: HWND;
procedure HideAllHints;

View File

@ -4263,6 +4263,65 @@ begin
@XClient)<>0;
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;
{used to get window manager name, so we can handle different wm's behaviour
eg. kde vs. gnome}
@ -4382,8 +4441,10 @@ begin
if g_object_get_data(PGObject(Window),'lclhintwindow') <> nil then
begin
if gdk_window_is_visible(PGDKWindow(List^.Data)) then
begin
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;

View File

@ -180,9 +180,40 @@ begin
end;
GDK_WINDOW_STATE:
begin
if (GDK_WINDOW_STATE_WITHDRAWN and event^.window_state.changed_mask) = 1 then
exit;
{$IFDEF HASX}
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
begin
if (WInfo^.FormWindowState.new_window_state <> event^.window_state.new_window_state)