1<?xml version="1.0" encoding="UTF-8"?>
2<protocol name="extended_drag_unstable_v1">
3
4  <copyright>
5    Copyright 2020 The Chromium Authors
6
7    Permission is hereby granted, free of charge, to any person obtaining a
8    copy of this software and associated documentation files (the "Software"),
9    to deal in the Software without restriction, including without limitation
10    the rights to use, copy, modify, merge, publish, distribute, sublicense,
11    and/or sell copies of the Software, and to permit persons to whom the
12    Software is furnished to do so, subject to the following conditions:
13
14    The above copyright notice and this permission notice (including the next
15    paragraph) shall be included in all copies or substantial portions of the
16    Software.
17
18    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24    DEALINGS IN THE SOFTWARE.
25  </copyright>
26
27  <interface name="zcr_extended_drag_v1" version="1">
28    <description summary="extends DnD protocol with some advanced features">
29      The zcr_extended_drag_v1 interface extends the Wayland drag-and-drop with
30      features unsurpported by the core protocol. Such as, making toplevel shell
31      surfaces "draggable", as well as making them "snappable" into and out of
32      other surfaces as they are dragged around.
33
34      A common use case for this is a Chromium-like tab/window dragging UX,
35      where the user is able to drag a tab (or any other kind of UI piece) out
36      of its original window, into a new surface anchored to the pointer cursor,
37      similar to a regular drag icon but with enhanced and more configurable
38      capabilities.
39
40      Warning! The protocol described in this file is experimental and
41      backward incompatible changes may be made. Backward compatible changes
42      may be added together with the corresponding uinterface version bump.
43      Backward incompatible changes are done by bumping the version number in
44      the protocol and uinterface names and resetting the interface version.
45      Once the protocol is to be declared stable, the 'z' prefix and the
46      version number in the protocol and interface names are removed and the
47      interface version number is reset.
48    </description>
49
50    <enum name="options" bitfield="true">
51      <description summary="extended drag configuration flags.">
52        Bitmask flags that can be used to configure how the drag session will
53        operate. By default no additional option is set.
54
55        Source client might set allow_swallow option to tell the compositor that
56        the dragged UI item can be snapped out and into other surfaces
57        (swallowed/unswallowed), eg: Chromium's tab dragging UX.
58
59        allow_drop_no_target controls how source and destination clients are
60        notified when the drop happens, if it is set the DnD operation is
61        considered successfully finished regardless the drop location (eg:
62        outside any shell surface or there is no target that can accept it).
63
64        lock_cursor might be used to keep the cursor shape locked during the
65        extended drag session, regardless current the mime types, dnd action
66        negotiation status.
67      </description>
68      <entry name="default" value="0"/>
69      <entry name="allow_swallow" value="1"/>
70      <entry name="allow_drop_no_target" value="2"/>
71      <entry name="lock_cursor" value="4"/>
72    </enum>
73
74    <request name="get_extended_drag_source">
75      <description summary="get an extended_drag_source for a wl_data_source">
76        Create an extended drag source object. See zcr_extended_drag_source_v1
77        interface for details.
78      </description>
79      <arg name="id" type="new_id" interface="zcr_extended_drag_source_v1"/>
80      <arg name="data_source" type="object" interface="wl_data_source"/>
81      <arg name="options" type="uint" enum="zcr_extended_drag_v1.options"/>
82    </request>
83
84    <request name="get_extended_drag_offer">
85      <description summary="get an extended_drag_offer for a wl_data_offer">
86        Create an extended drag offer object. See zcr_extended_drag_offer_v1
87        interface for details.
88      </description>
89      <arg name="id" type="new_id" interface="zcr_extended_drag_offer_v1"/>
90      <arg name="data_offer" type="object" interface="wl_data_offer"/>
91    </request>
92  </interface>
93
94  <interface name="zcr_extended_drag_source_v1" version="1">
95    <description summary="extensions for the standard drag data source">
96      The zcr_extended_drag_source_v1 interface extends the wl_data_source with
97      features unsurpported by the standard drag-and-drop protocol.
98    </description>
99
100    <request name="destroy" type="destructor">
101      <description summary="destroy the extended drag source object"/>
102    </request>
103
104    <request name="drag">
105      <description summary="Update the dragged surface">
106        Update the dragged surface. If null is passed, the dragged surface gets
107        unset, making it to not being moved anymore under the pointer cursor.
108        Otherwise, it will be set as the dragged surface, making it to be visually
109        anchored to the pointer cursor. surface is expected to have a toplevel
110        shell surface role assigned, which allows it to be dropped smoothly into
111        an arbitrary location of the shell, so turning it instantly into a
112        regular toplevel window, which not possible with the standard DND
113        protocol.
114
115        x and y offsets are described in surface-local coordinates, with no
116        scale applied, that determine how the surface must be positioned
117        relative to the cursor location, similar to drag icon offsets in
118        standard DND operations.
119      </description>
120      <arg name="surface" type="object" interface="wl_surface" allow-null="true" summary="drag icon surface"/>
121      <arg name="x_offset" type="int" summary="dragged surface x offset"/>
122      <arg name="y_offset" type="int" summary="dragged surface y offset"/>
123    </request>
124
125    <event name="swallow">
126      <description summary="the receiving client requested to swallow the drag.">
127        The receiving client has requested to swallow the dragged surface.
128        Which, in a drag operation involving 2 or more clients, can be used to
129        negotiate when the dragged surface is incorporated (aka: merged) into
130        its UI. See zcr_extended_drag_offer_v1::swallow request for more
131        details.
132      </description>
133      <arg name="mime_type" type="string" summary="mime type to be swallowed by the client"/>
134    </event>
135
136    <event name="unswallow">
137      <description summary="the receiving client requested to unswallow the drag.">
138        The receiving client has requested to unswallow the dragged surface.
139        Which, in a drag operation involving more than a single client, can be
140        used to negotiate when the dragged surface is snapped out of the
141        receiving client's UI.
142
143        X and Y offsets are expressed in surface-local coordinates, with no
144        scale applied, and describe how the surface must be positioned relative
145        to the cursor location, similar to drag icon offsets in standard DND
146        operations. Note that these coordinates are local to the unswallowed
147        surface, created and owned by the source client, so it can be used
148        rightaway to call drag(surface, x_offset, y_offset) in response to
149        receiving client's request.
150      </description>
151      <arg name="mime_type" type="string" allow-null="true" summary="mime type accepted by the client"/>
152      <arg name="x_offset" type="int" summary="dragged surface x offset"/>
153      <arg name="y_offset" type="int" summary="dragged surface y offset"/>
154    </event>
155  </interface>
156
157  <interface name="zcr_extended_drag_offer_v1" version="1">
158    <description summary="extensions for the standard drag data offer.">
159      The zcr_extended_drag_offer_v1 interface extends the wl_data_offer with
160      features unsurpported by the standard drag-and-drop protocol.
161    </description>
162
163    <request name="destroy" type="destructor">
164      <description summary="destroy the extended drag offer object"/>
165    </request>
166
167    <request name="swallow">
168      <description summary="Requests the drag source to swallow the drag.">
169        Requests the drag source to swallow the dragged surface. This means the
170        receiving client accepts and will incorporate the dragged surface into
171        its UI. For example, a browser tab is dragged and snapped to an icon\
172        grid.
173      </description>
174      <arg name="serial" type="uint" summary="serial number of the swallow request"/>
175      <arg name="mime_type" type="string" allow-null="true" summary="mime type being swallowed"/>
176    </request>
177
178    <request name="unswallow">
179      <description summary="Requests the drag source to unswallow the drag.">
180        Requests the drag source to unswallow the dragged surface. Which means
181        that the receiving client wants to undo a previously swallowed dragged
182        surface, i.e: detach it from its UI.
183
184        X and Y offsets are expressed in surface-local coordinates, with no
185        scale applied and describe how the surface must be positioned relative
186        to the cursor location, similar to drag icon offsets in standard DND
187        operations. Note that these coordinates are local to the currently
188        focused surface, owned by the receiving client, which may differ from
189        corresponding offsets at source side (which owns the unswallowed
190        surface), for instance, when the receiving surface is on a wl_output
191        with different scale value. Compositor handles such conversion before
192        delivering the zcr_extended_drag_source_v1::swallow event counterpart
193        to the source client.
194      </description>
195      <arg name="serial" type="uint" summary="serial number of the unswallow request"/>
196      <arg name="mime_type" type="string" summary="mime type being unswallowed"/>
197      <arg name="x_offset" type="int" summary="dragged surface x offset"/>
198      <arg name="y_offset" type="int" summary="dragged surface y offset"/>
199    </request>
200  </interface>
201</protocol>
202