[gtk+/wip/gbsneto/edge-constraints: 216/216] window: Add individual CSS classes based on edge constraints



commit 79bf5b859289d3fe7d6be450ce5bb8eb14eed2dc
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Aug 18 20:12:23 2017 -0300

    window: Add individual CSS classes based on edge constraints
    
    The last touch on this patch series is making GtkWindow able to
    selectively adjust various UI details based on the different
    tiled edges. The main driver here is that we don't want to show
    shadows on edges that are constrained.
    
    This patch adds the necessary code to do that, while still
    maintaining compatibility with the old ways.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783669

 gtk/gtkwindow.c                          |   41 ++++++++++++++++++++++--
 gtk/theme/Adwaita/_common.scss           |   50 ++++++++++++++++++++++++++---
 gtk/theme/Adwaita/gtk-contained-dark.css |   16 ++++++---
 gtk/theme/Adwaita/gtk-contained.css      |   16 ++++++---
 4 files changed, 101 insertions(+), 22 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index fb87ca6..ffc8418 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -7643,10 +7643,37 @@ update_window_style_classes (GtkWindow *window)
 
   context = gtk_widget_get_style_context (GTK_WIDGET (window));
 
-  if (priv->tiled)
-    gtk_style_context_add_class (context, "tiled");
+  if (priv->edge_constraints == 0)
+    {
+      if (priv->tiled)
+        gtk_style_context_add_class (context, "tiled");
+      else
+        gtk_style_context_remove_class (context, "tiled");
+    }
   else
-    gtk_style_context_remove_class (context, "tiled");
+    {
+      guint edge_constraints = priv->edge_constraints;
+
+      if (edge_constraints & GDK_WINDOW_STATE_TOP_TILED)
+        gtk_style_context_add_class (context, "tiled-top");
+      else
+        gtk_style_context_remove_class (context, "tiled-top");
+
+      if (edge_constraints & GDK_WINDOW_STATE_RIGHT_TILED)
+        gtk_style_context_add_class (context, "tiled-right");
+      else
+        gtk_style_context_remove_class (context, "tiled-right");
+
+      if (edge_constraints & GDK_WINDOW_STATE_BOTTOM_TILED)
+        gtk_style_context_add_class (context, "tiled-bottom");
+      else
+        gtk_style_context_remove_class (context, "tiled-bottom");
+
+      if (edge_constraints & GDK_WINDOW_STATE_LEFT_TILED)
+        gtk_style_context_add_class (context, "tiled-left");
+      else
+        gtk_style_context_remove_class (context, "tiled-left");
+    }
 
   if (priv->maximized)
     gtk_style_context_add_class (context, "maximized");
@@ -7940,7 +7967,13 @@ gtk_window_state_event (GtkWidget           *widget,
 
   update_edge_constraints (window, event);
 
-  if (event->changed_mask & (GDK_WINDOW_STATE_FULLSCREEN | GDK_WINDOW_STATE_MAXIMIZED | 
GDK_WINDOW_STATE_TILED))
+  if (event->changed_mask & (GDK_WINDOW_STATE_FULLSCREEN |
+                             GDK_WINDOW_STATE_MAXIMIZED |
+                             GDK_WINDOW_STATE_TILED |
+                             GDK_WINDOW_STATE_TOP_TILED |
+                             GDK_WINDOW_STATE_RIGHT_TILED |
+                             GDK_WINDOW_STATE_BOTTOM_TILED |
+                             GDK_WINDOW_STATE_LEFT_TILED))
     {
       update_window_style_classes (window);
       update_window_buttons (window);
diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss
index 3dd8832..274c0ce 100644
--- a/gtk/theme/Adwaita/_common.scss
+++ b/gtk/theme/Adwaita/_common.scss
@@ -1589,6 +1589,7 @@ headerbar {
 
   // squared corners when the window is maximized, tiled, or fullscreen
   .tiled &,
+  .tiled-top &,
   .maximized &,
   .fullscreen & {
     &:backdrop, & {
@@ -1596,6 +1597,14 @@ headerbar {
     }
   }
 
+  .tiled-left & {
+    border-top-left-radius: 0;
+  }
+
+  .tiled-right & {
+    border-top-right-radius: 0;
+  }
+
   &.default-decoration {
     min-height: 28px;
     padding: 4px;
@@ -1636,18 +1645,32 @@ headerbar {
   }
 }
 
-.background:not(.tiled):not(.maximized):not(.solid-csd) .titlebar {
+.background .titlebar {
   &:backdrop, & {
     border-top-left-radius: 7px;
     border-top-right-radius: 7px;
   }
 }
 
+.background.tiled .titlebar,
+.background.tiled-top .titlebar,
+.background.tiled-right .titlebar,
+.background.tiled-bottom .titlebar,
+.background.tiled-left .titlebar,
+.background.maximized .titlebar,
+.backgrounf.solid-csd .titlebar {
+  &:backdrop, & {
+    border-top-left-radius: 0;
+    border-top-right-radius: 0;
+  }
+}
+
 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
+
+  window separator:first-child + &,
+  window stack &,
+  &:first-child,
+  &:last-child {
     &:first-child, &:last-child {
       &:backdrop, & {
         border-top-left-radius: 7px;
@@ -1655,6 +1678,17 @@ headerbar { // headerbar border rounding
       }
     }
   }
+
+  window.tiled &,
+  window.tiled-top &,
+  window.tiled-right &,
+  window.tiled-bottom &,
+  window.tiled-left &,
+  window.maximized &,
+  window.fullscreen & {
+    border-top-left-radius: 0;
+    border-top-right-radius: 0;
+  }
 }
 
 .titlebar:not(headerbar) {
@@ -4273,7 +4307,11 @@ decoration {
 
   .maximized &,
   .fullscreen &,
-  .tiled & { border-radius: 0; }
+  .tiled &,
+  .tiled-top &,
+  .tiled-right &,
+  .tiled-bottom &,
+  .tiled-left & { border-radius: 0; }
 
   .popup & { box-shadow: none; }
 
diff --git a/gtk/theme/Adwaita/gtk-contained-dark.css b/gtk/theme/Adwaita/gtk-contained-dark.css
index 8596f6f..82c4bac 100644
--- a/gtk/theme/Adwaita/gtk-contained-dark.css
+++ b/gtk/theme/Adwaita/gtk-contained-dark.css
@@ -648,7 +648,11 @@ searchbar, .location-bar { border-width: 0 0 1px; padding: 3px; }
 
 .selection-mode.titlebar:not(headerbar) .selection-menu:backdrop .arrow, 
.selection-mode.titlebar:not(headerbar) .selection-menu .arrow, headerbar.selection-mode 
.selection-menu:backdrop .arrow, headerbar.selection-mode .selection-menu .arrow { -gtk-icon-source: 
-gtk-icontheme("pan-down-symbolic"); color: rgba(255, 255, 255, 0.5); -gtk-icon-shadow: none; }
 
-.tiled .titlebar:backdrop:not(headerbar), .tiled .titlebar:not(headerbar), .maximized 
.titlebar:backdrop:not(headerbar), .maximized .titlebar:not(headerbar), .fullscreen 
.titlebar:backdrop:not(headerbar), .fullscreen .titlebar:not(headerbar), .tiled headerbar:backdrop, .tiled 
headerbar, .maximized headerbar:backdrop, .maximized headerbar, .fullscreen headerbar:backdrop, .fullscreen 
headerbar { border-radius: 0; }
+.tiled .titlebar:backdrop:not(headerbar), .tiled .titlebar:not(headerbar), .tiled-top 
.titlebar:backdrop:not(headerbar), .tiled-top .titlebar:not(headerbar), .maximized 
.titlebar:backdrop:not(headerbar), .maximized .titlebar:not(headerbar), .fullscreen 
.titlebar:backdrop:not(headerbar), .fullscreen .titlebar:not(headerbar), .tiled headerbar:backdrop, .tiled 
headerbar, .tiled-top headerbar:backdrop, .tiled-top headerbar, .maximized headerbar:backdrop, .maximized 
headerbar, .fullscreen headerbar:backdrop, .fullscreen headerbar { border-radius: 0; }
+
+.tiled-left .titlebar:not(headerbar), .tiled-left headerbar { border-top-left-radius: 0; }
+
+.tiled-right .titlebar:not(headerbar), .tiled-right headerbar { border-top-right-radius: 0; }
 
 .default-decoration.titlebar:not(headerbar), headerbar.default-decoration { min-height: 28px; padding: 4px; }
 
@@ -660,13 +664,13 @@ headerbar entry, headerbar spinbutton, headerbar separator, headerbar button { m
 
 headerbar switch { margin-top: 9px; margin-bottom: 9px; }
 
-.background:not(.tiled):not(.maximized):not(.solid-csd) .titlebar:backdrop, 
.background:not(.tiled):not(.maximized):not(.solid-csd) .titlebar { border-top-left-radius: 7px; 
border-top-right-radius: 7px; }
+.background .titlebar:backdrop, .background .titlebar { border-top-left-radius: 7px; 
border-top-right-radius: 7px; }
 
-window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) separator:first-child + 
headerbar:backdrop, window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) separator:first-child 
+ headerbar, window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) 
headerbar:first-child:backdrop, window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) 
headerbar:first-child { border-top-left-radius: 7px; }
+.background.tiled .titlebar:backdrop, .background.tiled .titlebar, .background.tiled-top .titlebar:backdrop, 
.background.tiled-top .titlebar, .background.tiled-right .titlebar:backdrop, .background.tiled-right 
.titlebar, .background.tiled-bottom .titlebar:backdrop, .background.tiled-bottom .titlebar, 
.background.tiled-left .titlebar:backdrop, .background.tiled-left .titlebar, .background.maximized 
.titlebar:backdrop, .background.maximized .titlebar, .backgrounf.solid-csd .titlebar:backdrop, 
.backgrounf.solid-csd .titlebar { border-top-left-radius: 0; border-top-right-radius: 0; }
 
-window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) headerbar:last-child:backdrop, 
window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) headerbar:last-child { 
border-top-right-radius: 7px; }
+window separator:first-child + headerbar:first-child:backdrop, window separator:first-child + 
headerbar:first-child, window separator:first-child + headerbar:last-child:backdrop, window 
separator:first-child + headerbar:last-child, window stack headerbar:first-child:backdrop, window stack 
headerbar:first-child, window stack headerbar:last-child:backdrop, window stack headerbar:last-child, 
headerbar:first-child:first-child:backdrop, headerbar:first-child:first-child, 
headerbar:first-child:last-child:backdrop, headerbar:first-child:last-child, 
headerbar:last-child:first-child:backdrop, headerbar:last-child:first-child, 
headerbar:last-child:last-child:backdrop, headerbar:last-child:last-child { border-top-left-radius: 7px; 
border-top-right-radius: 7px; }
 
-window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) stack headerbar:first-child:backdrop, 
window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) stack headerbar:first-child, 
window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) stack headerbar:last-child:backdrop, 
window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) stack headerbar:last-child { 
border-top-left-radius: 7px; border-top-right-radius: 7px; }
+window.tiled headerbar, window.tiled-top headerbar, window.tiled-right headerbar, window.tiled-bottom 
headerbar, window.tiled-left headerbar, window.maximized headerbar, window.fullscreen headerbar { 
border-top-left-radius: 0; border-top-right-radius: 0; }
 
 window.csd > .titlebar:not(headerbar) { padding: 0; background-color: transparent; background-image: none; 
border-style: none; border-color: transparent; box-shadow: none; }
 
@@ -1832,7 +1836,7 @@ decoration { border-radius: 7px 7px 0 0; border-width: 0px; box-shadow: 0 3px 9p
 
 decoration:backdrop { box-shadow: 0 3px 9px 1px transparent, 0 2px 6px 2px rgba(0, 0, 0, 0.2), 0 0 0 1px 
rgba(27, 31, 32, 0.9); transition: 200ms ease-out; }
 
-.maximized decoration, .fullscreen decoration, .tiled decoration { border-radius: 0; }
+.maximized decoration, .fullscreen decoration, .tiled decoration, .tiled-top decoration, .tiled-right 
decoration, .tiled-bottom decoration, .tiled-left decoration { border-radius: 0; }
 
 .popup decoration { box-shadow: none; }
 
diff --git a/gtk/theme/Adwaita/gtk-contained.css b/gtk/theme/Adwaita/gtk-contained.css
index 2ff271f..5409f53 100644
--- a/gtk/theme/Adwaita/gtk-contained.css
+++ b/gtk/theme/Adwaita/gtk-contained.css
@@ -656,7 +656,11 @@ searchbar, .location-bar { border-width: 0 0 1px; padding: 3px; }
 
 .selection-mode.titlebar:not(headerbar) .selection-menu:backdrop .arrow, 
.selection-mode.titlebar:not(headerbar) .selection-menu .arrow, headerbar.selection-mode 
.selection-menu:backdrop .arrow, headerbar.selection-mode .selection-menu .arrow { -gtk-icon-source: 
-gtk-icontheme("pan-down-symbolic"); color: rgba(255, 255, 255, 0.5); -gtk-icon-shadow: none; }
 
-.tiled .titlebar:backdrop:not(headerbar), .tiled .titlebar:not(headerbar), .maximized 
.titlebar:backdrop:not(headerbar), .maximized .titlebar:not(headerbar), .fullscreen 
.titlebar:backdrop:not(headerbar), .fullscreen .titlebar:not(headerbar), .tiled headerbar:backdrop, .tiled 
headerbar, .maximized headerbar:backdrop, .maximized headerbar, .fullscreen headerbar:backdrop, .fullscreen 
headerbar { border-radius: 0; }
+.tiled .titlebar:backdrop:not(headerbar), .tiled .titlebar:not(headerbar), .tiled-top 
.titlebar:backdrop:not(headerbar), .tiled-top .titlebar:not(headerbar), .maximized 
.titlebar:backdrop:not(headerbar), .maximized .titlebar:not(headerbar), .fullscreen 
.titlebar:backdrop:not(headerbar), .fullscreen .titlebar:not(headerbar), .tiled headerbar:backdrop, .tiled 
headerbar, .tiled-top headerbar:backdrop, .tiled-top headerbar, .maximized headerbar:backdrop, .maximized 
headerbar, .fullscreen headerbar:backdrop, .fullscreen headerbar { border-radius: 0; }
+
+.tiled-left .titlebar:not(headerbar), .tiled-left headerbar { border-top-left-radius: 0; }
+
+.tiled-right .titlebar:not(headerbar), .tiled-right headerbar { border-top-right-radius: 0; }
 
 .default-decoration.titlebar:not(headerbar), headerbar.default-decoration { min-height: 28px; padding: 4px; }
 
@@ -668,13 +672,13 @@ headerbar entry, headerbar spinbutton, headerbar separator, headerbar button { m
 
 headerbar switch { margin-top: 9px; margin-bottom: 9px; }
 
-.background:not(.tiled):not(.maximized):not(.solid-csd) .titlebar:backdrop, 
.background:not(.tiled):not(.maximized):not(.solid-csd) .titlebar { border-top-left-radius: 7px; 
border-top-right-radius: 7px; }
+.background .titlebar:backdrop, .background .titlebar { border-top-left-radius: 7px; 
border-top-right-radius: 7px; }
 
-window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) separator:first-child + 
headerbar:backdrop, window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) separator:first-child 
+ headerbar, window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) 
headerbar:first-child:backdrop, window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) 
headerbar:first-child { border-top-left-radius: 7px; }
+.background.tiled .titlebar:backdrop, .background.tiled .titlebar, .background.tiled-top .titlebar:backdrop, 
.background.tiled-top .titlebar, .background.tiled-right .titlebar:backdrop, .background.tiled-right 
.titlebar, .background.tiled-bottom .titlebar:backdrop, .background.tiled-bottom .titlebar, 
.background.tiled-left .titlebar:backdrop, .background.tiled-left .titlebar, .background.maximized 
.titlebar:backdrop, .background.maximized .titlebar, .backgrounf.solid-csd .titlebar:backdrop, 
.backgrounf.solid-csd .titlebar { border-top-left-radius: 0; border-top-right-radius: 0; }
 
-window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) headerbar:last-child:backdrop, 
window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) headerbar:last-child { 
border-top-right-radius: 7px; }
+window separator:first-child + headerbar:first-child:backdrop, window separator:first-child + 
headerbar:first-child, window separator:first-child + headerbar:last-child:backdrop, window 
separator:first-child + headerbar:last-child, window stack headerbar:first-child:backdrop, window stack 
headerbar:first-child, window stack headerbar:last-child:backdrop, window stack headerbar:last-child, 
headerbar:first-child:first-child:backdrop, headerbar:first-child:first-child, 
headerbar:first-child:last-child:backdrop, headerbar:first-child:last-child, 
headerbar:last-child:first-child:backdrop, headerbar:last-child:first-child, 
headerbar:last-child:last-child:backdrop, headerbar:last-child:last-child { border-top-left-radius: 7px; 
border-top-right-radius: 7px; }
 
-window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) stack headerbar:first-child:backdrop, 
window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) stack headerbar:first-child, 
window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) stack headerbar:last-child:backdrop, 
window:not(.tiled):not(.maximized):not(.fullscreen):not(.solid-csd) stack headerbar:last-child { 
border-top-left-radius: 7px; border-top-right-radius: 7px; }
+window.tiled headerbar, window.tiled-top headerbar, window.tiled-right headerbar, window.tiled-bottom 
headerbar, window.tiled-left headerbar, window.maximized headerbar, window.fullscreen headerbar { 
border-top-left-radius: 0; border-top-right-radius: 0; }
 
 window.csd > .titlebar:not(headerbar) { padding: 0; background-color: transparent; background-image: none; 
border-style: none; border-color: transparent; box-shadow: none; }
 
@@ -1852,7 +1856,7 @@ decoration { border-radius: 7px 7px 0 0; border-width: 0px; box-shadow: 0 3px 9p
 
 decoration:backdrop { box-shadow: 0 3px 9px 1px transparent, 0 2px 6px 2px rgba(0, 0, 0, 0.2), 0 0 0 1px 
rgba(0, 0, 0, 0.18); transition: 200ms ease-out; }
 
-.maximized decoration, .fullscreen decoration, .tiled decoration { border-radius: 0; }
+.maximized decoration, .fullscreen decoration, .tiled decoration, .tiled-top decoration, .tiled-right 
decoration, .tiled-bottom decoration, .tiled-left decoration { border-radius: 0; }
 
 .popup decoration { box-shadow: none; }
 


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