From b141121ef6cac2e07257c9d0e73db4c25807bf0c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 17 Mar 2013 12:06:26 -0400 Subject: [PATCH] window: Add support for enabling client decorations on non-Wayland Client side decorations can be enabled on non-Wayland platforms by setting the GTK_CSD="1" environment variable. We must ensure we have a GdkVisual that has an alpha channel since the decorations rely on transparency. If we cannot get a visual with an alpha channel then we do not enable client side decorations. --- gtk/gtkwindow.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 45d8a36d92..bd09f8b286 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -4855,16 +4855,26 @@ create_decoration (GtkWidget *widget) return; #ifdef GDK_WINDOWING_WAYLAND - if (!GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget))) - return; -#else - return; + if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget))) + priv->client_decorated = TRUE; #endif - if (!priv->decorated) - return; + if (!priv->client_decorated && + g_strcmp0 (g_getenv ("GTK_CSD"),"1") == 0) + { + GdkVisual *visual; - priv->client_decorated = TRUE; + /* 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); + priv->client_decorated = TRUE; + } + } + + if (!priv->client_decorated) + return; priv->title_box = gtk_header_bar_new (); g_object_set (priv->title_box,