Commit 43083236 authored by Kirill K. Smirnov's avatar Kirill K. Smirnov Committed by Alexandre Julliard

systray: Add support for NIS_HIDDEN flag.

parent b391b8af
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment