From 760e60fa0487ded9b053ccd94200582cc24e52db Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 21 Apr 2021 20:00:49 -0400 Subject: window: Fix up resize borders The invisible resize borders have been wider than they should, for a while. Go back to a size close to what we have in GTK3. To summarize: resize borders will be at most 12 pixels on each size, but never wider than the windows shadow. The resize corners have 'legs' of 24 pixels where you still get a corner resize cursor. Fixes: #3856 --- gtk/gtkwindow.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 17beb19fa3..2270690357 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -148,7 +148,8 @@ */ #define MENU_BAR_ACCEL GDK_KEY_F10 -#define RESIZE_HANDLE_SIZE 20 +#define RESIZE_HANDLE_SIZE 12 /* Width of resize borders */ +#define RESIZE_HANDLE_CORNER_SIZE 24 /* How resize corners extend */ #define MNEMONICS_DELAY 300 /* ms */ #define NO_CONTENT_CHILD_NAT 200 /* ms */ #define VISIBLE_FOCUS_DURATION 3 /* s */ @@ -1389,10 +1390,10 @@ get_edge_for_coordinates (GtkWindow *window, if (x < left && x >= left - handle_size.left) { - if (y < top + handle_size.top && y >= top - handle_size.top) + if (y < top + RESIZE_HANDLE_CORNER_SIZE && y >= top - handle_size.top) return edge_or_minus_one (GDK_SURFACE_EDGE_NORTH_WEST); - if (y > top + border_rect->size.height - handle_size.bottom && + if (y > top + border_rect->size.height - RESIZE_HANDLE_CORNER_SIZE && y <= top + border_rect->size.height + handle_size.bottom) return edge_or_minus_one (GDK_SURFACE_EDGE_SOUTH_WEST); @@ -1401,10 +1402,10 @@ get_edge_for_coordinates (GtkWindow *window, else if (x > left + border_rect->size.width && x <= left + border_rect->size.width + handle_size.right) { - if (y < top + handle_size.top && y >= top - handle_size.top) + if (y < top + RESIZE_HANDLE_CORNER_SIZE && y >= top - handle_size.top) return edge_or_minus_one (GDK_SURFACE_EDGE_NORTH_EAST); - if (y > top + border_rect->size.height - handle_size.bottom && + if (y > top + border_rect->size.height - RESIZE_HANDLE_CORNER_SIZE && y <= top + border_rect->size.height + handle_size.bottom) return edge_or_minus_one (GDK_SURFACE_EDGE_SOUTH_EAST); @@ -1412,10 +1413,10 @@ get_edge_for_coordinates (GtkWindow *window, } else if (y < top && y >= top - handle_size.top) { - if (x < left + handle_size.left && x >= left - handle_size.left) + if (x < left + RESIZE_HANDLE_CORNER_SIZE && x >= left - handle_size.left) return edge_or_minus_one (GDK_SURFACE_EDGE_NORTH_WEST); - if (x > left + border_rect->size.width - handle_size.right && + if (x > left + border_rect->size.width - RESIZE_HANDLE_CORNER_SIZE && x <= left + border_rect->size.width + handle_size.right) return edge_or_minus_one (GDK_SURFACE_EDGE_NORTH_EAST); @@ -1424,10 +1425,10 @@ get_edge_for_coordinates (GtkWindow *window, else if (y > top + border_rect->size.height && y <= top + border_rect->size.height + handle_size.bottom) { - if (x < left + handle_size.left && x >= left - handle_size.left) + if (x < left + RESIZE_HANDLE_CORNER_SIZE && x >= left - handle_size.left) return edge_or_minus_one (GDK_SURFACE_EDGE_SOUTH_WEST); - if (x > left + border_rect->size.width - handle_size.right && + if (x > left + border_rect->size.width - RESIZE_HANDLE_CORNER_SIZE && x <= left + border_rect->size.width + handle_size.right) return edge_or_minus_one (GDK_SURFACE_EDGE_SOUTH_EAST); -- cgit v1.2.1 From a2cd21cab663a0034214c34682960c12b0ad3393 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 21 Apr 2021 21:09:09 -0400 Subject: window: Tweak resize borders Make windows resizable in the padding and border area of the css box as well. This naturally makes solid-csd borders work again. --- gtk/gtkwindow.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 2270690357..bacbb1f920 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -1332,10 +1332,10 @@ static void get_box_border (GtkCssStyle *style, GtkBorder *border) { - border->top = get_number (style->border->border_top_width); - border->left = get_number (style->border->border_left_width); - border->bottom = get_number (style->border->border_bottom_width); - border->right = get_number (style->border->border_right_width); + border->top = get_number (style->border->border_top_width) + get_number (style->size->padding_top); + border->left = get_number (style->border->border_left_width) + get_number (style->size->padding_left); + border->bottom = get_number (style->border->border_bottom_width) + get_number (style->size->padding_bottom); + border->right = get_number (style->border->border_right_width) + get_number (style->size->padding_right); } static int @@ -1364,7 +1364,10 @@ get_edge_for_coordinates (GtkWindow *window, return -1; gtk_css_boxes_init (&css_boxes, GTK_WIDGET (window)); - border_rect = gtk_css_boxes_get_padding_rect (&css_boxes); + border_rect = gtk_css_boxes_get_content_rect (&css_boxes); + + get_box_border (gtk_css_node_get_style (gtk_widget_get_css_node (GTK_WIDGET (window))), + &handle_size); if (priv->use_client_shadow) { @@ -1373,16 +1376,10 @@ get_edge_for_coordinates (GtkWindow *window, get_shadow_width (window, &shadow); /* This logic is duplicated in update_realized_window_properties() */ - handle_size.left = MIN (RESIZE_HANDLE_SIZE, shadow.left); - handle_size.top = MIN (RESIZE_HANDLE_SIZE, shadow.top); - handle_size.right = MIN (RESIZE_HANDLE_SIZE, shadow.right); - handle_size.bottom = MIN (RESIZE_HANDLE_SIZE, shadow.bottom); - } - else - { - /* Use border */ - get_box_border (gtk_css_node_get_style (gtk_widget_get_css_node (GTK_WIDGET (window))), - &handle_size); + handle_size.left += MIN (RESIZE_HANDLE_SIZE, shadow.left); + handle_size.top += MIN (RESIZE_HANDLE_SIZE, shadow.top); + handle_size.right += MIN (RESIZE_HANDLE_SIZE, shadow.right); + handle_size.bottom += MIN (RESIZE_HANDLE_SIZE, shadow.bottom); } left = border_rect->origin.x; @@ -3976,7 +3973,7 @@ get_shadow_width (GtkWindow *window, if (!priv->decorated) goto out; - if (!priv->client_decorated && + if (!priv->client_decorated || !(gtk_window_should_use_csd (window) && gtk_window_supports_client_shadow (window))) goto out; -- cgit v1.2.1 From 01d81ffc17f08ee8ddf5e1d0b105303c649f1caf Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 22 Apr 2021 06:33:30 -0400 Subject: window: Make resize border size independent Deriving the resize border size from the shadows carries the risk that we might end up with uneven resize borders (or none at all, on some sides). So, justs enforce that we have a big enough shadow width on all sides. --- gtk/gtkwindow.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index bacbb1f920..1a36008713 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -1376,10 +1376,10 @@ get_edge_for_coordinates (GtkWindow *window, get_shadow_width (window, &shadow); /* This logic is duplicated in update_realized_window_properties() */ - handle_size.left += MIN (RESIZE_HANDLE_SIZE, shadow.left); - handle_size.top += MIN (RESIZE_HANDLE_SIZE, shadow.top); - handle_size.right += MIN (RESIZE_HANDLE_SIZE, shadow.right); - handle_size.bottom += MIN (RESIZE_HANDLE_SIZE, shadow.bottom); + handle_size.left += shadow.left; + handle_size.top += shadow.top; + handle_size.right += shadow.right; + handle_size.bottom += shadow.bottom; } left = border_rect->origin.x; @@ -3986,6 +3986,12 @@ get_shadow_width (GtkWindow *window, /* Calculate the size of the drop shadows ... */ gtk_css_shadow_value_get_extents (style->background->box_shadow, shadow_width); + + shadow_width->left = MAX (shadow_width->left, RESIZE_HANDLE_SIZE); + shadow_width->top = MAX (shadow_width->top, RESIZE_HANDLE_SIZE); + shadow_width->bottom = MAX (shadow_width->bottom, RESIZE_HANDLE_SIZE); + shadow_width->right = MAX (shadow_width->right, RESIZE_HANDLE_SIZE); + return; out: @@ -4092,7 +4098,6 @@ update_realized_window_properties (GtkWindow *window) { GtkWindowPrivate *priv = gtk_window_get_instance_private (window); GtkBorder shadow; - GtkBorder resize_handle; GdkRectangle rect; GtkCssBoxes css_boxes; const graphene_rect_t *border_rect; @@ -4101,7 +4106,7 @@ update_realized_window_properties (GtkWindow *window) get_shadow_width (window, &shadow); update_opaque_region (window, &shadow); - if (!priv->client_decorated) + if (!priv->client_decorated || !priv->use_client_shadow) return; gtk_native_get_surface_transform (GTK_NATIVE (window), &native_x, &native_y); @@ -4112,15 +4117,10 @@ update_realized_window_properties (GtkWindow *window) border_rect = gtk_css_boxes_get_border_rect (&css_boxes); /* This logic is duplicated in get_edge_for_coordinates() */ - resize_handle.left = MIN (shadow.left, RESIZE_HANDLE_SIZE); - resize_handle.top = MIN (shadow.top, RESIZE_HANDLE_SIZE); - resize_handle.right = MIN (shadow.right, RESIZE_HANDLE_SIZE); - resize_handle.bottom = MIN (shadow.bottom, RESIZE_HANDLE_SIZE); - - rect.x = native_x + border_rect->origin.x - resize_handle.left; - rect.y = native_y + border_rect->origin.y - resize_handle.top; - rect.width = border_rect->size.width + resize_handle.left + resize_handle.right; - rect.height = border_rect->size.height + resize_handle.top + resize_handle.bottom; + rect.x = native_x + border_rect->origin.x - RESIZE_HANDLE_SIZE; + rect.y = native_y + border_rect->origin.y - RESIZE_HANDLE_SIZE; + rect.width = border_rect->size.width + 2 * RESIZE_HANDLE_SIZE; + rect.height = border_rect->size.height + 2 * RESIZE_HANDLE_SIZE; if (rect.width > 0 && rect.height > 0) { -- cgit v1.2.1 From f8dcda80cfec7e68e1c231ae77039dec1ddbd694 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 21 Apr 2021 21:10:17 -0400 Subject: theme: Fix solid-csd borders MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The selectors did not apply anymore. Based on a patch by Alberts Muktupāvels. --- gtk/theme/Default/_common.scss | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gtk/theme/Default/_common.scss b/gtk/theme/Default/_common.scss index 83692f5e97..2e6dade4dd 100644 --- a/gtk/theme/Default/_common.scss +++ b/gtk/theme/Default/_common.scss @@ -4068,16 +4068,16 @@ window { box-shadow: 0 1px 2px transparentize(black, 0.8), 0 0 0 1px transparentize($_wm_border, 0.1); } + } - &.solid-csd { - margin: 0; - padding: 0; - border: solid 1px $borders_color; - border-radius: 0; - box-shadow: inset 0 0 0 3px $headerbar_bg_color, inset 0 1px $top_hilight; + &.solid-csd { + margin: 0; + padding: 4px; + border: solid 1px $borders_color; + border-radius: 0; + box-shadow: inset 0 0 0 3px $headerbar_bg_color, inset 0 1px $top_hilight; - &:backdrop { box-shadow: inset 0 0 0 3px $backdrop_bg_color, inset 0 1px $top_hilight; } - } + &:backdrop { box-shadow: inset 0 0 0 3px $backdrop_bg_color, inset 0 1px $top_hilight; } } &.maximized, -- cgit v1.2.1 From da4e2a29763f5fcc314da992c4b24763247c6211 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 22 Apr 2021 06:43:46 -0400 Subject: theme: Make solid borders look better MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As pointed out by Alberts Muktupāvels, without this, we are missing the inner edge of the frame. --- gtk/theme/Default/_common.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gtk/theme/Default/_common.scss b/gtk/theme/Default/_common.scss index 2e6dade4dd..709a9bd61c 100644 --- a/gtk/theme/Default/_common.scss +++ b/gtk/theme/Default/_common.scss @@ -4075,9 +4075,9 @@ window { padding: 4px; border: solid 1px $borders_color; border-radius: 0; - box-shadow: inset 0 0 0 3px $headerbar_bg_color, inset 0 1px $top_hilight; + box-shadow: inset 0 0 0 4px $borders_color, inset 0 0 0 3px $headerbar_bg_color, inset 0 1px $top_hilight; - &:backdrop { box-shadow: inset 0 0 0 3px $backdrop_bg_color, inset 0 1px $top_hilight; } + &:backdrop { box-shadow: inset 0 0 0 4px $borders_color, inset 0 0 0 3px $backdrop_bg_color, inset 0 1px $top_hilight; } } &.maximized, -- cgit v1.2.1