types: implement xdg-toplevel-drag-v1 protocol

This protocol allows clients to attach a toplevel window to an ongoing
drag-and-drop operation, enabling features like browser tab tear-off.

The attached toplevel follows the cursor during the drag, moving as if
xdg_toplevel.move was called. The window is automatically detached when
unmapped or when its surface is destroyed.

Implementation details:

- Listen to both unmap and destroy events on the toplevel surface to
  properly clean up when the surface is destroyed while still mapped

- Emit new_toplevel_drag event when a drag is created, allowing
  compositors to track attached toplevels

- The toplevel pointer becomes NULL when detached, which compositors
  must handle during motion events.
This commit is contained in:
Ryan Walklin 2025-12-12 16:46:19 +13:00
parent 0e9c6ddefa
commit 44475dc062
4 changed files with 388 additions and 0 deletions

View file

@ -44,6 +44,7 @@ protocols = {
'xdg-dialog-v1': wl_protocol_dir / 'staging/xdg-dialog/xdg-dialog-v1.xml',
'xdg-system-bell-v1': wl_protocol_dir / 'staging/xdg-system-bell/xdg-system-bell-v1.xml',
'xdg-toplevel-icon-v1': wl_protocol_dir / 'staging/xdg-toplevel-icon/xdg-toplevel-icon-v1.xml',
'xdg-toplevel-drag-v1': wl_protocol_dir / 'staging/xdg-toplevel-drag/xdg-toplevel-drag-v1.xml',
'xdg-toplevel-tag-v1': wl_protocol_dir / 'staging/xdg-toplevel-tag/xdg-toplevel-tag-v1.xml',
'xwayland-shell-v1': wl_protocol_dir / 'staging/xwayland-shell/xwayland-shell-v1.xml',
'tearing-control-v1': wl_protocol_dir / 'staging/tearing-control/tearing-control-v1.xml',