From 18c17aaa5acb5c1d08e3064495a35bfb8b4ffa92 Mon Sep 17 00:00:00 2001 From: Jeffrey Knockel Date: Tue, 21 May 2024 08:53:03 -0400 Subject: [PATCH] constraints: Allow resize of windows moved above screen If the titlebar of a window has been moved above the screen by a user via an unconstrained move, then any constrained user resize following this move will cause the window to jump below the top of the screen or cause other glitchy behavior. This commit removes the constraint that the titlebar of a window must be below the top of the screen for any resize that is both (1) triggered by a user and (2) is a resize that affects only the left, right, or bottom edges of the window. This allows users to move a window partially above the screen and then resize the window to be wider or resize the bottom edge of the window to make it taller or shorter. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1206 Part-of: (cherry picked from commit 5ba364a9476905d9b92e7dc6cdc2f273bcda2498) --- src/core/constraints.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/core/constraints.c b/src/core/constraints.c index 4bd2bc471..2c261f083 100644 --- a/src/core/constraints.c +++ b/src/core/constraints.c @@ -1764,6 +1764,7 @@ constrain_titlebar_visible (MetaWindow *window, gboolean check_only) { gboolean unconstrained_user_action; + gboolean user_nonnorthern_resize; gboolean retval; int bottom_amount; int horiz_amount_offscreen, vert_amount_offscreen; @@ -1784,6 +1785,19 @@ constrain_titlebar_visible (MetaWindow *window, (meta_window_drag_get_grab_op (window_drag) & META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED) != 0); + /* If the user is resizing anything other than the top, then don't check if + * the titlebar is beyond the top of the screen. This resize might be + * immediately following an unconstrained move that placed the titlebar above + * the top of the screen, in which case we don't want the titlebar + * immediately popping back below the top of the screen or other glitching + * (https://gitlab.gnome.org/GNOME/mutter/-/issues/1206). + */ + user_nonnorthern_resize = + info->is_user_action && + window_drag && + meta_grab_op_is_resizing (meta_window_drag_get_grab_op (window_drag)) && + info->orig.y == info->current.y; + /* Exit early if we know the constraint won't apply--note that this constraint * is only meant for normal windows (e.g. we don't want docks to be shoved * "onscreen" by their own strut). @@ -1793,6 +1807,7 @@ constrain_titlebar_visible (MetaWindow *window, window->fullscreen || !window->require_titlebar_visible || unconstrained_user_action || + user_nonnorthern_resize || meta_window_get_placement_rule (window)) return TRUE;