Skip to content

Commit a8068f3

Browse files
committed
tiling: Skip the resize effect for tiled windows during user grabs.
meta_window_tile ends up being called during each update_resize, but the incremental changes don't need to be animated. This fixes a large memory leak when resizing tiled, matched windows, and should improve performance during these resizes.
1 parent 508a213 commit a8068f3

File tree

4 files changed

+25
-19
lines changed

4 files changed

+25
-19
lines changed

src/core/keybindings.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3510,7 +3510,7 @@ handle_tile_action (MetaDisplay *display,
35103510
else if (can_tile (window, new_mode))
35113511
{
35123512
window->tile_monitor_number = window->monitor->number;
3513-
meta_window_tile (window, new_mode);
3513+
meta_window_tile (window, new_mode, FALSE);
35143514
}
35153515
}
35163516

src/core/window-private.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,8 @@ void meta_window_queue (MetaWindow *window,
685685
guint queuebits);
686686
META_EXPORT_TEST
687687
void meta_window_tile (MetaWindow *window,
688-
MetaTileMode mode);
688+
MetaTileMode mode,
689+
gboolean in_update_resize);
689690
MetaTileMode meta_window_get_tile_mode (MetaWindow *window);
690691
void meta_window_restore_tile (MetaWindow *window,
691692
MetaTileMode mode,

src/core/window.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3233,7 +3233,8 @@ meta_window_get_tile_fractions (MetaWindow *window,
32333233
static void
32343234
meta_window_update_tile_fractions (MetaWindow *window,
32353235
int new_w,
3236-
int new_h)
3236+
int new_h,
3237+
gboolean in_update_resize)
32373238
{
32383239
MetaWindow *vtile_match = window->vtile_match;
32393240
MetaWindow *htile_match = window->htile_match;
@@ -3249,10 +3250,10 @@ meta_window_update_tile_fractions (MetaWindow *window,
32493250
window->tile_vfraction = (double)new_h / work_area.height;
32503251

32513252
if (htile_match && window->display->grab_window == window)
3252-
meta_window_tile (htile_match, htile_match->tile_mode);
3253+
meta_window_tile (htile_match, htile_match->tile_mode, in_update_resize);
32533254

32543255
if (vtile_match && window->display->grab_window == window)
3255-
meta_window_tile (vtile_match, vtile_match->tile_mode);
3256+
meta_window_tile (vtile_match, vtile_match->tile_mode, in_update_resize);
32563257
}
32573258

32583259
static void
@@ -3402,10 +3403,10 @@ update_edge_constraints (MetaWindow *window)
34023403

34033404
void
34043405
meta_window_tile (MetaWindow *window,
3405-
MetaTileMode tile_mode)
3406+
MetaTileMode tile_mode,
3407+
gboolean in_update_resize)
34063408
{
34073409
MetaMaximizeFlags directions;
3408-
MetaRectangle old_frame_rect, old_buffer_rect;
34093410
/* Maximization constraints beat tiling constraints, so if the window
34103411
* is maximized, tiling won't have any effect unless we unmaximize it
34113412
* horizontally first; rather than calling meta_window_unmaximize(),
@@ -3451,12 +3452,16 @@ meta_window_tile (MetaWindow *window,
34513452
/* Setup the edge constraints */
34523453
update_edge_constraints (window);
34533454

3454-
meta_window_get_frame_rect (window, &old_frame_rect);
3455-
meta_window_get_buffer_rect (window, &old_buffer_rect);
3455+
if (!in_update_resize)
3456+
{
3457+
MetaRectangle old_frame_rect, old_buffer_rect;
34563458

3457-
meta_compositor_size_change_window (window->display->compositor, window,
3458-
META_SIZE_CHANGE_TILE,
3459-
&old_frame_rect, &old_buffer_rect);
3459+
meta_window_get_frame_rect (window, &old_frame_rect);
3460+
meta_window_get_buffer_rect (window, &old_buffer_rect);
3461+
meta_compositor_size_change_window (window->display->compositor, window,
3462+
META_SIZE_CHANGE_TILE,
3463+
&old_frame_rect, &old_buffer_rect);
3464+
}
34603465

34613466
meta_window_move_resize_internal (window,
34623467
(META_MOVE_RESIZE_MOVE_ACTION |
@@ -3481,8 +3486,8 @@ meta_window_restore_tile (MetaWindow *window,
34813486
int width,
34823487
int height)
34833488
{
3484-
meta_window_update_tile_fractions (window, width, height);
3485-
meta_window_tile (window, mode);
3489+
meta_window_update_tile_fractions (window, width, height, FALSE);
3490+
meta_window_tile (window, mode, FALSE);
34863491
}
34873492

34883493
static gboolean
@@ -4673,7 +4678,7 @@ meta_window_resize_frame_with_gravity (MetaWindow *window,
46734678
*/
46744679
if (window->display->grab_window == window)
46754680
adjust_size_for_tile_match (window, &w, &h);
4676-
meta_window_update_tile_fractions (window, w, h);
4681+
meta_window_update_tile_fractions (window, w, h, TRUE);
46774682
}
46784683

46794684
flags = (user_op ? META_MOVE_RESIZE_USER_ACTION : 0) | META_MOVE_RESIZE_RESIZE_ACTION;
@@ -6860,7 +6865,7 @@ end_grab_op (MetaWindow *window,
68606865
if (meta_grab_op_is_moving (window->display->grab_op))
68616866
{
68626867
if (window->display->preview_tile_mode != META_TILE_NONE)
6863-
meta_window_tile (window, window->display->preview_tile_mode);
6868+
meta_window_tile (window, window->display->preview_tile_mode, FALSE);
68646869
else
68656870
update_move (window,
68666871
modifiers & CLUTTER_SHIFT_MASK,

src/tests/monitor-unit-tests.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6113,7 +6113,7 @@ meta_test_monitor_wm_tiling (void)
61136113
g_error ("Failed to find the window: %s", error->message);
61146114
test_client_wait_for_window_shown (test_client, test_window);
61156115

6116-
meta_window_tile (test_window, META_TILE_MAXIMIZED);
6116+
meta_window_tile (test_window, META_TILE_MAXIMIZED, FALSE);
61176117
meta_window_move_to_monitor (test_window, 1);
61186118
check_test_client_state (test_client);
61196119

@@ -6144,14 +6144,14 @@ meta_test_monitor_wm_tiling (void)
61446144
emulate_hotplug (test_setup);
61456145

61466146
meta_window_move_to_monitor (test_window, 1);
6147-
meta_window_tile (test_window, META_TILE_NONE);
6147+
meta_window_tile (test_window, META_TILE_NONE, FALSE);
61486148

61496149
test_case.setup.n_outputs = 1;
61506150
test_setup = create_monitor_test_setup (&test_case,
61516151
MONITOR_TEST_FLAG_NO_STORED);
61526152
emulate_hotplug (test_setup);
61536153

6154-
meta_window_tile (test_window, META_TILE_MAXIMIZED);
6154+
meta_window_tile (test_window, META_TILE_MAXIMIZED, FALSE);
61556155

61566156
test_client_destroy (test_client);
61576157
}

0 commit comments

Comments
 (0)