[gtk+] window: Render inner and outer border separately



commit a41f7e47412f31e5941bf0ff3608008e1efa791c
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Mar 10 13:46:59 2013 -0400

    window: Render inner and outer border separately
    
    This lets themes render a window frame in the inner border,
    and a shadow or nothing in the outer border.

 gtk/gtkwindow.c |   28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index da8ade3..dbf7d79 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -8838,14 +8838,15 @@ gtk_window_draw (GtkWidget *widget,
   gboolean ret = FALSE;
   GtkAllocation allocation;
   GtkBorder title_border = { 0 };
-  GtkBorder window_border = {};
+  GtkBorder inner_border = { 0 };
+  GtkBorder outer_border = { 0 };
 
   context = gtk_widget_get_style_context (widget);
 
   if (priv->title_box != NULL)
-    get_decoration_borders (widget, &title_border, &window_border, NULL);
+    get_decoration_borders (widget, &title_border, &inner_border, &outer_border);
   else
-    get_decoration_borders (widget, NULL, &window_border, NULL);
+    get_decoration_borders (widget, NULL, &inner_border, &outer_border);
 
   if (!gtk_widget_get_app_paintable (widget) &&
       gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
@@ -8859,17 +8860,24 @@ gtk_window_draw (GtkWidget *widget,
           !priv->fullscreen &&
           !(gdk_window_get_state (gtk_widget_get_window (widget)) & GDK_WINDOW_STATE_MAXIMIZED))
         {
-          gtk_style_context_add_class (context, "window-border");
           gtk_widget_get_allocation (widget, &allocation);
+          gtk_style_context_add_class (context, "window-border");
           gtk_render_background (context, cr,
-                                 window_border.left,
-                                 window_border.top,
+                                 inner_border.left + outer_border.left,
+                                 inner_border.top + outer_border.top,
                                  allocation.width -
-                                 (window_border.left +
-                                  window_border.right),
+                                 (inner_border.left + inner_border.right +
+                                  outer_border.left + outer_border.right),
                                  allocation.height -
-                                 (window_border.top +
-                                  window_border.bottom));
+                                 (inner_border.top + inner_border.bottom +
+                                  outer_border.top + outer_border.bottom));
+          gtk_render_frame (context, cr,
+                            outer_border.left,
+                            outer_border.top,
+                            allocation.width - (outer_border.left + outer_border.right),
+                            allocation.height - (outer_border.top + outer_border.bottom));
+          gtk_style_context_remove_class (context, "window-border");
+          gtk_style_context_add_class (context, "window-outer-border");
           gtk_render_frame (context, cr,
                             0, 0, allocation.width, allocation.height);
         }


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