Kirill K. Smirnov : systray: Add support for NIS_HIDDEN flag.
Alexandre Julliard
julliard at winehq.org
Wed Feb 6 07:27:51 CST 2008
Module: wine
Branch: master
Commit: 43083236c428e968a7fa1c54470a67cd89674034
URL: http://source.winehq.org/git/wine.git/?a=commit;h=43083236c428e968a7fa1c54470a67cd89674034
Author: Kirill K. Smirnov <lich at math.spbu.ru>
Date: Tue Feb 5 14:19:40 2008 +0000
systray: Add support for NIS_HIDDEN flag.
---
programs/explorer/systray.c | 135 ++++++++++++++++++++++++++-----------------
1 files changed, 82 insertions(+), 53 deletions(-)
diff --git a/programs/explorer/systray.c b/programs/explorer/systray.c
index 75872b0..9ddfd4d 100644
--- a/programs/explorer/systray.c
+++ b/programs/explorer/systray.c
@@ -64,6 +64,7 @@ struct icon
HWND tooltip; /* Icon tooltip */
UINT id; /* the unique id given by the app */
UINT callback_message;
+ BOOL hidden; /* icon display state */
};
static struct tray tray;
@@ -182,6 +183,69 @@ static void set_tooltip(struct icon *icon, WCHAR *szTip, BOOL modify)
SendMessageW(icon->tooltip, TTM_ADDTOOLW, 0, (LPARAM)&ti);
}
+static BOOL display_icon(struct icon *icon, BOOL hide)
+{
+ HMODULE x11drv = GetModuleHandleA("winex11.drv");
+ RECT rect;
+ static const WCHAR adaptor_windowname[] = /* Wine System Tray Adaptor */ {'W','i','n','e',' ','S','y','s','t','e','m',' ','T','r','a','y',' ','A','d','a','p','t','o','r',0};
+ static BOOL tooltps_initialized = FALSE;
+
+ WINE_TRACE("id=0x%x, hwnd=%p, hide=%d\n", icon->id, icon->owner, hide);
+
+ if (icon->hidden == hide || (!icon->hidden) == (!hide)) return TRUE;
+ icon->hidden = hide;
+ if (hide)
+ {
+ DestroyWindow(icon->window);
+ DestroyWindow(icon->tooltip);
+ return TRUE;
+ }
+
+ rect.left = 0;
+ rect.top = 0;
+ rect.right = GetSystemMetrics(SM_CXSMICON) + ICON_BORDER;
+ rect.bottom = GetSystemMetrics(SM_CYSMICON) + ICON_BORDER;
+ AdjustWindowRect(&rect, WS_CLIPSIBLINGS | WS_CAPTION, FALSE);
+
+ /* create the adaptor window */
+ icon->window = CreateWindowEx(0, adaptor_classname,
+ adaptor_windowname,
+ WS_CLIPSIBLINGS | WS_CAPTION,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ rect.right - rect.left,
+ rect.bottom - rect.top,
+ NULL, NULL, NULL, icon);
+ if (x11drv)
+ {
+ void (*make_systray_window)(HWND) = (void *)GetProcAddress(x11drv, "wine_make_systray_window");
+ if (make_systray_window) make_systray_window(icon->window);
+ }
+
+ if (!hide_systray)
+ ShowWindow(icon->window, SW_SHOWNA);
+
+ /* create icon tooltip */
+
+ /* Register tooltip classes if this is the first icon */
+ if (!tooltps_initialized)
+ {
+ INITCOMMONCONTROLSEX init_tooltip;
+
+ init_tooltip.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ init_tooltip.dwICC = ICC_TAB_CLASSES;
+
+ InitCommonControlsEx(&init_tooltip);
+ tooltps_initialized = TRUE;
+ }
+
+ icon->tooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,
+ WS_POPUP | TTS_ALWAYSTIP,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ icon->window, NULL, NULL, NULL);
+ return TRUE;
+}
+
static BOOL modify_icon(NOTIFYICONDATAW *nid, BOOL modify_tooltip)
{
struct icon *icon;
@@ -196,12 +260,23 @@ static BOOL modify_icon(NOTIFYICONDATAW *nid, BOOL modify_tooltip)
return FALSE;
}
+ if (nid->uFlags & NIF_STATE)
+ {
+ if (nid->dwStateMask & NIS_HIDDEN)
+ display_icon(icon, !!(nid->dwState & NIS_HIDDEN));
+ else
+ display_icon(icon, FALSE);
+ }
+ else
+ display_icon(icon, FALSE);
+
if (nid->uFlags & NIF_ICON)
{
if (icon->image) DestroyIcon(icon->image);
icon->image = CopyIcon(nid->hIcon);
- RedrawWindow(icon->window, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
+ if (!icon->hidden)
+ RedrawWindow(icon->window, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
}
if (nid->uFlags & NIF_MESSAGE)
@@ -221,11 +296,7 @@ static BOOL modify_icon(NOTIFYICONDATAW *nid, BOOL modify_tooltip)
static BOOL add_icon(NOTIFYICONDATAW *nid)
{
- HMODULE x11drv = GetModuleHandleA( "winex11.drv" );
- RECT rect;
struct icon *icon;
- static const WCHAR adaptor_windowname[] = /* Wine System Tray Adaptor */ {'W','i','n','e',' ','S','y','s','t','e','m',' ','T','r','a','y',' ','A','d','a','p','t','o','r',0};
- static BOOL tooltps_initialized = FALSE;
WINE_TRACE("id=0x%x, hwnd=%p\n", nid->uID, nid->hWnd);
@@ -241,52 +312,11 @@ static BOOL add_icon(NOTIFYICONDATAW *nid)
return FALSE;
}
- icon->id = nid->uID;
- icon->owner = nid->hWnd;
- icon->image = NULL;
-
- rect.left = 0;
- rect.top = 0;
- rect.right = GetSystemMetrics(SM_CXSMICON) + ICON_BORDER;
- rect.bottom = GetSystemMetrics(SM_CYSMICON) + ICON_BORDER;
- AdjustWindowRect(&rect, WS_CLIPSIBLINGS | WS_CAPTION, FALSE);
-
- /* create the adaptor window */
- icon->window = CreateWindowEx(0, adaptor_classname,
- adaptor_windowname,
- WS_CLIPSIBLINGS | WS_CAPTION,
- CW_USEDEFAULT, CW_USEDEFAULT,
- rect.right - rect.left,
- rect.bottom - rect.top,
- NULL, NULL, NULL, icon);
- if (x11drv)
- {
- void (*make_systray_window)(HWND) = (void *)GetProcAddress( x11drv, "wine_make_systray_window" );
- if (make_systray_window) make_systray_window( icon->window );
- }
-
- if (!hide_systray)
- ShowWindow(icon->window, SW_SHOWNA);
-
- /* create icon tooltip */
-
- /* Register tooltip classes if this is the first icon */
- if (!tooltps_initialized)
- {
- INITCOMMONCONTROLSEX init_tooltip;
-
- init_tooltip.dwSize = sizeof(INITCOMMONCONTROLSEX);
- init_tooltip.dwICC = ICC_TAB_CLASSES;
-
- InitCommonControlsEx(&init_tooltip);
- tooltps_initialized = TRUE;
- }
-
- icon->tooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,
- WS_POPUP | TTS_ALWAYSTIP,
- CW_USEDEFAULT, CW_USEDEFAULT,
- CW_USEDEFAULT, CW_USEDEFAULT,
- icon->window, NULL, NULL, NULL);
+ icon->id = nid->uID;
+ icon->owner = nid->hWnd;
+ icon->image = NULL;
+ icon->window = NULL;
+ icon->hidden = TRUE;
list_add_tail(&tray.icons, &icon->entry);
@@ -305,8 +335,7 @@ static BOOL delete_icon(const NOTIFYICONDATAW *nid)
return FALSE;
}
- DestroyWindow(icon->tooltip);
- DestroyWindow(icon->window);
+ display_icon(icon, TRUE);
return TRUE;
}
More information about the wine-cvs
mailing list