Fix AppIndicator tray init for Wayland/source builds

This commit is contained in:
2026-03-20 23:18:19 -06:00
parent 394de09cb1
commit 416b8449b9
2 changed files with 12 additions and 4 deletions

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 */