Skip to content

Commit 32b93ef

Browse files
Ronan Pigottemersion
Ronan Pigott
authored andcommitted
xdg_shell: allow views to change geometry anytime
Currently, when sway sends a configure with some geometry and the client responds with a different geometry in a commit that acks that configure, sway ignores the new size. Sway applies the surface geometry it had requested to the container, not what was actually committed, in the following transaction. This change allows any client commit to change its surface geometry, even if it is a response to a configure event.
1 parent f1afef5 commit 32b93ef

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

sway/desktop/xdg_shell.c

+18-19
Original file line numberDiff line numberDiff line change
@@ -284,28 +284,27 @@ static void handle_commit(struct wl_listener *listener, void *data) {
284284
struct sway_view *view = &xdg_shell_view->view;
285285
struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface;
286286

287+
struct wlr_box new_geo;
288+
wlr_xdg_surface_get_geometry(xdg_surface, &new_geo);
289+
bool new_size = new_geo.width != view->geometry.width ||
290+
new_geo.height != view->geometry.height ||
291+
new_geo.x != view->geometry.x ||
292+
new_geo.y != view->geometry.y;
293+
294+
if (new_size) {
295+
// The view has unexpectedly sent a new size
296+
desktop_damage_view(view);
297+
view_update_size(view, new_geo.width, new_geo.height);
298+
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
299+
desktop_damage_view(view);
300+
transaction_commit_dirty();
301+
}
302+
287303
if (view->container->node.instruction) {
288-
wlr_xdg_surface_get_geometry(xdg_surface, &view->geometry);
289304
transaction_notify_view_ready_by_serial(view,
290305
xdg_surface->configure_serial);
291-
} else {
292-
struct wlr_box new_geo;
293-
wlr_xdg_surface_get_geometry(xdg_surface, &new_geo);
294-
295-
if ((new_geo.width != view->geometry.width ||
296-
new_geo.height != view->geometry.height ||
297-
new_geo.x != view->geometry.x ||
298-
new_geo.y != view->geometry.y)) {
299-
// The view has unexpectedly sent a new size
300-
desktop_damage_view(view);
301-
view_update_size(view, new_geo.width, new_geo.height);
302-
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
303-
desktop_damage_view(view);
304-
transaction_commit_dirty();
305-
transaction_notify_view_ready_immediately(view);
306-
} else {
307-
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
308-
}
306+
} else if (new_size) {
307+
transaction_notify_view_ready_immediately(view);
309308
}
310309

311310
view_damage_from(view);

0 commit comments

Comments
 (0)