[gtk+/wip/csd-for-merge: 7/7] window: Add support for enabling client decorations on non-Wayland



commit 55039f0f87336eb92665d7bb07c79c427dfb4ee4
Author: Rob Bradford <rob linux intel com>
Date:   Fri Apr 13 15:06:55 2012 +0100

    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 |   35 +++++++++++++++++++++++++----------
 1 files changed, 25 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 972647a..bc12c6c 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -3386,7 +3386,7 @@ gtk_window_set_decorated (GtkWindow *window,
   gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
   if (gdk_window)
     {
-      if (priv->decorated)
+      if (priv->decorated && !priv->client_decorated)
         gdk_window_set_decorations (gdk_window,
                                     GDK_DECOR_ALL);
       else
@@ -4843,21 +4843,36 @@ create_decoration (GtkWidget *widget)
   GtkStyleContext *context;
   const gchar *title;
 
-  /* Decorations already created */
+  /* Client decorations already created */
   if (priv->client_decorated)
     return;
 
-#ifdef GDK_WINDOWING_WAYLAND
-  if (!GDK_IS_WAYLAND_DISPLAY_MANAGER (gdk_display_manager_get ()))
+  /* No decorations at all */
+  if (!priv->decorated)
     return;
-#else
-  return;
+
+#ifdef GDK_WINDOWING_WAYLAND
+  if (GDK_IS_WAYLAND_DISPLAY_MANAGER (gdk_display_manager_get ()))
+    priv->client_decorated = TRUE;
 #endif
 
-  if (!priv->decorated)
-    return;
+  if (!priv->client_decorated &&
+      g_getenv ("GTK_CSD") &&
+      g_str_equal (g_getenv ("GTK_CSD"), "1"))
+    {
+      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;
 
   if (priv->type != GTK_WINDOW_POPUP)
     {
@@ -5400,7 +5415,7 @@ gtk_window_realize (GtkWidget *widget)
   if (priv->wm_role)
     gdk_window_set_role (gdk_window, priv->wm_role);
   
-  if (!priv->decorated)
+  if (!priv->decorated || priv->client_decorated)
     gdk_window_set_decorations (gdk_window, 0);
   
   if (!priv->deletable)


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