Bug 609622 - disappearing statusicon

Windows 7 is managing status icon visibility across process lifetime,
which did not work with GTK+ create icons. Apparently the mechanism
does not require use of new API (like suggested by MSDN), but it is
enough to give a "unique" tooltip at creation time.
Formerly this initial tooltip was not set at all, later setting via
gtk_status_icon_set_tooltip_text() is not enough, but luckily
different follow-up tooltips don't disturb the intended behavior.
(cherry picked from commit ae0544c636)
(cherry picked from commit 8a9d458baf)
This commit is contained in:
Hans Breuer 2010-11-07 21:19:48 +01:00 committed by Tristan Van Berkom
parent 0b749700e6
commit 017f637a76

View File

@ -903,6 +903,17 @@ gtk_status_icon_init (GtkStatusIcon *status_icon)
priv->nid.uCallbackMessage = WM_GTK_TRAY_NOTIFICATION;
priv->nid.uFlags = NIF_MESSAGE;
/* To help win7 identify the icon create it with an application "unique" tip */
if (g_get_prgname ())
{
WCHAR *wcs = g_utf8_to_utf16 (g_get_prgname (), -1, NULL, NULL, NULL);
priv->nid.uFlags |= NIF_TIP;
wcsncpy (priv->nid.szTip, wcs, G_N_ELEMENTS (priv->nid.szTip) - 1);
priv->nid.szTip[G_N_ELEMENTS (priv->nid.szTip) - 1] = 0;
g_free (wcs);
}
if (!Shell_NotifyIconW (NIM_ADD, &priv->nid))
{
g_warning (G_STRLOC ": Shell_NotifyIcon(NIM_ADD) failed");