summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-04-22 11:13:20 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-04-22 11:13:20 +0000
commitbe927d9ce665e9715b328ffa546c0427e0b9fb43 (patch)
tree44e638ec1cd52f7f8a7da7c7d49b52ffe204a739
parentdcb5a7427571e75b67e800250d847bf0b5e31814 (diff)
parentda4e2a29763f5fcc314da992c4b24763247c6211 (diff)
downloadgtk+-be927d9ce665e9715b328ffa546c0427e0b9fb43.tar.gz
Merge branch 'resize-borders' into 'master'
window: Fix up resize borders Closes #3856 See merge request GNOME/gtk!3467
-rw-r--r--gtk/gtkwindow.c70
1 files changed, 34 insertions, 36 deletions
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index b8ea6e3e21..abc6aa1582 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -149,7 +149,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 */
@@ -1363,10 +1364,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
@@ -1395,7 +1396,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)
{
@@ -1404,16 +1408,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 += shadow.left;
+ handle_size.top += shadow.top;
+ handle_size.right += shadow.right;
+ handle_size.bottom += shadow.bottom;
}
left = border_rect->origin.x;
@@ -1421,10 +1419,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);
@@ -1433,10 +1431,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);
@@ -1444,10 +1442,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);
@@ -1456,10 +1454,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);
@@ -4007,7 +4005,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;
@@ -4020,6 +4018,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:
@@ -4126,7 +4130,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;
@@ -4135,7 +4138,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);
@@ -4146,15 +4149,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)
{