From 2d8fa26c8e07fbedda5f1266c4897d8dbbb9b65c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 29 Sep 2022 15:55:11 +0200 Subject: [PATCH] core: Pass "frame action" grab operations as an "unconstrained" grab op The frame_action boolean is only used by constraints.c code, in order to determine whether a moving window should be able to move past the top bar or not. We can avoid the special casing by passing this information as a META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED flag passed with the grab op. Part-of: --- src/core/constraints.c | 3 ++- src/core/display-private.h | 1 - src/core/display.c | 9 +++++++-- src/meta/meta-enums.h | 3 +++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/core/constraints.c b/src/core/constraints.c index 86a3effe4..e1d1303ed 100644 --- a/src/core/constraints.c +++ b/src/core/constraints.c @@ -1769,7 +1769,8 @@ constrain_titlebar_visible (MetaWindow *window, * clicking on the frame to start the move. */ unconstrained_user_action = - info->is_user_action && !window->display->grab_frame_action; + info->is_user_action && + (window->display->grab_op & META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED) != 0; /* 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 diff --git a/src/core/display-private.h b/src/core/display-private.h index 8cd251df8..565529385 100644 --- a/src/core/display-private.h +++ b/src/core/display-private.h @@ -172,7 +172,6 @@ struct _MetaDisplay int grab_latest_motion_y; guint grab_have_pointer : 1; guint grab_have_keyboard : 1; - guint grab_frame_action : 1; MetaRectangle grab_initial_window_pos; int grab_initial_x, grab_initial_y; /* These are only relevant for */ gboolean grab_threshold_movement_reached; /* raise_on_click == FALSE. */ diff --git a/src/core/display.c b/src/core/display.c index 1bb7e0d76..b0a2116cc 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -1670,6 +1670,8 @@ meta_display_notify_window_created (MetaDisplay *display, static MetaCursor meta_cursor_for_grab_op (MetaGrabOp op) { + op &= ~(META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED); + switch (op) { case META_GRAB_OP_RESIZING_SE: @@ -1880,6 +1882,9 @@ meta_display_begin_grab_op (MetaDisplay *display, return FALSE; } + if (!frame_action) + op |= META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED; + event_route = get_event_route_from_grab_op (op); if (event_route == META_EVENT_ROUTE_WINDOW_OP) @@ -1957,7 +1962,6 @@ meta_display_begin_grab_op (MetaDisplay *display, display->grab_latest_motion_x = root_x; display->grab_latest_motion_y = root_y; display->grab_last_edge_resistance_flags = META_EDGE_RESISTANCE_DEFAULT; - display->grab_frame_action = frame_action; meta_display_update_cursor (display); @@ -2047,7 +2051,6 @@ meta_display_end_grab_op (MetaDisplay *display, display->grab_latest_motion_x = 0; display->grab_latest_motion_y = 0; display->grab_last_edge_resistance_flags = META_EDGE_RESISTANCE_DEFAULT; - display->grab_frame_action = FALSE; meta_display_update_cursor (display); @@ -2564,6 +2567,8 @@ meta_resize_gravity_from_grab_op (MetaGrabOp op) { MetaGravity gravity; + op &= ~(META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED); + gravity = -1; switch (op) { diff --git a/src/meta/meta-enums.h b/src/meta/meta-enums.h index 3759ab0ab..83198bc54 100644 --- a/src/meta/meta-enums.h +++ b/src/meta/meta-enums.h @@ -110,6 +110,7 @@ enum { META_GRAB_OP_WINDOW_FLAG_KEYBOARD = 0x0100, META_GRAB_OP_WINDOW_FLAG_UNKNOWN = 0x0200, + META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED = 0x0400, META_GRAB_OP_WINDOW_DIR_WEST = 0x1000, META_GRAB_OP_WINDOW_DIR_EAST = 0x2000, META_GRAB_OP_WINDOW_DIR_SOUTH = 0x4000, @@ -119,6 +120,7 @@ enum /* WGO = "window grab op". shorthand for below */ _WGO_K = META_GRAB_OP_WINDOW_FLAG_KEYBOARD, _WGO_U = META_GRAB_OP_WINDOW_FLAG_UNKNOWN, + _WGO_C = META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED, _WGO_W = META_GRAB_OP_WINDOW_DIR_WEST, _WGO_E = META_GRAB_OP_WINDOW_DIR_EAST, _WGO_S = META_GRAB_OP_WINDOW_DIR_SOUTH, @@ -133,6 +135,7 @@ typedef enum META_GRAB_OP_WINDOW_BASE, META_GRAB_OP_MOVING = META_GRAB_OP_WINDOW_BASE, + META_GRAB_OP_MOVING_UNCONSTRAINED = META_GRAB_OP_WINDOW_BASE | _WGO_C, META_GRAB_OP_RESIZING_NW = META_GRAB_OP_WINDOW_BASE | _WGO_N | _WGO_W, META_GRAB_OP_RESIZING_N = META_GRAB_OP_WINDOW_BASE | _WGO_N, META_GRAB_OP_RESIZING_NE = META_GRAB_OP_WINDOW_BASE | _WGO_N | _WGO_E,