wl_subsurface vs xdg_popup?

Jonas Ådahl jadahl at gmail.com
Tue Mar 19 10:01:18 UTC 2024


On Thu, Mar 07, 2024 at 04:31:47PM -0500, Shawn W wrote:
> I've been looking at the protocol docs on http://wayland.app and something that's stood out to me is wl_subsurface and xdg_popup. If I want a pop up menu, which one should I go for? I would guess xdg_popup, but it seems like some compositors may not support repositioning if they don't support version 3 of the interface, and positioning a popup seems a little complicated. Then I look at wl_subsurface, and unless I'm misunderstanding it, it seems like it could also be used for generating popups, and is required for compositors to support, but it's not clear to me whether the compositor will actually show a wl_subsurface, since it wouldn't show a regular wl_surface. Would someone be able to clarify the difference between these?

Subsurfaces should in general be used for constructing a part of your
"window", and not for auxiliary windows, like popup menus and tooltips.
The reason for this is that unlike subsurfaces, popups have necessary
grab semantics that is usually needed (click outside to to dismiss,
etc), as well as logic to allow it to be positioned within e.g the work
area, using xdg_positioner rules.

I suggest allowing repositioning your popups only when the compositor
support it, and in other, unmap it and map a new one at a new position,
if you need to.


Jonas


More information about the wayland-devel mailing list