Commit fd5451d1 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

exo: Use correct start position for touch DnD

It is possible for a Wayland client to trigger drag & drop operation
from the touchscreen. Exo have used GetCursorScreenPoint() as the
initial drag shadow position, but the method does not return the
expected location when DnD is triggered from the touchscreen.

TEST=manual
BUG=None

Change-Id: I7febd3dacd60603893dee16a96adba05460d6422
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2224886Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774002}
parent 38b8cff0
......@@ -78,8 +78,10 @@ base::WeakPtr<DragDropOperation> DragDropOperation::Create(
DataSource* source,
Surface* origin,
Surface* icon,
const gfx::Point& drag_start_point,
ui::DragDropTypes::DragEventSource event_source) {
auto* dnd_op = new DragDropOperation(source, origin, icon, event_source);
auto* dnd_op = new DragDropOperation(source, origin, icon, drag_start_point,
event_source);
return dnd_op->weak_ptr_factory_.GetWeakPtr();
}
......@@ -87,11 +89,12 @@ DragDropOperation::DragDropOperation(
DataSource* source,
Surface* origin,
Surface* icon,
const gfx::Point& drag_start_point,
ui::DragDropTypes::DragEventSource event_source)
: SurfaceTreeHost("ExoDragDropOperation"),
source_(std::make_unique<ScopedDataSource>(source, this)),
origin_(std::make_unique<ScopedSurface>(origin, this)),
drag_start_point_(display::Screen::GetScreen()->GetCursorScreenPoint()),
drag_start_point_(drag_start_point),
os_exchange_data_(std::make_unique<ui::OSExchangeData>()),
event_source_(event_source),
weak_ptr_factory_(this) {
......
......@@ -50,6 +50,7 @@ class DragDropOperation : public DataSourceObserver,
DataSource* source,
Surface* origin,
Surface* icon,
const gfx::Point& drag_start_point,
ui::DragDropTypes::DragEventSource event_source);
// Abort the operation if it hasn't been started yet, otherwise do nothing.
......@@ -77,6 +78,7 @@ class DragDropOperation : public DataSourceObserver,
DragDropOperation(DataSource* source,
Surface* origin,
Surface* icon,
const gfx::Point& drag_start_point,
ui::DragDropTypes::DragEventSource event_source);
~DragDropOperation() override;
......
......@@ -339,6 +339,8 @@ void Pointer::OnSurfaceDestroying(Surface* surface) {
// ui::EventHandler overrides:
void Pointer::OnMouseEvent(ui::MouseEvent* event) {
seat_->SetLastLocation(event->root_location());
Surface* target = GetEffectiveTargetForEvent(event);
gfx::PointF location_in_target = event->location_f();
if (target) {
......
......@@ -83,8 +83,12 @@ void Seat::StartDrag(DataSource* source,
Surface* icon,
ui::DragDropTypes::DragEventSource event_source) {
// DragDropOperation manages its own lifetime.
drag_drop_operation_ =
DragDropOperation::Create(source, origin, icon, event_source);
drag_drop_operation_ = DragDropOperation::Create(
source, origin, icon, last_location_, event_source);
}
void Seat::SetLastLocation(const gfx::Point& last_location) {
last_location_ = last_location;
}
void Seat::AbortPendingDragOperation() {
......
......@@ -72,6 +72,10 @@ class Seat : public aura::client::FocusChangeObserver,
Surface* icon,
ui::DragDropTypes::DragEventSource event_source);
// Sets the last location in screen coordinates, irrespective of mouse or
// touch.
void SetLastLocation(const gfx::Point& last_location);
// Abort any drag operations that haven't been started yet.
void AbortPendingDragOperation();
......@@ -159,6 +163,8 @@ class Seat : public aura::client::FocusChangeObserver,
// True while Seat is updating clipboard data to selection source.
bool changing_clipboard_data_to_selection_source_;
gfx::Point last_location_;
base::WeakPtrFactory<Seat> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(Seat);
......
......@@ -60,6 +60,8 @@ bool Touch::HasStylusDelegate() const {
// ui::EventHandler overrides:
void Touch::OnTouchEvent(ui::TouchEvent* event) {
seat_->SetLastLocation(event->root_location());
bool send_details = false;
const int touch_pointer_id = event->pointer_details().id;
......
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