shell: Replace set_margin with set_window_geometry
Currently, there is a fun flicker when toggling maximization or fullscreen on a window in mutter or more sophisicated compositors and WMs. What happens is that the client want so go maximized, so we calculate the size that we want the window to resize to (640x480), and then add on its margins to find the buffer size (+10 = 660x500), and then send out a configure event for that size. The client renders to that size, realizes that it's maximized, and then says "oh hey, my margins are actually 0 now!", and so the compositor has to send out another configure event. In order to fix this, make the the configure request correspond to the window geometry we'd like the window to be at. At the same time, replace set_margin with set_window_geometry, where we specify a rect rather than a border around the window.
This commit is contained in:
committed by
Jason Ekstrand
parent
bd65e50875
commit
ccf48fb4f9
+22
-13
@@ -3894,24 +3894,33 @@ window_sync_parent(struct window *window)
|
||||
}
|
||||
|
||||
static void
|
||||
window_sync_margin(struct window *window)
|
||||
window_get_geometry(struct window *window, struct rectangle *geometry)
|
||||
{
|
||||
int margin;
|
||||
if (window->frame)
|
||||
frame_input_rect(window->frame->frame,
|
||||
&geometry->x,
|
||||
&geometry->y,
|
||||
&geometry->width,
|
||||
&geometry->height);
|
||||
else
|
||||
window_get_allocation(window, geometry);
|
||||
}
|
||||
|
||||
static void
|
||||
window_sync_geometry(struct window *window)
|
||||
{
|
||||
struct rectangle geometry;
|
||||
|
||||
if (!window->xdg_surface)
|
||||
return;
|
||||
|
||||
if (!window->frame)
|
||||
return;
|
||||
window_get_geometry(window, &geometry);
|
||||
|
||||
margin = frame_get_shadow_margin(window->frame->frame);
|
||||
|
||||
/* Shadow size is the same on every side. */
|
||||
xdg_surface_set_margin(window->xdg_surface,
|
||||
margin,
|
||||
margin,
|
||||
margin,
|
||||
margin);
|
||||
xdg_surface_set_window_geometry(window->xdg_surface,
|
||||
geometry.x,
|
||||
geometry.y,
|
||||
geometry.width,
|
||||
geometry.height);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3922,7 +3931,7 @@ window_flush(struct window *window)
|
||||
if (!window->custom) {
|
||||
if (window->xdg_surface) {
|
||||
window_sync_parent(window);
|
||||
window_sync_margin(window);
|
||||
window_sync_geometry(window);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user