diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index edea0fb3..4e2b01c3 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -124,6 +124,25 @@ create_msg_dialog (gchar *title, gchar *message) static char *win32_argv0_dir; +static void +win32_set_appusermodelid (void) +{ + HMODULE shell32; + HRESULT (WINAPI *set_appid) (PCWSTR); + + shell32 = GetModuleHandleW (L"shell32.dll"); + if (!shell32) + shell32 = LoadLibraryW (L"shell32.dll"); + if (!shell32) + return; + + set_appid = (HRESULT (WINAPI *) (PCWSTR)) GetProcAddress (shell32, "SetCurrentProcessExplicitAppUserModelID"); + if (!set_appid) + return; + + set_appid (L"ZoiteChat.Desktop.Notify"); +} + static void win32_set_gsettings_schema_dir (void) { @@ -422,6 +441,7 @@ fe_args (int argc, char *argv[]) #ifdef WIN32 win32_set_gsettings_schema_dir (); + win32_set_appusermodelid (); win32_configure_pixbuf_loaders (); /* this is mainly for irc:// URL handling. When windows calls us from */ diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index 3b319fbe..9dd386db 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -902,7 +902,12 @@ mg_windowstate_cb (GtkWindow *wid, GdkEventWindowState *event, gpointer userdata if ((event->changed_mask & GDK_WINDOW_STATE_ICONIFIED) && (event->new_window_state & GDK_WINDOW_STATE_ICONIFIED) && prefs.hex_gui_tray_minimize && prefs.hex_gui_tray && - gtkutil_tray_icon_supported (wid)) + gtkutil_tray_icon_supported (wid) +#ifndef WIN32 + ) +#else + && !gtk_window_is_active (wid)) +#endif { tray_toggle_visibility (TRUE); } @@ -947,7 +952,8 @@ mg_windowstate_cb (GtkWindow *wid, GdkEventWindowState *event, gpointer userdata if (sess && sess->gui && GTK_IS_WIDGET (sess->gui->window)) gtk_widget_queue_draw (sess->gui->window); - menu_set_fullscreen (current_sess->gui, prefs.hex_gui_win_fullscreen); + if (current_sess && current_sess->gui) + menu_set_fullscreen (current_sess->gui, prefs.hex_gui_win_fullscreen); #ifdef G_OS_WIN32 mg_win32_allow_autohide_taskbar (wid, event); @@ -4727,7 +4733,14 @@ mg_win32_filter (GdkXEvent *xevent, GdkEvent *event, gpointer data) { if (strcmp (command, "__WIN32_TASKBAR_TOGGLE__") == 0) { - if (gtk_widget_get_visible (current_sess->gui->window)) + GdkWindowState state = 0; + GdkWindow *gdk_window = gtk_widget_get_window (current_sess->gui->window); + + if (gdk_window) + state = gdk_window_get_state (gdk_window); + + if (gtk_widget_get_visible (current_sess->gui->window) + && (state & GDK_WINDOW_STATE_ICONIFIED) == 0) fe_ctrl_gui (current_sess, FE_GUI_ICONIFY, 0); else fe_ctrl_gui (current_sess, FE_GUI_SHOW, 0); diff --git a/src/fe-gtk/plugin-tray.c b/src/fe-gtk/plugin-tray.c index 7532f1ed..337f8f31 100644 --- a/src/fe-gtk/plugin-tray.c +++ b/src/fe-gtk/plugin-tray.c @@ -920,7 +920,10 @@ tray_menu_notify_cb (GObject *tray, GParamSpec *pspec, gpointer user_data) { if (!tray_backend_is_embedded ()) { - tray_restore_timer = g_timeout_add(500, (GSourceFunc)tray_menu_try_restore, NULL); + if (!tray_restore_timer) + { + tray_restore_timer = g_timeout_add (500, (GSourceFunc) tray_menu_try_restore, NULL); + } } else { @@ -936,9 +939,10 @@ tray_menu_notify_cb (GObject *tray, GParamSpec *pspec, gpointer user_data) static gboolean tray_menu_try_restore (void) { - tray_cleanup(); - tray_init(); - return TRUE; + tray_restore_timer = 0; + tray_cleanup (); + tray_init (); + return G_SOURCE_REMOVE; } static void