[gtk/wip/exalm/round_corners: 2/2] window: Mask corners



commit d4458b7a55b1a957cf62bddbb651f371c12cc95c
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Tue May 12 19:09:37 2020 +0500

    window: Mask corners

 gtk/gtkwindow.c                | 31 +++++++++++++++++-----------
 gtk/theme/Adwaita/_common.scss | 47 ++++++------------------------------------
 2 files changed, 25 insertions(+), 53 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index c8e51c5073..9f08c66a3c 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -6020,9 +6020,9 @@ gtk_window_snapshot (GtkWidget   *widget,
   GtkWindowPrivate *priv = gtk_window_get_instance_private (GTK_WINDOW (widget));
   GtkStyleContext *context;
   GtkBorder window_border;
-  gint title_height;
   int width, height;
   GtkWidget *child;
+  GskRoundedRect clip_rect;
 
   context = gtk_widget_get_style_context (widget);
 
@@ -6069,27 +6069,32 @@ gtk_window_snapshot (GtkWidget   *widget,
       gtk_style_context_restore (context);
     }
 
-  if (priv->title_box &&
-      gtk_widget_get_visible (priv->title_box) &&
-      gtk_widget_get_child_visible (priv->title_box))
-    title_height = priv->title_height;
-  else
-    title_height = 0;
-
   gtk_snapshot_render_background (snapshot, context,
                                   window_border.left,
-                                  window_border.top + title_height,
+                                  window_border.top,
                                   width -
                                     (window_border.left + window_border.right),
                                   height -
-                                    (window_border.top + window_border.bottom + title_height));
+                                    (window_border.top + window_border.bottom));
   gtk_snapshot_render_frame (snapshot, context,
                              window_border.left,
-                             window_border.top + title_height,
+                             window_border.top,
                              width -
                                (window_border.left + window_border.right),
                              height -
-                               (window_border.top + window_border.bottom + title_height));
+                               (window_border.top + window_border.bottom));
+
+  gtk_rounded_boxes_init_for_style (&clip_rect,
+                                    NULL, NULL,
+                                    gtk_css_node_get_style (gtk_widget_get_css_node (widget)),
+                                    window_border.left,
+                                    window_border.top,
+                                    width -
+                                      (window_border.left + window_border.right),
+                                    height -
+                                      (window_border.top + window_border.bottom));
+
+  gtk_snapshot_push_rounded_clip (snapshot, &clip_rect);
 
   for (child = _gtk_widget_get_first_child (widget);
        child != NULL;
@@ -6099,6 +6104,8 @@ gtk_window_snapshot (GtkWidget   *widget,
       if (!GTK_IS_POPOVER (child))
         gtk_widget_snapshot_child (widget, child, snapshot);
     }
+
+  gtk_snapshot_pop (snapshot);
 }
 
 /**
diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss
index f240346b89..1321b8b8dd 100644
--- a/gtk/theme/Adwaita/_common.scss
+++ b/gtk/theme/Adwaita/_common.scss
@@ -1378,7 +1378,6 @@ headerbar {
   border-width: 0 0 1px;
   border-style: solid;
   border-color: $alt_borders_color;
-  border-radius: 0;
 
   @include headerbar_fill(darken($bg_color, 10%));
 
@@ -1422,19 +1421,6 @@ headerbar {
     }
   }
 
-  // squared corners when the window is maximized, tiled, or fullscreen
-  .tiled &,
-  .tiled-top &,
-  .tiled-left &,
-  .tiled-right &,
-  .tiled-bottom &,
-  .maximized &,
-  .fullscreen & {
-    &:backdrop, & {
-      border-radius: 0;
-    }
-  }
-
   &.default-decoration {
     min-height: 28px;
     padding: 4px;
@@ -1463,7 +1449,6 @@ headerbar {
         margin-left: -1px;
         margin-right: -1px;
         margin-top: -1px;
-        border-radius: 0;
         box-shadow: none;
       }
     }
@@ -1505,31 +1490,6 @@ headerbar {
   }
 }
 
-.background:not(.tiled):not(.maximized):not(.solid-csd) .titlebar,
-.background:not(.tiled-top):not(.maximized):not(.solid-csd) .titlebar,
-.background:not(.tiled-left):not(.maximized):not(.solid-csd) .titlebar,
-.background:not(.tiled-right):not(.maximized):not(.solid-csd) .titlebar,
-.background:not(.tiled-bottom):not(.maximized):not(.solid-csd) .titlebar {
-  &:backdrop, & {
-    border-top-left-radius: 7px;
-    border-top-right-radius: 7px;
-  }
-}
-
-headerbar { // headerbar border rounding
-  window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) separator:first-child + &, // tackles 
the paned container case
-  window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) &:first-child { &:backdrop, & { 
border-top-left-radius: 7px; }}
-  window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) &:last-child { &:backdrop, & { 
border-top-right-radius: 7px; }}
-  window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) stack & { // tackles the stacked 
headerbars case
-    &:first-child, &:last-child {
-      &:backdrop, & {
-        border-top-left-radius: 7px;
-        border-top-right-radius: 7px;
-      }
-    }
-  }
-}
-
 .titlebar:not(headerbar) {
   window.csd > & {
     // in csd we assume every titlebar is a headerbar so reset anything, this is needed for split toolbars 
cases
@@ -4052,8 +4012,13 @@ colorchooser .popover.osd { border-radius: 5px; }
 /**********************
  * Window Decorations *
  *********************/
+
+.csd {
+  border-radius: $window_radius;
+}
+
 decoration {
-  border-radius: $window_radius $window_radius 0 0;
+  border-radius: $window_radius;
   // lamefun trick to get rounded borders regardless of CSD use
   border-width: 0px;
 


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