[PATCH] explorer: Hide the systray window better.

Lei Zhang thestig at google.com
Wed Dec 3 17:10:19 CST 2008


Hi,

Several applications (accidentally?) unhide the systray window,
leaving users with a window they cannot close, as reported in bug
16158. This patch does a better job of hiding the window. Also, in
virtual desktop mode, users no longer see an empty systray on startup.
-------------- next part --------------
From 537d5ac217a61bdefa4020cc85ae02f390f4f57e Mon Sep 17 00:00:00 2001
From: Lei Zhang <thestig at google.com>
Date: Wed, 3 Dec 2008 15:07:26 -0800
Subject: [PATCH] explorer: Hide the systray window better.

---
 programs/explorer/systray.c |   31 +++++++++++++++++++------------
 1 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/programs/explorer/systray.c b/programs/explorer/systray.c
index 37f3551..3c08515 100644
--- a/programs/explorer/systray.c
+++ b/programs/explorer/systray.c
@@ -180,6 +180,21 @@ static void invalidate_icons( unsigned int start, unsigned int end )
     InvalidateRect( tray_window, &rect, TRUE );
 }
 
+static void do_show_systray(void)
+{
+    ShowWindow( tray_window, SW_SHOWNA );
+    SetWindowPos( tray_window, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
+}
+
+static void do_hide_systray(void)
+{
+    ShowWindow( tray_window, SW_HIDE );
+    SetWindowPos( tray_window, 0,
+                  GetSystemMetrics(SM_XVIRTUALSCREEN) + GetSystemMetrics(SM_CXVIRTUALSCREEN),
+                  GetSystemMetrics(SM_YVIRTUALSCREEN) + GetSystemMetrics(SM_CYVIRTUALSCREEN),
+                  0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
+}
+
 /* make an icon visible */
 static BOOL show_icon(struct icon *icon)
 {
@@ -210,7 +225,7 @@ static BOOL show_icon(struct icon *icon)
     }
     else if (nb_displayed == 1)
     {
-        if (!hide_systray) ShowWindow( tray_window, SW_SHOWNA );
+        if (!hide_systray) do_show_systray();
     }
 
     create_tooltip(icon);
@@ -244,7 +259,7 @@ static BOOL hide_icon(struct icon *icon)
     }
     else if (!nb_displayed)
     {
-        ShowWindow( tray_window, SW_HIDE );
+        do_hide_systray();
     }
 
     update_tooltip_position( icon );
@@ -430,14 +445,6 @@ static BOOL handle_incoming(HWND hwndSource, COPYDATASTRUCT *cds)
     return ret;
 }
 
-static void do_hide_systray(void)
-{
-    SetWindowPos( tray_window, 0,
-                  GetSystemMetrics(SM_XVIRTUALSCREEN) + GetSystemMetrics(SM_CXVIRTUALSCREEN),
-                  GetSystemMetrics(SM_YVIRTUALSCREEN) + GetSystemMetrics(SM_CYVIRTUALSCREEN),
-                  0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
-}
-
 static LRESULT WINAPI tray_wndproc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 {
     switch (msg)
@@ -508,7 +515,7 @@ static LRESULT WINAPI tray_wndproc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
 
     case WM_CLOSE:
         /* don't destroy the tray window, just hide it */
-        ShowWindow( hwnd, SW_HIDE );
+        do_hide_systray();
         return 0;
 
     default:
@@ -581,7 +588,7 @@ void initialize_systray(void)
         return;
     }
 
-    if (hide_systray) do_hide_systray();
+    do_hide_systray();
 
     SetTimer( tray_window, 1, 2000, NULL );
 }
-- 
1.5.4.5


More information about the wine-patches mailing list