From bc74d166ddf1609e21b4e6d5522587295cc4fc49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 6 Sep 2023 12:24:00 +0200 Subject: [PATCH] window: Really fix portrait orientation check for tiling Commit 3bfcb6d1 fixed the check for tiling via keybindings, but ignored a subtle edge case when tiling with the pointer: The monitor used for tiling is the monitor with the pointer, which is not necessarily the one that contains the largest part of the window. That is, the correct monitor to check against depends on the context where the function is called. We can either figure it out automatically via the current window drag, or make it a parameter. The latter is clearer, because the callers already decide which monitor to use for tiling anyway. Fixes: 3bfcb6d1b9 ("window: Fix portrait orientation check for tiling") Part-of: --- src/compositor/meta-window-drag.c | 4 ++-- src/core/keybindings.c | 2 +- src/core/window-private.h | 3 ++- src/core/window.c | 7 +++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compositor/meta-window-drag.c b/src/compositor/meta-window-drag.c index bd71d9e9c..f3f8d6449 100644 --- a/src/compositor/meta-window-drag.c +++ b/src/compositor/meta-window-drag.c @@ -1160,10 +1160,10 @@ update_move_maybe_tile (MetaWindowDrag *window_drag, /* Check if the cursor is in a position which triggers tiling * and set tile_mode accordingly. */ - if (meta_window_can_tile_side_by_side (window) && + if (meta_window_can_tile_side_by_side (window, logical_monitor->number) && x >= logical_monitor->rect.x && x < (work_area.x + shake_threshold)) window_drag->preview_tile_mode = META_TILE_LEFT; - else if (meta_window_can_tile_side_by_side (window) && + else if (meta_window_can_tile_side_by_side (window, logical_monitor->number) && x >= work_area.x + work_area.width - shake_threshold && x < (logical_monitor->rect.x + logical_monitor->rect.width)) window_drag->preview_tile_mode = META_TILE_RIGHT; diff --git a/src/core/keybindings.c b/src/core/keybindings.c index b25d993d8..39df9c094 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -2668,7 +2668,7 @@ handle_toggle_tiled (MetaDisplay *display, { meta_window_untile (window); } - else if (meta_window_can_tile_side_by_side (window)) + else if (meta_window_can_tile_side_by_side (window, window->monitor->number)) { window->tile_monitor_number = window->monitor->number; /* Maximization constraints beat tiling constraints, so if the window diff --git a/src/core/window-private.h b/src/core/window-private.h index fc5fac832..4df552abe 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -778,7 +778,8 @@ void meta_window_update_for_monitors_changed (MetaWindow *window); void meta_window_on_all_workspaces_changed (MetaWindow *window); gboolean meta_window_should_attach_to_parent (MetaWindow *window); -gboolean meta_window_can_tile_side_by_side (MetaWindow *window); +gboolean meta_window_can_tile_side_by_side (MetaWindow *window, + int monitor_number); void meta_window_compute_tile_match (MetaWindow *window); diff --git a/src/core/window.c b/src/core/window.c index 87bb0a6fa..2f1e01c27 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -3043,7 +3043,8 @@ meta_window_can_tile_maximized (MetaWindow *window) } gboolean -meta_window_can_tile_side_by_side (MetaWindow *window) +meta_window_can_tile_side_by_side (MetaWindow *window, + int monitor_number) { MtkRectangle tile_area; MtkRectangle client_rect; @@ -3051,9 +3052,7 @@ meta_window_can_tile_side_by_side (MetaWindow *window) if (!meta_window_can_tile_maximized (window)) return FALSE; - meta_window_get_work_area_for_monitor (window, - window->monitor->number, - &tile_area); + meta_window_get_work_area_for_monitor (window, monitor_number, &tile_area); /* Do not allow tiling in portrait orientation */ if (tile_area.height > tile_area.width)