From a2eafe2f573e03dffb9036517a9867f7c1b48997 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 21 Aug 2013 15:08:08 -0400 Subject: [PATCH] gtkwindow: Disable CSD if we aren't running under a supported WM Also, split the checks for CSD out into a separate function. https://bugzilla.gnome.org/show_bug.cgi?id=706529 --- gtk/gtkwindow.c | 57 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 2e4ed1269f..e4becaa806 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -3472,6 +3472,50 @@ unset_titlebar (GtkWindow *window) } } +static gboolean +gdk_window_supports_csd (GtkWindow *window) +{ + GtkWidget *widget = GTK_WIDGET (window); + +#ifdef GDK_WINDOWING_X11 + if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget))) + { + GdkScreen *screen; + GdkVisual *visual; + + screen = gtk_widget_get_screen (widget); + + if (!gdk_screen_is_composited (screen)) + return FALSE; + + if (!gdk_x11_screen_supports_net_wm_hint (screen, gdk_atom_intern_static_string ("_GTK_FRAME_EXTENTS"))) + return FALSE; + + /* We need a visual with alpha */ + visual = gdk_screen_get_rgba_visual (screen); + if (!visual) + return FALSE; + } +#endif + + return TRUE; +} + +static void +gdk_window_enable_csd (GtkWindow *window) +{ + GtkWindowPrivate *priv = window->priv; + GtkWidget *widget = GTK_WIDGET (window); + GdkVisual *visual; + + /* We need a visual with alpha */ + visual = gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget)); + g_assert (visual != NULL); + gtk_widget_set_visual (widget, visual); + + priv->client_decorated = TRUE; +} + /** * gtk_window_set_titlebar: * @window: a #GtkWindow @@ -5266,17 +5310,10 @@ create_decoration (GtkWidget *widget) GtkWindow *window = GTK_WINDOW (widget); GtkWindowPrivate *priv = window->priv; -#ifdef GDK_WINDOWING_X11 - if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget))) - { - GdkVisual *visual; + if (!gdk_window_supports_csd (window)) + return; - /* We need a visual with alpha */ - visual = gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget)); - if (visual) - gtk_widget_set_visual (widget, visual); - } -#endif + gdk_window_enable_csd (window); if (priv->title_box == NULL) {