[gtk+] window: Split the border into inner and outer



commit 70ccfb0efc7b58d3ab3804408f61c390e07cbbcc
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Mar 16 21:37:51 2013 -0400

    window: Split the border into inner and outer
    
    For now, nothing changes, we're using the sum of inner and
    outer border everywhere.
    
    In the future, we will make the inner border the visible
    window frame, and the outer border the shadow/resize border.

 gtk/gtkwindow.c |   83 +++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 57 insertions(+), 26 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 3a9028d..da8ade3 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -5921,14 +5921,21 @@ set_grip_position (GtkWindow *window)
 static void
 get_decoration_borders (GtkWidget *widget,
                         GtkBorder *title_border,
-                        GtkBorder *window_border)
+                        GtkBorder *window_border,
+                        GtkBorder *outer_border)
 {
   GtkStyleContext *context;
   GtkStateFlags state;
   GdkWindow *window;
+  gboolean maximized = FALSE;
+  const GtkBorder empty = { 0 };
+  GtkBorder outer;
 
   context = gtk_widget_get_style_context (widget);
   state = gtk_style_context_get_state (context);
+  window = gtk_widget_get_window (widget);
+  if (window != NULL)
+    maximized = gdk_window_get_state (window) & GDK_WINDOW_STATE_MAXIMIZED;
 
   if (title_border != NULL)
     {
@@ -5940,12 +5947,10 @@ get_decoration_borders (GtkWidget *widget,
 
   if (window_border != NULL)
     {
-      window = gtk_widget_get_window (widget);
-      if (window != NULL && (gdk_window_get_state (window) & GDK_WINDOW_STATE_MAXIMIZED) != 0)
+      if (maximized)
         {
-           GtkBorder empty = { 0 };
-           *window_border = empty;
-         }
+          *window_border = empty;
+        }
       else
         {
           gtk_style_context_save (context);
@@ -5954,6 +5959,33 @@ get_decoration_borders (GtkWidget *widget,
           gtk_style_context_restore (context);
         }
     }
+
+  if (window_border != NULL || outer_border != NULL)
+    {
+      if (maximized)
+        {
+          outer = empty;
+        }
+      else
+        {
+          gtk_style_context_save (context);
+          gtk_style_context_add_class (context, "window-outer-border");
+          gtk_style_context_get_border (context, state, &outer);
+          gtk_style_context_restore (context);
+        }
+
+      if (outer_border != NULL)
+        {
+          *outer_border = outer;
+        }
+      else
+        {
+          window_border->left += outer.left;
+          window_border->right += outer.right;
+          window_border->top += outer.top;
+          window_border->bottom += outer.bottom;
+        }
+    }
 }
 
 /* _gtk_window_set_allocation:
@@ -5994,9 +6026,9 @@ _gtk_window_set_allocation (GtkWindow           *window,
   gtk_widget_set_allocation (widget, allocation);
 
   if (priv->title_box != NULL)
-    get_decoration_borders (widget, &title_border, &window_border);
+    get_decoration_borders (widget, &title_border, &window_border, NULL);
   else
-    get_decoration_borders (widget, NULL, &window_border);
+    get_decoration_borders (widget, NULL, &window_border, NULL);
 
   border_width = gtk_container_get_border_width (GTK_CONTAINER (window));
 
@@ -6038,10 +6070,8 @@ _gtk_window_set_allocation (GtkWindow           *window,
                             title_height +
                             title_border.top +
                             title_border.bottom;
-      child_allocation.width -= (window_border.left +
-                                 window_border.right);
-      child_allocation.height -= (child_allocation.y +
-                                  window_border.bottom);
+      child_allocation.width -= window_border.left + window_border.right;
+      child_allocation.height -= child_allocation.y + window_border.bottom;
     }
 
   if (gtk_widget_get_realized (widget))
@@ -6435,7 +6465,7 @@ gtk_window_get_resize_grip_area (GtkWindow    *window,
     return FALSE;
 
   if (priv->client_decorated)
-    get_decoration_borders (widget, NULL, &window_border);
+    get_decoration_borders (widget, NULL, &window_border, NULL);
 
   gtk_widget_get_allocation (widget, &allocation);
 
@@ -6608,11 +6638,12 @@ get_region_type (GtkWindow *window, gint x, gint y)
   GtkWidget *widget = GTK_WIDGET (window);
   gint title_height = 0;
   gint resize_handle = 0;
-  GtkBorder window_border;
+  GtkBorder window_border = { 0 };
 
   if (priv->title_box)
     title_height = gtk_widget_get_allocated_height (priv->title_box);
-  get_decoration_borders (widget, NULL, &window_border);
+
+  get_decoration_borders (widget, NULL, &window_border, NULL);
   gtk_widget_style_get (widget,
                         "decoration-resize-handle", &resize_handle,
                         NULL);
@@ -6673,7 +6704,7 @@ get_active_region_type (GtkWindow *window, gint x, gint y)
   GtkBorder window_border;
 
   region = get_region_type (window, x, y);
-  get_decoration_borders (widget, NULL, &window_border);
+  get_decoration_borders (widget, NULL, &window_border, NULL);
 
   state = gdk_window_get_state (gtk_widget_get_window (widget));
   if (!priv->resizable || (state & GDK_WINDOW_STATE_MAXIMIZED))
@@ -7357,11 +7388,11 @@ gtk_window_get_preferred_width (GtkWidget *widget,
         {
           gtk_widget_get_preferred_width (priv->title_box,
                                           &title_min, &title_nat);
-          get_decoration_borders (widget, &title_border, &window_border);
+          get_decoration_borders (widget, &title_border, &window_border, NULL);
         }
       else
         {
-          get_decoration_borders (widget, NULL, &window_border);
+          get_decoration_borders (widget, NULL, &window_border, NULL);
         }
 
       title_min += border_width * 2 +
@@ -7416,11 +7447,11 @@ gtk_window_get_preferred_width_for_height (GtkWidget *widget,
           gtk_widget_get_preferred_width_for_height (priv->title_box,
                                                      height,
                                                      &title_min, &title_nat);
-          get_decoration_borders (widget, &title_border, &window_border);
+          get_decoration_borders (widget, &title_border, &window_border, NULL);
         }
       else
         {
-          get_decoration_borders (widget, NULL, &window_border);
+          get_decoration_borders (widget, NULL, &window_border, NULL);
         }
 
       title_min += border_width * 2 +
@@ -7478,11 +7509,11 @@ gtk_window_get_preferred_height (GtkWidget *widget,
           gtk_widget_get_preferred_height (priv->title_box,
                                            &title_min,
                                            &title_height);
-          get_decoration_borders (widget, &title_border, &window_border);
+          get_decoration_borders (widget, &title_border, &window_border, NULL);
         }
       else
         {
-          get_decoration_borders (widget, NULL, &window_border);
+          get_decoration_borders (widget, NULL, &window_border, NULL);
         }
 
       *minimum_size = title_min +
@@ -7539,11 +7570,11 @@ gtk_window_get_preferred_height_for_width (GtkWidget *widget,
                                                      width,
                                                      &title_min,
                                                      &title_height);
-          get_decoration_borders (widget, &title_border, &window_border);
+          get_decoration_borders (widget, &title_border, &window_border, NULL);
         }
       else
         {
-          get_decoration_borders (widget, NULL, &window_border);
+          get_decoration_borders (widget, NULL, &window_border, NULL);
         }
 
       *minimum_size = title_min +
@@ -8812,9 +8843,9 @@ gtk_window_draw (GtkWidget *widget,
   context = gtk_widget_get_style_context (widget);
 
   if (priv->title_box != NULL)
-    get_decoration_borders (widget, &title_border, &window_border);
+    get_decoration_borders (widget, &title_border, &window_border, NULL);
   else
-    get_decoration_borders (widget, NULL, &window_border);
+    get_decoration_borders (widget, NULL, &window_border, NULL);
 
   if (!gtk_widget_get_app_paintable (widget) &&
       gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))


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