Commit 92544dcf authored by Nick Diego Yamane's avatar Nick Diego Yamane Committed by Commit Bot

exo: Add extended-drag extension and its stub implementation

TL;DR:

Wayland Protocol needs to be extended to make it possible to properly
support full Chromium's tab dragging experience. Further details in the
Design document [1]. This is the first of a patch series which
implements extended-drag extension in Exo compositor, adding the
protocol descriptor XML file, boilerplate code as well as a stub
implementation of it. Follow-up CLs will incrementally implement the
extension features and start using it in Chromium Ozone/Wayland
(client-side).

-----------------------------------------------------------------------
An overview of how this protocol is aimed to be used in a tabdrag-like
scenario, but in generic terms, is outlined below:

1. An UI item (eg: a tab in a tab bar) starts to be dragged within shell
surface A owned by source client S. At some point, it gets far enough
from its original location and S then starts a Wayland "extended drag"
session, which protocol-wise requires to:

1.1. Create a wl_data_source, set one (or more) mime type and the
supported dnd actions;

1.2. Create a zcr_extended_drag_source for the newly created drag
source. Here it is possible to set a few options, such as:
  - ALLOW_SWALLOW: determines that the dragged item can be attached (or
  incorporated, also referred to as "swallow" in this protocol) to
  another surface, including use cases such as Chrome's tab drag.
  - ALLOW_DROP_NO_TARGET: In the standard DND protocol, dropping
  something outside shell surfaces lead to a wl_data_source::cancel,
  which is problematic in use cases such as tab drag, preventing us from
  detecting when it was really cancelled, e.g: ESC pressed.
  - LOCK_CURSOR: Keep the cursor shape unchanged during the whole
  session. Ultimately, having an extended drag source attached to the
  wl_data_source used to wl_data_device::start_drag instructs the
  compositor to run the drag session in the "extended mode".

1.3 Start the drag session as usual (i.e: wl_data_source::start_drag),
with a null drag icon surface. Assuming that we're still in attached
mode for now. In addition, from now on, client S must start watching for
wl_data_device::{enter,leave,motion} events in order to be able to
detect the next actions and state transitions as the user drags the UI
item around.

1.4 Store the (x_offset, y_offset) location where the drag started in S
and keep them synced to the values received in wl_data_device::motion()
events.

2. Once the drag gets far enough from the original UI item's container
(ie: tab bar), it's time to detach (or unswallow) it from surface A. To
achieve it, client S must:

2.1. Create a new wl_surface B + its corresponding shell surface, e.g: a
toplevel xdg surface where a new detached browser window will rendered
to in Chrome's tab drag use case;

2.2. Issue a zcr_extended_drag_source::drag(B, x_offset, y_offset)
request, which tells the compositor (in advance) that B must be set as
the extended-drag surface, using x and y offsets to translate it from
the current pointer location;

2.3. Map surface B (configure, attach buffer, etc) as usual. After this
B's shell surface should show up tied to the mouse pointer and the
compositor is supposed to take care of it, putting it in a special state
where, for example, it does not receive events, etc, acting just like a
standard DND "drag icon". At this point, the "unswallow" operation is
done and the extended-drag session enters in detached state.

3. Supposing the drop happens while in detached state, there are 2
possible flows, which depend on whether ALLOW_DROP_NO_TARGET config is
set or not (see 1.2). If it is set, wl_data_source::dnd_finished event
is sent to the source client S, otherwise wl_data_source::cancelled is
sent.

4. Otherwise, if before dropping, the pointer enters surface C, owned by
client T. T receives a wl_data_offer O through wl_data_device::offer
event as usual, to which it can attach a zcr_extended_drag_offer XO to
it by issuing zcr_extended_drag::get_extended_drag_offer(O). Target
client T, then starts monitoring wl_data_device::motion events, so that
it can trigger a swallow based on where the pointer is. If B is dragged
over a region that leads to a swallow, T must:

4.1 Issue a zcr_extended_drag_offer::swallow(serial, mime) request,
asking source client S to incorporate the dragged item into its UI.
S then receives a zcr_extended_drag_source::swallow(mime) event and
it can accept it by calling zcr_extended_drag_source::drag(null, 0, 0),
so client T can finally render it as part of its UI. At this point, the
session is back to a state similar to 1.4. So, similarly to 2, once the
drag gets far enough, T might want to unswallow (aka: detach) the UI
item. In order to do so it must:

4.1.1 Call unswallow(serial, mime, x_offset, y_offset) on the
extended-drag offer XO (created at step 4), whereas the offsets tell how
the dragged surface must be positioned related to the pointer location.
Client S will then receive a zcr_extended_drag_source::unswallow(mime,
x_offset, y_offset) event so that it can create and map a new surface D
and issue a zcr_extended_drag_source::drag(D, x_offset, y_offset), same
as in step 2.3, making surface D to show up under the pointer. At target
side, T can then re-render its UI without the dragged item. This
finishes the unswallow (or detaching) operation, transitioning the
session back to "detached" state.

[1] https://docs.google.com/document/d/1s6OwTi_WC-pS21WLGQYI39yw2m42ZlVolUXBclljXB4/edit?usp=sharing

Bug: 1099418
Change-Id: I8d876e96e45717c625c1d1bdcc269b100524cbc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2307653
Commit-Queue: Nick Yamane <nickdiego@igalia.com>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811055}
parent c913d715
...@@ -33,6 +33,10 @@ static_library("exo") { ...@@ -33,6 +33,10 @@ static_library("exo") {
"display.h", "display.h",
"drag_drop_operation.cc", "drag_drop_operation.cc",
"drag_drop_operation.h", "drag_drop_operation.h",
"extended_drag_offer.cc",
"extended_drag_offer.h",
"extended_drag_source.cc",
"extended_drag_source.h",
"frame_sink_resource_manager.cc", "frame_sink_resource_manager.cc",
"frame_sink_resource_manager.h", "frame_sink_resource_manager.h",
"input_trace.h", "input_trace.h",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/exo/extended_drag_offer.h"
#include <cstdint>
#include <string>
#include "base/check_op.h"
#include "base/notreached.h"
#include "components/exo/data_offer.h"
#include "components/exo/data_offer_observer.h"
#include "ui/gfx/geometry/vector2d.h"
namespace exo {
ExtendedDragOffer::ExtendedDragOffer(DataOffer* offer, Delegate* delegate)
: offer_(offer), delegate_(delegate) {
DCHECK(offer_);
DCHECK(delegate_);
}
ExtendedDragOffer::~ExtendedDragOffer() {
delegate_->OnDataOfferDestroying();
}
// TODO(crbug.com/1099418): Implement extended-drag Wayland extension.
void ExtendedDragOffer::Swallow(uint32_t serial, const std::string& mime_type) {
NOTIMPLEMENTED();
}
// TODO(crbug.com/1099418): Implement extended-drag Wayland extension.
void ExtendedDragOffer::Unswallow(uint32_t serial,
const std::string& mime_type,
const gfx::Vector2d& offset) {
NOTIMPLEMENTED();
}
void ExtendedDragOffer::OnDataOfferDestroying(DataOffer* offer) {
DCHECK_EQ(offer, offer_);
offer_ = nullptr;
}
} // namespace exo
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_EXO_EXTENDED_DRAG_OFFER_H_
#define COMPONENTS_EXO_EXTENDED_DRAG_OFFER_H_
#include <cstdint>
#include <string>
#include "components/exo/data_offer_observer.h"
namespace gfx {
class Vector2d;
}
namespace exo {
class DataOffer;
class ExtendedDragOffer : public DataOfferObserver {
public:
class Delegate {
public:
virtual void OnDataOfferDestroying() = 0;
protected:
virtual ~Delegate() = default;
};
ExtendedDragOffer(DataOffer* offer, Delegate* delegate);
ExtendedDragOffer(const ExtendedDragOffer&) = delete;
ExtendedDragOffer& operator=(const ExtendedDragOffer&) = delete;
~ExtendedDragOffer() override;
void Swallow(uint32_t serial, const std::string& mime_type);
void Unswallow(uint32_t serial,
const std::string& mime_type,
const gfx::Vector2d& offset);
private:
// DataOfferObserver:
void OnDataOfferDestroying(DataOffer* offer) override;
DataOffer* offer_ = nullptr;
// Created and destroyed at wayland/zcr_extended_drag.cc and its lifetime is
// tied to the zcr_extended_drag_source_v1 object it's attached to.
Delegate* const delegate_;
};
} // namespace exo
#endif // COMPONENTS_EXO_EXTENDED_DRAG_OFFER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/exo/extended_drag_source.h"
#include "base/check_op.h"
#include "base/logging.h"
#include "components/exo/data_source.h"
#include "components/exo/seat.h"
#include "components/exo/surface.h"
#include "ui/gfx/geometry/vector2d.h"
namespace exo {
ExtendedDragSource::ExtendedDragSource(DataSource* source,
Seat* seat,
Delegate* delegate)
: delegate_(delegate), seat_(seat), source_(source) {
DCHECK(source_);
DCHECK(seat_);
DCHECK(delegate_);
DVLOG(1) << "ExtendedDragSource created. wl_source=" << source_;
source_->AddObserver(this);
}
ExtendedDragSource::~ExtendedDragSource() {
delegate_->OnDataSourceDestroying();
for (auto& observer : observers_)
observer.OnExtendedDragSourceDestroying(this);
if (source_)
source_->RemoveObserver(this);
}
void ExtendedDragSource::AddObserver(Observer* observer) {
DCHECK(observer);
observers_.AddObserver(observer);
}
void ExtendedDragSource::RemoveObserver(Observer* observer) {
DCHECK(observer);
observers_.RemoveObserver(observer);
}
void ExtendedDragSource::Drag(Surface* dragged_surface,
const gfx::Vector2d& drag_offset) {
// Associated data source already destroyed.
if (!source_)
return;
if (dragged_surface == dragged_surface_ && drag_offset == drag_offset_)
return;
dragged_surface_ = dragged_surface;
drag_offset_ = drag_offset;
DVLOG(1) << "Dragged surface changed: surface=" << dragged_surface_
<< " offset=" << drag_offset_.ToString();
for (auto& observer : observers_)
observer.OnDraggedSurfaceChanged(this);
}
void ExtendedDragSource::OnDataSourceDestroying(DataSource* source) {
DCHECK_EQ(source, source_);
source_->RemoveObserver(this);
source_ = nullptr;
}
} // namespace exo
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_EXO_EXTENDED_DRAG_SOURCE_H_
#define COMPONENTS_EXO_EXTENDED_DRAG_SOURCE_H_
#include <string>
#include "base/observer_list.h"
#include "base/optional.h"
#include "components/exo/data_source_observer.h"
#include "ui/gfx/geometry/vector2d.h"
namespace exo {
class DataSource;
class Seat;
class Surface;
class ExtendedDragSource : public DataSourceObserver {
public:
class Delegate {
public:
virtual bool ShouldAllowDropAnywhere() const = 0;
virtual bool ShouldLockCursor() const = 0;
virtual void OnSwallowed(std::string mime_type) = 0;
virtual void OnUnswallowed(std::string mime_type,
const gfx::Vector2d& offset) = 0;
virtual void OnDataSourceDestroying() = 0;
protected:
virtual ~Delegate() = default;
};
class Observer {
public:
virtual void OnExtendedDragSourceDestroying(ExtendedDragSource* source) = 0;
virtual void OnDraggedSurfaceChanged(ExtendedDragSource* source) = 0;
protected:
virtual ~Observer() = default;
};
ExtendedDragSource(DataSource* source, Seat* seat, Delegate* delegate);
ExtendedDragSource(const ExtendedDragSource&) = delete;
ExtendedDragSource& operator=(const ExtendedDragSource&) = delete;
~ExtendedDragSource() override;
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
bool should_allow_drop_anywhere() const {
return delegate_->ShouldAllowDropAnywhere();
}
bool should_lock_cursor() const { return delegate_->ShouldLockCursor(); }
const gfx::Vector2d& drag_offset() const { return drag_offset_; }
void Drag(Surface* surface, const gfx::Vector2d& offset);
private:
// DataSourceObserver:
void OnDataSourceDestroying(DataSource* source) override;
// Created and destroyed at wayland/zcr_extended_drag.cc and its lifetime is
// tied to the zcr_extended_drag_source_v1 object it's attached to.
Delegate* const delegate_;
Seat* const seat_;
DataSource* source_ = nullptr;
Surface* dragged_surface_ = nullptr;
gfx::Vector2d drag_offset_;
base::ObserverList<Observer>::Unchecked observers_;
};
} // namespace exo
#endif // COMPONENTS_EXO_EXTENDED_DRAG_SOURCE_H_
...@@ -49,6 +49,8 @@ source_set("wayland") { ...@@ -49,6 +49,8 @@ source_set("wayland") {
"zaura_shell.h", "zaura_shell.h",
"zcr_alpha_compositing.cc", "zcr_alpha_compositing.cc",
"zcr_alpha_compositing.h", "zcr_alpha_compositing.h",
"zcr_extended_drag.cc",
"zcr_extended_drag.h",
"zcr_secure_output.cc", "zcr_secure_output.cc",
"zcr_secure_output.h", "zcr_secure_output.h",
"zcr_stylus.cc", "zcr_stylus.cc",
...@@ -74,6 +76,7 @@ source_set("wayland") { ...@@ -74,6 +76,7 @@ source_set("wayland") {
"//third_party/wayland-protocols:alpha_compositing_protocol", "//third_party/wayland-protocols:alpha_compositing_protocol",
"//third_party/wayland-protocols:color_space_protocol", "//third_party/wayland-protocols:color_space_protocol",
"//third_party/wayland-protocols:cursor_shapes_protocol", "//third_party/wayland-protocols:cursor_shapes_protocol",
"//third_party/wayland-protocols:extended_drag",
"//third_party/wayland-protocols:gaming_input_protocol", "//third_party/wayland-protocols:gaming_input_protocol",
"//third_party/wayland-protocols:input_timestamps_protocol", "//third_party/wayland-protocols:input_timestamps_protocol",
"//third_party/wayland-protocols:keyboard_configuration_protocol", "//third_party/wayland-protocols:keyboard_configuration_protocol",
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <aura-shell-server-protocol.h> #include <aura-shell-server-protocol.h>
#include <color-space-unstable-v1-server-protocol.h> #include <color-space-unstable-v1-server-protocol.h>
#include <cursor-shapes-unstable-v1-server-protocol.h> #include <cursor-shapes-unstable-v1-server-protocol.h>
#include <extended-drag-unstable-v1-server-protocol.h>
#include <gaming-input-unstable-v2-server-protocol.h> #include <gaming-input-unstable-v2-server-protocol.h>
#include <grp.h> #include <grp.h>
#include <input-timestamps-unstable-v1-server-protocol.h> #include <input-timestamps-unstable-v1-server-protocol.h>
...@@ -66,6 +67,7 @@ ...@@ -66,6 +67,7 @@
#include "components/exo/wayland/xdg_shell.h" #include "components/exo/wayland/xdg_shell.h"
#include "components/exo/wayland/zcr_color_space.h" #include "components/exo/wayland/zcr_color_space.h"
#include "components/exo/wayland/zcr_cursor_shapes.h" #include "components/exo/wayland/zcr_cursor_shapes.h"
#include "components/exo/wayland/zcr_extended_drag.h"
#include "components/exo/wayland/zcr_gaming_input.h" #include "components/exo/wayland/zcr_gaming_input.h"
#include "components/exo/wayland/zcr_keyboard_configuration.h" #include "components/exo/wayland/zcr_keyboard_configuration.h"
#include "components/exo/wayland/zcr_keyboard_extension.h" #include "components/exo/wayland/zcr_keyboard_extension.h"
...@@ -210,6 +212,8 @@ Server::Server(Display* display) ...@@ -210,6 +212,8 @@ Server::Server(Display* display)
display_, bind_color_space); display_, bind_color_space);
wl_global_create(wl_display_.get(), &zxdg_decoration_manager_v1_interface, 1, wl_global_create(wl_display_.get(), &zxdg_decoration_manager_v1_interface, 1,
display_, bind_zxdg_decoration_manager); display_, bind_zxdg_decoration_manager);
wl_global_create(wl_display_.get(), &zcr_extended_drag_v1_interface, 1,
display_, bind_extended_drag);
zwp_text_manager_data_ = std::make_unique<WaylandTextInputManager>( zwp_text_manager_data_ = std::make_unique<WaylandTextInputManager>(
display_->seat()->xkb_tracker(), serial_tracker_.get()); display_->seat()->xkb_tracker(), serial_tracker_.get());
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/exo/wayland/zcr_extended_drag.h"
#include <extended-drag-unstable-v1-server-protocol.h>
#include <wayland-server-core.h>
#include <wayland-server-protocol-core.h>
#include <cstdint>
#include "base/notreached.h"
#include "components/exo/data_offer.h"
#include "components/exo/data_source.h"
#include "components/exo/display.h"
#include "components/exo/extended_drag_offer.h"
#include "components/exo/extended_drag_source.h"
#include "components/exo/surface.h"
#include "components/exo/wayland/server_util.h"
#include "ui/gfx/geometry/vector2d.h"
namespace exo {
namespace wayland {
namespace {
////////////////////////////////////////////////////////////////////////////////
// zcr_extended_drag_source interface:
class ZcrExtendedDragSourceDelegate : public ExtendedDragSource::Delegate {
public:
ZcrExtendedDragSourceDelegate(wl_resource* resource, uint32_t settings)
: resource_(resource), settings_(settings) {}
ZcrExtendedDragSourceDelegate(const ZcrExtendedDragSourceDelegate&) = delete;
ZcrExtendedDragSourceDelegate& operator=(
const ZcrExtendedDragSourceDelegate&) = delete;
~ZcrExtendedDragSourceDelegate() override = default;
// ExtendedDragSource::Delegate:
bool ShouldAllowDropAnywhere() const override {
return settings_ & ZCR_EXTENDED_DRAG_V1_OPTIONS_ALLOW_DROP_NO_TARGET;
}
bool ShouldLockCursor() const override {
return settings_ & ZCR_EXTENDED_DRAG_V1_OPTIONS_LOCK_CURSOR;
}
void OnSwallowed(std::string mime_type) override {
zcr_extended_drag_source_v1_send_swallow(resource_, mime_type.c_str());
wl_client_flush(wl_resource_get_client(resource_));
}
void OnUnswallowed(std::string mime_type,
const gfx::Vector2d& offset) override {
zcr_extended_drag_source_v1_send_unswallow(resource_, mime_type.c_str(),
offset.x(), offset.y());
wl_client_flush(wl_resource_get_client(resource_));
}
void OnDataSourceDestroying() override { delete this; }
private:
wl_resource* const resource_;
const uint32_t settings_;
};
void extended_drag_source_destroy(wl_client* client, wl_resource* resource) {
wl_resource_destroy(resource);
}
void extended_drag_source_drag(wl_client* client,
wl_resource* resource,
wl_resource* surface_resource,
int32_t x_offset,
int32_t y_offset) {
Surface* surface =
surface_resource ? GetUserDataAs<Surface>(surface_resource) : nullptr;
gfx::Vector2d offset{x_offset, y_offset};
GetUserDataAs<ExtendedDragSource>(resource)->Drag(surface, offset);
}
const struct zcr_extended_drag_source_v1_interface
extended_drag_source_implementation = {extended_drag_source_destroy,
extended_drag_source_drag};
////////////////////////////////////////////////////////////////////////////////
// zcr_extended_drag_offer interface:
class ZcrExtendedOfferDelegate : public ExtendedDragOffer::Delegate {
public:
explicit ZcrExtendedOfferDelegate(wl_resource* resource)
: resource_(resource) {
DCHECK(resource_);
}
ZcrExtendedOfferDelegate(const ZcrExtendedOfferDelegate&) = delete;
ZcrExtendedOfferDelegate& operator=(const ZcrExtendedOfferDelegate&) = delete;
~ZcrExtendedOfferDelegate() override = default;
// ExtendedDragOffer::Delegate:
void OnDataOfferDestroying() override { delete this; }
private:
wl_resource* const resource_;
};
void extended_drag_offer_destroy(wl_client* client, wl_resource* resource) {
wl_resource_destroy(resource);
}
void extended_drag_offer_swallow(wl_client* client,
wl_resource* resource,
uint32_t serial,
const char* mime_type) {
GetUserDataAs<ExtendedDragOffer>(resource)->Swallow(serial, mime_type);
}
void extended_drag_offer_unswallow(wl_client* client,
wl_resource* resource,
uint32_t serial,
const char* mime_type,
int32_t x_offset,
int32_t y_offset) {
gfx::Vector2d offset{x_offset, y_offset};
GetUserDataAs<ExtendedDragOffer>(resource)->Unswallow(serial, mime_type,
offset);
}
const struct zcr_extended_drag_offer_v1_interface
extended_drag_offer_implementation = {extended_drag_offer_destroy,
extended_drag_offer_swallow,
extended_drag_offer_unswallow};
////////////////////////////////////////////////////////////////////////////////
// zcr_extended_drag interface:
void extended_drag_get_extended_drag_source(wl_client* client,
wl_resource* resource,
uint32_t id,
wl_resource* data_source_resource,
uint32_t settings) {
Display* display = GetUserDataAs<Display>(resource);
DataSource* source = GetUserDataAs<DataSource>(data_source_resource);
wl_resource* extended_drag_source_resource =
wl_resource_create(client, &zcr_extended_drag_source_v1_interface,
wl_resource_get_version(resource), id);
SetImplementation(extended_drag_source_resource,
&extended_drag_source_implementation,
std::make_unique<ExtendedDragSource>(
source, display->seat(),
new ZcrExtendedDragSourceDelegate(
extended_drag_source_resource, settings)));
}
void extended_drag_get_extended_drag_offer(wl_client* client,
wl_resource* resource,
uint32_t id,
wl_resource* data_offer_resource) {
DataOffer* offer = GetUserDataAs<DataOffer>(data_offer_resource);
wl_resource* extended_drag_offer_resource =
wl_resource_create(client, &zcr_extended_drag_offer_v1_interface,
wl_resource_get_version(resource), id);
SetImplementation(
extended_drag_offer_resource, &extended_drag_offer_implementation,
std::make_unique<ExtendedDragOffer>(
offer, new ZcrExtendedOfferDelegate(extended_drag_offer_resource)));
}
const struct zcr_extended_drag_v1_interface extended_drag_implementation = {
extended_drag_get_extended_drag_source,
extended_drag_get_extended_drag_offer};
} // namespace
void bind_extended_drag(wl_client* client,
void* data,
uint32_t version,
uint32_t id) {
wl_resource* resource =
wl_resource_create(client, &zcr_extended_drag_v1_interface, version, id);
wl_resource_set_implementation(resource, &extended_drag_implementation, data,
nullptr);
}
} // namespace wayland
} // namespace exo
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_EXO_WAYLAND_ZCR_EXTENDED_DRAG_H_
#define COMPONENTS_EXO_WAYLAND_ZCR_EXTENDED_DRAG_H_
#include <cstdint>
struct wl_client;
namespace exo {
namespace wayland {
void bind_extended_drag(wl_client* client,
void* data,
uint32_t version,
uint32_t id);
} // namespace wayland
} // namespace exo
#endif // COMPONENTS_EXO_WAYLAND_ZCR_EXTENDED_DRAG_H_
...@@ -123,3 +123,7 @@ wayland_protocol("color_space_protocol") { ...@@ -123,3 +123,7 @@ wayland_protocol("color_space_protocol") {
wayland_protocol("xdg_foreign") { wayland_protocol("xdg_foreign") {
sources = [ "src/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml" ] sources = [ "src/unstable/xdg-foreign/xdg-foreign-unstable-v1.xml" ]
} }
wayland_protocol("extended_drag") {
sources = [ "unstable/extended-drag/extended-drag-unstable-v1.xml" ]
}
Extended Drag protocol
Maintainers:
Nick Yamane <nickdiego@igalia.com>
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="extended_drag_unstable_v1">
<copyright>
Copyright 2020 The Chromium Authors.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<interface name="zcr_extended_drag_v1" version="1">
<description summary="extends DnD protocol with some advanced features">
The zcr_extended_drag_v1 interface extends the Wayland drag-and-drop with
features unsurpported by the core protocol. Such as, making toplevel shell
surfaces "draggable", as well as making them "snappable" into and out of
other surfaces as they are dragged around.
A common use case for this is a Chromium-like tab/window dragging UX,
where the user is able to drag a tab (or any other kind of UI piece) out
of its original window, into a new surface anchored to the pointer cursor,
similar to a regular drag icon but with enhanced and more configurable
capabilities.
Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible changes
may be added together with the corresponding uinterface version bump.
Backward incompatible changes are done by bumping the version number in
the protocol and uinterface names and resetting the interface version.
Once the protocol is to be declared stable, the 'z' prefix and the
version number in the protocol and interface names are removed and the
interface version number is reset.
</description>
<enum name="options" bitfield="true">
<description summary="extended drag configuration flags.">
Bitmask flags that can be used to configure how the drag session will
operate. By default no additional option is set.
Source client might set allow_swallow option to tell the compositor that
the dragged UI item can be snapped out and into other surfaces
(swallowed/unswallowed), eg: Chromium's tab dragging UX.
allow_drop_no_target controls how source and destination clients are
notified when the drop happens, if it is set the DnD operation is
considered successfully finished regardless the drop location (eg:
outside any shell surface or there is no target that can accept it).
lock_cursor might be used to keep the cursor shape locked during the
extended drag session, regardless current the mime types, dnd action
negotiation status.
</description>
<entry name="default" value="0"/>
<entry name="allow_swallow" value="1"/>
<entry name="allow_drop_no_target" value="2"/>
<entry name="lock_cursor" value="4"/>
</enum>
<request name="get_extended_drag_source">
<description summary="get an extended_drag_source for a wl_data_source">
Create an extended drag source object. See zcr_extended_drag_source_v1
interface for details.
</description>
<arg name="id" type="new_id" interface="zcr_extended_drag_source_v1"/>
<arg name="data_source" type="object" interface="wl_data_source"/>
<arg name="options" type="uint" enum="zcr_extended_drag_v1.options"/>
</request>
<request name="get_extended_drag_offer">
<description summary="get an extended_drag_offer for a wl_data_offer">
Create an extended drag offer object. See zcr_extended_drag_offer_v1
interface for details.
</description>
<arg name="id" type="new_id" interface="zcr_extended_drag_offer_v1"/>
<arg name="data_offer" type="object" interface="wl_data_offer"/>
</request>
</interface>
<interface name="zcr_extended_drag_source_v1" version="1">
<description summary="extensions for the standard drag data source">
The zcr_extended_drag_source_v1 interface extends the wl_data_source with
features unsurpported by the standard drag-and-drop protocol.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the extended drag source object"/>
</request>
<request name="drag">
<description summary="Update the dragged surface">
Update the dragged surface. If null is passed, the dragged surface gets
unset, making it to not being moved anymore under the pointer cursor.
Otherwise, it will be set as the dragged surface, making it to be visually
anchored to the pointer cursor. surface is expected to have a toplevel
shell surface role assigned, which allows it to be dropped smoothly into
an arbitrary location of the shell, so turning it instantly into a
regular toplevel window, which not possible with the standard DND
protocol.
x and y offsets are described in surface-local coordinates, with no
scale applied, that determine how the surface must be positioned
relative to the cursor location, similar to drag icon offsets in
standard DND operations.
</description>
<arg name="surface" type="object" interface="wl_surface" allow-null="true" summary="drag icon surface"/>
<arg name="x_offset" type="int" summary="dragged surface x offset"/>
<arg name="y_offset" type="int" summary="dragged surface y offset"/>
</request>
<event name="swallow">
<description summary="the receiving client requested to swallow the drag.">
The receiving client has requested to swallow the dragged surface.
Which, in a drag operation involving 2 or more clients, can be used to
negotiate when the dragged surface is incorporated (aka: merged) into
its UI. See zcr_extended_drag_offer_v1::swallow request for more
details.
</description>
<arg name="mime_type" type="string" summary="mime type to be swallowed by the client"/>
</event>
<event name="unswallow">
<description summary="the receiving client requested to unswallow the drag.">
The receiving client has requested to unswallow the dragged surface.
Which, in a drag operation involving more than a single client, can be
used to negotiate when the dragged surface is snapped out of the
receiving client's UI.
X and Y offsets are expressed in surface-local coordinates, with no
scale applied, and describe how the surface must be positioned relative
to the cursor location, similar to drag icon offsets in standard DND
operations. Note that these coordinates are local to the unswallowed
surface, created and owned by the source client, so it can be used
rightaway to call drag(surface, x_offset, y_offset) in response to
receiving client's request.
</description>
<arg name="mime_type" type="string" allow-null="true" summary="mime type accepted by the client"/>
<arg name="x_offset" type="int" summary="dragged surface x offset"/>
<arg name="y_offset" type="int" summary="dragged surface y offset"/>
</event>
</interface>
<interface name="zcr_extended_drag_offer_v1" version="1">
<description summary="extensions for the standard drag data offer.">
The zcr_extended_drag_offer_v1 interface extends the wl_data_offer with
features unsurpported by the standard drag-and-drop protocol.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the extended drag offer object"/>
</request>
<request name="swallow">
<description summary="Requests the drag source to swallow the drag.">
Requests the drag source to swallow the dragged surface. This means the
receiving client accepts and will incorporate the dragged surface into
its UI. For example, a browser tab is dragged and snapped to an icon\
grid.
</description>
<arg name="serial" type="uint" summary="serial number of the swallow request"/>
<arg name="mime_type" type="string" allow-null="true" summary="mime type being swallowed"/>
</request>
<request name="unswallow">
<description summary="Requests the drag source to unswallow the drag.">
Requests the drag source to unswallow the dragged surface. Which means
that the receiving client wants to undo a previously swallowed dragged
surface, i.e: detach it from its UI.
X and Y offsets are expressed in surface-local coordinates, with no
scale applied and describe how the surface must be positioned relative
to the cursor location, similar to drag icon offsets in standard DND
operations. Note that these coordinates are local to the currently
focused surface, owned by the receiving client, which may differ from
corresponding offsets at source side (which owns the unswallowed
surface), for instance, when the receiving surface is on a wl_output
with different scale value. Compositor handles such conversion before
delivering the zcr_extended_drag_source_v1::swallow event counterpart
to the source client.
</description>
<arg name="serial" type="uint" summary="serial number of the unswallow request"/>
<arg name="mime_type" type="string" summary="mime type being unswallowed"/>
<arg name="x_offset" type="int" summary="dragged surface x offset"/>
<arg name="y_offset" type="int" summary="dragged surface y offset"/>
</request>
</interface>
</protocol>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment