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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3248>
This commit is contained in:
Florian Müllner 2023-09-06 12:24:00 +02:00 committed by Marge Bot
parent 493e799398
commit bc74d166dd
4 changed files with 8 additions and 8 deletions

View File

@ -1160,10 +1160,10 @@ update_move_maybe_tile (MetaWindowDrag *window_drag,
/* Check if the cursor is in a position which triggers tiling /* Check if the cursor is in a position which triggers tiling
* and set tile_mode accordingly. * 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)) x >= logical_monitor->rect.x && x < (work_area.x + shake_threshold))
window_drag->preview_tile_mode = META_TILE_LEFT; 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 >= work_area.x + work_area.width - shake_threshold &&
x < (logical_monitor->rect.x + logical_monitor->rect.width)) x < (logical_monitor->rect.x + logical_monitor->rect.width))
window_drag->preview_tile_mode = META_TILE_RIGHT; window_drag->preview_tile_mode = META_TILE_RIGHT;

View File

@ -2668,7 +2668,7 @@ handle_toggle_tiled (MetaDisplay *display,
{ {
meta_window_untile (window); 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; window->tile_monitor_number = window->monitor->number;
/* Maximization constraints beat tiling constraints, so if the window /* Maximization constraints beat tiling constraints, so if the window

View File

@ -778,7 +778,8 @@ void meta_window_update_for_monitors_changed (MetaWindow *window);
void meta_window_on_all_workspaces_changed (MetaWindow *window); void meta_window_on_all_workspaces_changed (MetaWindow *window);
gboolean meta_window_should_attach_to_parent (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); void meta_window_compute_tile_match (MetaWindow *window);

View File

@ -3043,7 +3043,8 @@ meta_window_can_tile_maximized (MetaWindow *window)
} }
gboolean 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 tile_area;
MtkRectangle client_rect; MtkRectangle client_rect;
@ -3051,9 +3052,7 @@ meta_window_can_tile_side_by_side (MetaWindow *window)
if (!meta_window_can_tile_maximized (window)) if (!meta_window_can_tile_maximized (window))
return FALSE; return FALSE;
meta_window_get_work_area_for_monitor (window, meta_window_get_work_area_for_monitor (window, monitor_number, &tile_area);
window->monitor->number,
&tile_area);
/* Do not allow tiling in portrait orientation */ /* Do not allow tiling in portrait orientation */
if (tile_area.height > tile_area.width) if (tile_area.height > tile_area.width)