Skip to content

Commit 33d03ce

Browse files
CollinBartlamCollin Bartlam
authored andcommitted
window.c: update saved_rect to target monitor work area on tiling (#714)
Co-authored-by: Collin Bartlam <[email protected]>
1 parent b319954 commit 33d03ce

File tree

1 file changed

+34
-12
lines changed

1 file changed

+34
-12
lines changed

src/core/window.c

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3541,21 +3541,43 @@ meta_window_tile (MetaWindow *window,
35413541
directions = META_MAXIMIZE_VERTICAL;
35423542

35433543

3544-
GdkRectangle *maybe_saved_rect = NULL;
3544+
MetaRectangle existing_rect, work_area, tile_area;
3545+
meta_window_get_frame_rect(window, &existing_rect);
3546+
meta_window_get_work_area_for_monitor(window, window->tile_monitor_number, &work_area);
3547+
tile_area = existing_rect;
35453548

3546-
if (window->saved_tile_mode == META_TILE_NONE && window->display->grab_op != META_GRAB_OP_NONE)
3547-
{
3548-
// If we let it save the current rect when initially tiling, the rect position
3549-
// may end up on a different monitor (depending on where the grab anchor is positioned).
3550-
maybe_saved_rect = &window->display->grab_initial_window_pos;
3551-
}
3552-
else
3553-
if (window->saved_tile_mode != META_TILE_NONE)
3549+
switch (tile_mode)
35543550
{
3555-
maybe_saved_rect = &window->saved_rect;
3556-
}
3551+
case META_TILE_LEFT:
3552+
tile_area.x = work_area.x;
3553+
tile_area.y = work_area.y;
3554+
break;
3555+
3556+
case META_TILE_RIGHT:
3557+
tile_area.x = work_area.x + work_area.width - existing_rect.width;
3558+
tile_area.y = work_area.y;
3559+
break;
3560+
3561+
case META_TILE_TOP:
3562+
tile_area.x = work_area.x;
3563+
tile_area.y = work_area.y;
3564+
break;
3565+
3566+
case META_TILE_BOTTOM:
3567+
tile_area.x = work_area.x;
3568+
tile_area.y = work_area.y + work_area.height - existing_rect.height;
3569+
break;
3570+
3571+
default:
3572+
tile_area.x = work_area.x + (work_area.width - existing_rect.width) / 2;
3573+
tile_area.y = work_area.y + (work_area.height - existing_rect.height) / 2;
3574+
break;
3575+
}
3576+
3577+
window->saved_rect = tile_area;
3578+
window->unconstrained_rect = tile_area;
35573579

3558-
meta_window_maximize_internal (window, directions, maybe_saved_rect);
3580+
meta_window_maximize_internal (window, directions, &window->saved_rect);
35593581
meta_display_update_tile_preview (window->display, FALSE);
35603582

35613583
if ((!window->htile_match || window->htile_match != window->display->grab_window) &&

0 commit comments

Comments
 (0)