mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-02-10 04:27:51 -05:00
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:
parent
0e9c6ddefa
commit
44475dc062
4 changed files with 388 additions and 0 deletions
91
include/wlr/types/wlr_xdg_toplevel_drag_v1.h
Normal file
91
include/wlr/types/wlr_xdg_toplevel_drag_v1.h
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* This an unstable interface of wlroots. No guarantees are made regarding the
|
||||
* future consistency of this API.
|
||||
*/
|
||||
#ifndef WLR_USE_UNSTABLE
|
||||
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
||||
#endif
|
||||
|
||||
#ifndef WLR_TYPES_WLR_XDG_TOPLEVEL_DRAG_V1_H
|
||||
#define WLR_TYPES_WLR_XDG_TOPLEVEL_DRAG_V1_H
|
||||
|
||||
#include <wayland-server-core.h>
|
||||
|
||||
struct wlr_xdg_toplevel;
|
||||
struct wlr_data_source;
|
||||
|
||||
struct wlr_xdg_toplevel_drag_v1 {
|
||||
struct wl_resource *resource;
|
||||
struct wlr_xdg_toplevel_drag_manager_v1 *manager;
|
||||
struct wlr_data_source *data_source;
|
||||
|
||||
struct wlr_xdg_toplevel *toplevel; // NULL if none attached
|
||||
int32_t x_offset, y_offset;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
struct {
|
||||
struct wl_list link; // wlr_xdg_toplevel_drag_manager_v1.drags
|
||||
bool started, ended;
|
||||
|
||||
struct wl_listener data_source_destroy;
|
||||
struct wl_listener toplevel_unmap;
|
||||
struct wl_listener toplevel_surface_destroy;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
struct wlr_xdg_toplevel_drag_manager_v1 {
|
||||
struct wl_global *global;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
struct wl_signal new_toplevel_drag; // struct wlr_xdg_toplevel_drag_v1
|
||||
} events;
|
||||
|
||||
struct {
|
||||
struct wl_list drags; // wlr_xdg_toplevel_drag_v1.link
|
||||
struct wl_listener display_destroy;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
struct wlr_xdg_toplevel_drag_manager_v1 *wlr_xdg_toplevel_drag_manager_v1_create(
|
||||
struct wl_display *display, uint32_t version);
|
||||
|
||||
/**
|
||||
* Get a struct wlr_xdg_toplevel_drag_v1 from a struct wlr_data_source.
|
||||
*
|
||||
* Returns NULL if there's no xdg_toplevel_drag_v1 associated with the data source.
|
||||
*/
|
||||
struct wlr_xdg_toplevel_drag_v1 *wlr_xdg_toplevel_drag_v1_from_wlr_data_source(
|
||||
struct wlr_xdg_toplevel_drag_manager_v1 *manager,
|
||||
struct wlr_data_source *source);
|
||||
|
||||
/**
|
||||
* Get a struct wlr_xdg_toplevel_drag_v1 from a struct wlr_xdg_toplevel.
|
||||
*
|
||||
* Returns NULL if there's no xdg_toplevel_drag_v1 with the given toplevel attached.
|
||||
*/
|
||||
struct wlr_xdg_toplevel_drag_v1 *wlr_xdg_toplevel_drag_v1_from_wlr_xdg_toplevel(
|
||||
struct wlr_xdg_toplevel_drag_manager_v1 *manager,
|
||||
struct wlr_xdg_toplevel *toplevel);
|
||||
|
||||
/**
|
||||
* Notify the xdg_toplevel_drag that the underlying drag has started.
|
||||
*
|
||||
* This should be called by the compositor when wlr_seat starts a drag
|
||||
* that has an associated xdg_toplevel_drag.
|
||||
*/
|
||||
void wlr_xdg_toplevel_drag_v1_start(struct wlr_xdg_toplevel_drag_v1 *drag);
|
||||
|
||||
/**
|
||||
* Notify the xdg_toplevel_drag that the underlying drag has ended.
|
||||
*
|
||||
* This should be called by the compositor when the wlr_drag is destroyed
|
||||
* (i.e., after drop or cancel). After this call, the client may safely
|
||||
* destroy the xdg_toplevel_drag resource.
|
||||
*/
|
||||
void wlr_xdg_toplevel_drag_v1_finish(struct wlr_xdg_toplevel_drag_v1 *drag);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue