diff options
author | Patrick Griffis <tingping@tingping.se> | 2017-08-31 09:52:45 -0400 |
---|---|---|
committer | Patrick Griffis <tingping@tingping.se> | 2017-08-31 10:16:03 -0400 |
commit | d99cd18fb9e97c4ec264ad7a72bf7e2ba9a6dfa2 (patch) | |
tree | d2cb813ed55b738e354c1554052ac6556b4de2b2 /src/fe-gtk/gtkutil.c | |
parent | 281038e725e05e8373e11f8edcbcbfc746e1427d (diff) |
Improve detection of system tray support
Closes #2045
Diffstat (limited to 'src/fe-gtk/gtkutil.c')
-rw-r--r-- | src/fe-gtk/gtkutil.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/fe-gtk/gtkutil.c b/src/fe-gtk/gtkutil.c index 878f5c6e..674ad4fc 100644 --- a/src/fe-gtk/gtkutil.c +++ b/src/fe-gtk/gtkutil.c @@ -31,6 +31,10 @@ #include <pango/pangocairo.h> #endif +#ifdef GDK_WINDOWING_X11 +#include <gdk/gdkx.h> +#endif + #include "../common/hexchat.h" #include "../common/fe.h" #include "../common/util.h" @@ -735,6 +739,32 @@ gtkutil_treeview_get_selected (GtkTreeView *view, GtkTreeIter *iter_ret, ...) return has_selected; } +gboolean +gtkutil_tray_icon_supported (GtkWindow *window) +{ +#ifndef GDK_WINDOWING_X11 + return TRUE; +#else + GdkScreen *screen = gtk_window_get_screen (window); + GdkDisplay *display = gdk_screen_get_display (screen); + int screen_number = gdk_screen_get_number (screen); + Display *xdisplay = gdk_x11_display_get_xdisplay (display); + char *selection_name = g_strdup_printf ("_NET_SYSTEM_TRAY_S%d", screen_number); + Atom selection_atom = XInternAtom (xdisplay, selection_name, False); + Window tray_window = None; + + XGrabServer (xdisplay); + + tray_window = XGetSelectionOwner (xdisplay, selection_atom); + + XUngrabServer (xdisplay); + XFlush (xdisplay); + g_free (selection_name); + + return (tray_window != None); +#endif +} + #if defined (WIN32) || defined (__APPLE__) gboolean gtkutil_find_font (const char *fontname) |