xdg-shell: Turn the resizing heuristics into an explicit state
Currently, there's a race condition. When resizing from the left, and a client attaches a buffer after the resize ends, you suddenly see the buffer jump to the right, because the resize ended while multiple attaches were in-flight. Making resize a state can fix this, as the server can now know exactly when the resize ended, and whether a commit was before or after that place. We don't implement the correct tracking in this commit; that's left as an exercise to the reader. Additionally, clients like terminals might want to display resize popups to display the number of cells when in a resize. They can use the hint here to figure out whether they are resizing.
This commit is contained in:
committed by
Kristian Høgsberg
parent
ab2c108137
commit
5befdda84f
+20
-1
@@ -351,13 +351,27 @@ shell_grab_start(struct shell_grab *grab,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
shell_surface_state_changed(struct shell_surface *shsurf)
|
||||
{
|
||||
if (shell_surface_is_xdg_surface(shsurf)) {
|
||||
shsurf->client->send_configure(shsurf->surface,
|
||||
shsurf->surface->width,
|
||||
shsurf->surface->height);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
shell_grab_end(struct shell_grab *grab)
|
||||
{
|
||||
if (grab->shsurf) {
|
||||
wl_list_remove(&grab->shsurf_destroy_listener.link);
|
||||
grab->shsurf->grabbed = 0;
|
||||
grab->shsurf->resize_edges = 0;
|
||||
|
||||
if (grab->shsurf->resize_edges) {
|
||||
grab->shsurf->resize_edges = 0;
|
||||
shell_surface_state_changed(grab->shsurf);
|
||||
}
|
||||
}
|
||||
|
||||
weston_pointer_end_grab(grab->grab.pointer);
|
||||
@@ -1769,6 +1783,7 @@ surface_resize(struct shell_surface *shsurf,
|
||||
&resize->width, &resize->height);
|
||||
|
||||
shsurf->resize_edges = edges;
|
||||
shell_surface_state_changed(shsurf);
|
||||
shell_grab_start(&resize->base, &resize_grab_interface, shsurf,
|
||||
seat->pointer, edges);
|
||||
|
||||
@@ -3538,6 +3553,10 @@ xdg_send_configure(struct weston_surface *surface,
|
||||
s = wl_array_add(&states, sizeof *s);
|
||||
*s = XDG_SURFACE_STATE_MAXIMIZED;
|
||||
}
|
||||
if (shsurf->resize_edges != 0) {
|
||||
s = wl_array_add(&states, sizeof *s);
|
||||
*s = XDG_SURFACE_STATE_RESIZING;
|
||||
}
|
||||
|
||||
serial = wl_display_next_serial(shsurf->surface->compositor->wl_display);
|
||||
xdg_surface_send_configure(shsurf->resource, width, height, &states, serial);
|
||||
|
||||
Reference in New Issue
Block a user