[gtk+] window: Add support for enabling client decorations on non-Wayland



commit b141121ef6cac2e07257c9d0e73db4c25807bf0c
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Mar 17 12:06:26 2013 -0400

    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 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 45d8a36..bd09f8b 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;
+
+      /* 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;
+        }
+    }
 
-  priv->client_decorated = TRUE;
+  if (!priv->client_decorated)
+    return;
 
   priv->title_box = gtk_header_bar_new ();
   g_object_set (priv->title_box,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]