diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2023-02-16 14:16:09 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2023-02-16 15:38:32 +0100 |
commit | 10b426a3e4d9666751071d50b6d3027c7f5a6a76 (patch) | |
tree | 5150a31f8839cb60f2eaf374394a9b6ab7031e13 | |
parent | bfcce6447a052531a1f5f454cc5e2708133467aa (diff) | |
download | network-manager-applet-lr/x11-app-indicator.tar.gz |
applet: use appindicator if we can outside of X11lr/x11-app-indicator
The XEmbed-based GtkStatusIcon will silently do nothing in many
environments nowadays. In particular, it can't work outside X11.
Let's prefer X11 only if we got no app indicator support. Otherwise, use
the best backend possible and then turn on indicator support if it was
not X11.
Based on work by Aleksei Bavshin <alebastr89@gmail.com>.
-rw-r--r-- | src/applet.c | 9 | ||||
-rw-r--r-- | src/main.c | 8 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/applet.c b/src/applet.c index 5c968ffe..8ef6833a 100644 --- a/src/applet.c +++ b/src/applet.c @@ -3392,6 +3392,15 @@ static void nma_init (NMApplet *applet) { applet->icon_size = 16; +#ifdef WITH_APPINDICATOR +#ifdef GDK_WINDOWING_X11 + if (!GDK_IS_X11_DISPLAY (gdk_display_get_default ())) + with_appindicator = TRUE; +#else + with_appindicator = TRUE; +#endif +#endif + g_signal_connect (applet, "startup", G_CALLBACK (applet_startup), NULL); g_signal_connect (applet, "activate", G_CALLBACK (applet_activate), NULL); } @@ -58,8 +58,12 @@ int main (int argc, char *argv[]) bindtextdomain (GETTEXT_PACKAGE, NMALOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - if (!with_appindicator) - gdk_set_allowed_backends ("x11,*"); +#ifndef WITH_APPINDICATOR + /* If we got no app indicator, out only chance of doing anything + * useful is the XEmbed-based GtkStatusIcon, which only works on + * X11. Prefer it. */ + gdk_set_allowed_backends ("x11,*"); +#endif gtk_init (&argc, &argv); textdomain (GETTEXT_PACKAGE); |