Skip to content

xdg_shell: handle_commit() could receive new geometry of size outside of the toplevel set boundaries (#9130) - #9133

Open
dawsers wants to merge 2 commits into
swaywm:masterfrom
dawsers:commit-respect-boundaries
Open

xdg_shell: handle_commit() could receive new geometry of size outside of the toplevel set boundaries (#9130)#9133
dawsers wants to merge 2 commits into
swaywm:masterfrom
dawsers:commit-respect-boundaries

Conversation

@dawsers

@dawsers dawsers commented Apr 27, 2026

Copy link
Copy Markdown

I don't know if this PR can have unintended consequences, but it fixes #9130

I think this is a bug in Qt, because they set the minimum size and then commit a surface with smaller geometry than the minimum size, but using this workaround that I think should be valid in general, we can "fix" it.

The client was setting a minimum size for the toplevel, and then committing a geometry with a smaller size. handle_commit() was seeing the new size and calling wlr_xdg_toplevel_set_size() that was sending a new configure with the smaller size. This was creating a loop where the client would alternate sending commits with the smaller and the bigger size, resulting in flickering of the window.

@dawsers

dawsers commented Apr 28, 2026

Copy link
Copy Markdown
Author

Another option would be to add the check to wlroots, in uint32_t wlr_xdg_toplevel_set_size(struct wlr_xdg_toplevel *toplevel, int32_t width, int32_t height), something like:

uint32_t wlr_xdg_toplevel_set_size(struct wlr_xdg_toplevel *toplevel,
		int32_t width, int32_t height) {
	assert(width >= 0 && height >= 0);
	if ((toplevel->pending.min_width > 0 && width < toplevel->pending.min_width) ||
		(toplevel->pending.min_height > 0 && height < toplevel->pending.min_height) ||
		(toplevel->pending.max_width > 0 && width > toplevel->pending.max_width) ||
		(toplevel->pending.max_height > 0 && height > toplevel->pending.max_height)) {
		return 0;
	}
	toplevel->scheduled.width = width;
	toplevel->scheduled.height = height;
	return wlr_xdg_surface_schedule_configure(toplevel->base);
}

@emersion emersion left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new_geo comes from the client, so it sounds surprising to have it send a size which doesn't comply with its own constraints…

@dawsers

dawsers commented May 24, 2026

Copy link
Copy Markdown
Author

I agree it's definitely a bug in the client, but the Qt Print dialog is used extensively, and the flicker happens every time, even with a simple application like I wrote for the bug report (#9130). So I thought the check wouldn't hurt while at the same time it would fix that annoyance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Qt Applications: clicking a QPrintDialog's Options button causes the window to flicker in a loop of resizes

2 participants