GtkStatusIcon/w32: Also set the tooltip on taskbar_created_msg

When explorer.exe creates a taskbar it broadcasts a "TaskbarCreated"
message to all toplevels. Applications, By handling that message,
are able to re-create the icons to be displayed in the taskbar.

Explorer creates a new taskbar in two circumstances:
A) when explorer starts up
B) when the DPI of the monitor changes

A) happens either when explorer.exe is started for the first time at
   logon, or when it is restarted after being terminated.
B) happens when the user changes the DPI preference of the active
   monitor where the desktop is displayed, or if the desktop is moved
   to a monitor with different DPI.

Currently, this message is handled in Gtk and icons are re-created.
However the current implementation has a small issue in that it
doesn't set the tooltip on the new icons, so tooltips get lost
after re-creation.

The tooltip is important because Windows uses it for identification
of taskbar icons and for storing and applying user preferences. For
an explanation of that see:
https://bugzilla.gnome.org/show_bug.cgi?id=609622

With this commit the tooltip is correctly applied to new taskbar
icons when handling taskbar_created_msg.

See Merge Request !1003
This commit is contained in:
Luca Bacci
2019-08-02 16:58:25 +00:00
committed by Matthias Clasen
parent 25dd5d9eb0
commit 6dc2f6f026

View File

@ -735,25 +735,25 @@ wndproc (HWND hwnd,
GtkStatusIcon *status_icon = GTK_STATUS_ICON (rover->data);
GtkStatusIconPrivate *priv = status_icon->priv;
/* taskbar_created_msg is also fired when DPI changes. Try to delete existing icons if possible. */
if (!Shell_NotifyIconW (NIM_DELETE, &priv->nid))
{
g_warning (G_STRLOC ": Shell_NotifyIcon(NIM_DELETE) on existing icon failed");
}
if (priv->visible)
{
/* taskbar_created_msg is also fired when DPI changes. Try to delete existing icons if possible. */
if (priv->nid.hWnd)
if (!Shell_NotifyIconW (NIM_DELETE, &priv->nid))
g_warning (G_STRLOC ": Shell_NotifyIcon(NIM_DELETE) on existing icon failed");
priv->nid.hWnd = hwnd;
priv->nid.uID = status_icon_id++;
priv->nid.uCallbackMessage = WM_GTK_TRAY_NOTIFICATION;
priv->nid.uFlags = NIF_MESSAGE;
priv->nid.hWnd = hwnd;
priv->nid.uFlags &= ~NIF_ICON;
if (!Shell_NotifyIconW (NIM_ADD, &priv->nid))
{
g_warning (G_STRLOC ": Shell_NotifyIcon(NIM_ADD) failed");
priv->nid.hWnd = NULL;
continue;
}
if (!Shell_NotifyIconW (NIM_ADD, &priv->nid))
{
g_warning (G_STRLOC ": Shell_NotifyIcon(NIM_ADD) failed");
priv->nid.hWnd = NULL;
continue;
}
gtk_status_icon_update_image (status_icon);
gtk_status_icon_update_image (status_icon);
}
}
return 0;
}