Commit bc34b239 authored by Nick Diego Yamane's avatar Nick Diego Yamane Committed by Commit Bot

exo: extended-drag: Implement cursor locking

Context: 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 third of a patch series which implements extended-drag in
Exo compositor. This one implements cursor locking options, required for
Chrome's tab dragging, otherwise DragDropController would update the
cursor shape based on the widget under the cursor accept DND operation
or not, which is meaningless for tab/window dragging purposes. Refer to
the design doc for more details.

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

R=oshima@chromium.org

Bug: 1099418
Change-Id: Ie41f487b26e2eda72dd5be25590d8565e6a5edcb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2401358
Commit-Queue: Nick Yamane <nickdiego@igalia.com>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822690}
parent 57f34d16
......@@ -159,6 +159,8 @@ void ExtendedDragSource::OnToplevelWindowDragStarted(
ui::mojom::DragEventSource source) {
pointer_location_ = start_location;
drag_event_source_ = source;
MaybeLockCursor();
if (dragged_window_holder_ && dragged_window_holder_->toplevel_window())
StartDrag(dragged_window_holder_->toplevel_window(), start_location);
}
......@@ -199,6 +201,20 @@ void ExtendedDragSource::OnDataSourceDestroying(DataSource* source) {
source_ = nullptr;
}
void ExtendedDragSource::MaybeLockCursor() {
if (delegate_->ShouldLockCursor()) {
ash::Shell::Get()->cursor_manager()->LockCursor();
cursor_locked_ = true;
}
}
void ExtendedDragSource::UnlockCursor() {
if (cursor_locked_) {
ash::Shell::Get()->cursor_manager()->UnlockCursor();
cursor_locked_ = false;
}
}
void ExtendedDragSource::StartDrag(aura::Window* toplevel,
const gfx::PointF& pointer_location) {
// Ensure |toplevel| window does skip events while it's being dragged.
......@@ -252,6 +268,7 @@ gfx::Point ExtendedDragSource::CalculateOrigin(aura::Window* target) const {
void ExtendedDragSource::Cleanup() {
event_blocker_.reset();
dragged_window_holder_.reset();
UnlockCursor();
}
aura::Window* ExtendedDragSource::GetDraggedWindowForTesting() {
......
......@@ -87,6 +87,8 @@ class ExtendedDragSource : public DataSourceObserver,
private:
class DraggedWindowHolder;
void MaybeLockCursor();
void UnlockCursor();
void StartDrag(aura::Window* toplevel,
const gfx::PointF& pointer_location_in_screen);
void OnDraggedWindowVisibilityChanging(bool visible);
......@@ -100,6 +102,7 @@ class ExtendedDragSource : public DataSourceObserver,
DataSource* source_ = nullptr;
gfx::PointF pointer_location_;
ui::mojom::DragEventSource drag_event_source_;
bool cursor_locked_ = false;
std::unique_ptr<DraggedWindowHolder> dragged_window_holder_;
std::unique_ptr<aura::ScopedWindowEventTargetingBlocker> event_blocker_;
......
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