Merge pull request #139 from ZoiteChat/tray-icon-fix

Fix Wayland tray init + DBus assert, add source-build icon fallback
This commit is contained in:
deepend-tildeclub
2026-03-21 00:00:02 -06:00
committed by GitHub
3 changed files with 15 additions and 5 deletions

View File

@@ -1120,7 +1120,9 @@ gtkutil_treeview_get_selected (GtkTreeView *view, GtkTreeIter *iter_ret, ...)
gboolean gboolean
gtkutil_tray_icon_supported (GtkWindow *window) gtkutil_tray_icon_supported (GtkWindow *window)
{ {
#ifdef GDK_WINDOWING_X11 #if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_APPINDICATOR)
return TRUE;
#elif defined(GDK_WINDOWING_X11)
GdkScreen *screen = gtk_window_get_screen (window); GdkScreen *screen = gtk_window_get_screen (window);
GdkDisplay *display = gdk_screen_get_display (screen); GdkDisplay *display = gdk_screen_get_display (screen);
if (!GDK_IS_X11_DISPLAY (display)) if (!GDK_IS_X11_DISPLAY (display))

View File

@@ -65,8 +65,8 @@ if host_machine.system() != 'windows'
if appindicator_dep.found() if appindicator_dep.found()
zoitechat_gtk_deps += appindicator_dep zoitechat_gtk_deps += appindicator_dep
zoitechat_gtk_cflags += '-DHAVE_APPINDICATOR' zoitechat_gtk_cflags += '-DHAVE_APPINDICATOR'
elif appindicator_opt.enabled() elif appindicator_opt.enabled() or (appindicator_opt.auto() and host_machine.system() == 'linux')
error('appindicator=enabled, but neither ayatana-appindicator3-0.1 nor appindicator3-0.1 was found') error('tray support requires ayatana-appindicator3-0.1 or appindicator3-0.1 on Linux (use -Dappindicator=disabled to override)')
endif endif
endif endif
endif endif

View File

@@ -364,8 +364,8 @@ tray_app_indicator_set_icon (TrayIcon icon)
if (!icon_name) if (!icon_name)
return; return;
app_indicator_set_icon_full (tray_indicator, icon_name, _(DISPLAY_NAME));
app_indicator_set_status (tray_indicator, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_status (tray_indicator, APP_INDICATOR_STATUS_ACTIVE);
app_indicator_set_icon_full (tray_indicator, icon_name, _(DISPLAY_NAME));
g_free (icon_name_alloc); g_free (icon_name_alloc);
} }
@@ -431,7 +431,6 @@ tray_app_indicator_init (void)
g_signal_connect (G_OBJECT (tray_menu), "map", g_signal_connect (G_OBJECT (tray_menu), "map",
G_CALLBACK (tray_menu_show_cb), NULL); G_CALLBACK (tray_menu_show_cb), NULL);
app_indicator_set_menu (tray_indicator, GTK_MENU (tray_menu)); app_indicator_set_menu (tray_indicator, GTK_MENU (tray_menu));
app_indicator_set_status (tray_indicator, APP_INDICATOR_STATUS_ACTIVE);
klass = G_OBJECT_GET_CLASS (tray_indicator); klass = G_OBJECT_GET_CLASS (tray_indicator);
if (klass && g_object_class_find_property (klass, "connected")) if (klass && g_object_class_find_property (klass, "connected"))
@@ -1390,9 +1389,14 @@ tray_apply_setup (void)
} }
else else
{ {
#if HAVE_APPINDICATOR_BACKEND
if (prefs.hex_gui_tray)
tray_init ();
#else
GtkWindow *window = GTK_WINDOW(zoitechat_get_info (ph, "gtkwin_ptr")); GtkWindow *window = GTK_WINDOW(zoitechat_get_info (ph, "gtkwin_ptr"));
if (prefs.hex_gui_tray && gtkutil_tray_icon_supported (window)) if (prefs.hex_gui_tray && gtkutil_tray_icon_supported (window))
tray_init (); tray_init ();
#endif
} }
} }
@@ -1439,7 +1443,11 @@ tray_plugin_init (zoitechat_plugin *plugin_handle, char **plugin_name,
G_CALLBACK (tray_window_visibility_cb), NULL); G_CALLBACK (tray_window_visibility_cb), NULL);
} }
#if HAVE_APPINDICATOR_BACKEND
if (prefs.hex_gui_tray)
#else
if (prefs.hex_gui_tray && gtkutil_tray_icon_supported (window)) if (prefs.hex_gui_tray && gtkutil_tray_icon_supported (window))
#endif
tray_init (); tray_init ();
return 1; /* return 1 for success */ return 1; /* return 1 for success */