diff options
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) |