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



commit e7e43e88d47a7c8af6ee14c4aa892f5ff54862b4
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 4598b28..2057048 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -3374,7 +3374,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
@@ -4815,21 +4815,36 @@ create_decoration (GtkWidget *widget)
   GtkStyleContext *context;
   const char *title = "GtkWindow";
 
-  /* 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)
     {
@@ -5366,7 +5381,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]