Commit 5b63c8fb authored by Nick Diego Yamane's avatar Nick Diego Yamane Committed by Commit Bot

exo: Use float to store last seat's pointer location

As per suggestion [1], this switches exo::Seat's last_location_ variable
and SetLastLocation method to use gfx::PointF to handle last pointer
location. It'll be used in a followup CL as part of the extended-drag
protocol extension implementation in Exo [2].

[1] https://chromium-review.googlesource.com/c/chromium/src/+/2307653/comment/45820a22_e6516518/
[2] https://chromium-review.googlesource.com/c/chromium/src/+/2401280

R=oshima@chromium.org

Bug: 1099418
Change-Id: I3be933f8788f748ff0324760d8f98b70e13b8d96
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2410664
Commit-Queue: Nick Yamane <nickdiego@igalia.com>
Auto-Submit: Nick Yamane <nickdiego@igalia.com>
Reviewed-by: default avatarMitsuru Oshima (Slow: gardener) <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806761}
parent ff3a7ae3
......@@ -17,6 +17,9 @@
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/transform_util.h"
#if defined(OS_CHROMEOS)
......@@ -79,7 +82,7 @@ base::WeakPtr<DragDropOperation> DragDropOperation::Create(
DataSource* source,
Surface* origin,
Surface* icon,
const gfx::Point& drag_start_point,
const gfx::PointF& drag_start_point,
ui::mojom::DragEventSource event_source) {
auto* dnd_op = new DragDropOperation(source, origin, icon, drag_start_point,
event_source);
......@@ -89,7 +92,7 @@ base::WeakPtr<DragDropOperation> DragDropOperation::Create(
DragDropOperation::DragDropOperation(DataSource* source,
Surface* origin,
Surface* icon,
const gfx::Point& drag_start_point,
const gfx::PointF& drag_start_point,
ui::mojom::DragEventSource event_source)
: SurfaceTreeHost("ExoDragDropOperation"),
source_(std::make_unique<ScopedDataSource>(source, this)),
......@@ -242,11 +245,13 @@ void DragDropOperation::StartDragDropOperation() {
base::WeakPtr<DragDropOperation> weak_ptr = weak_ptr_factory_.GetWeakPtr();
started_by_this_object_ = true;
gfx::Point drag_start_point = gfx::ToFlooredPoint(drag_start_point_);
// This triggers a nested run loop that terminates when the drag and drop
// operation is completed.
int op = drag_drop_controller_->StartDragAndDrop(
std::move(os_exchange_data_), origin_->get()->window()->GetRootWindow(),
origin_->get()->window(), drag_start_point_, dnd_operations,
origin_->get()->window(), drag_start_point, dnd_operations,
event_source_);
// The instance deleted during StartDragAndDrop's nested RunLoop.
......
......@@ -13,6 +13,7 @@
#include "components/exo/wm_helper.h"
#include "ui/aura/client/drag_drop_client_observer.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom-forward.h"
#include "ui/gfx/geometry/point_f.h"
namespace ash {
class DragDropController;
......@@ -50,7 +51,7 @@ class DragDropOperation : public DataSourceObserver,
DataSource* source,
Surface* origin,
Surface* icon,
const gfx::Point& drag_start_point,
const gfx::PointF& drag_start_point,
ui::mojom::DragEventSource event_source);
// Abort the operation if it hasn't been started yet, otherwise do nothing.
......@@ -78,7 +79,7 @@ class DragDropOperation : public DataSourceObserver,
DragDropOperation(DataSource* source,
Surface* origin,
Surface* icon,
const gfx::Point& drag_start_point,
const gfx::PointF& drag_start_point,
ui::mojom::DragEventSource event_source);
~DragDropOperation() override;
......@@ -97,7 +98,7 @@ class DragDropOperation : public DataSourceObserver,
std::unique_ptr<ScopedDataSource> source_;
std::unique_ptr<ScopedSurface> icon_;
std::unique_ptr<ScopedSurface> origin_;
gfx::Point drag_start_point_;
gfx::PointF drag_start_point_;
std::unique_ptr<ui::OSExchangeData> os_exchange_data_;
#if defined(OS_CHROMEOS)
ash::DragDropController* drag_drop_controller_;
......
......@@ -17,6 +17,7 @@
#include "components/exo/test/exo_test_base.h"
#include "ui/aura/client/drag_drop_client.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom-shared.h"
#include "ui/gfx/geometry/point_f.h"
namespace exo {
namespace {
......@@ -103,8 +104,8 @@ TEST_F(DragDropOperationTest, DeleteDuringDragging) {
icon_surface->Attach(buffer.get());
auto operation = DragDropOperation::Create(
data_source.get(), origin_surface.get(), icon_surface.get(), gfx::Point(),
ui::mojom::DragEventSource::kMouse);
data_source.get(), origin_surface.get(), icon_surface.get(),
gfx::PointF(), ui::mojom::DragEventSource::kMouse);
icon_surface->Commit();
base::RunLoop run_loop;
......
......@@ -346,7 +346,7 @@ void Pointer::OnMouseEvent(ui::MouseEvent* event) {
if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED)
return;
seat_->SetLastLocation(event->root_location());
seat_->SetLastPointerLocation(event->root_location_f());
Surface* target = GetEffectiveTargetForEvent(event);
gfx::PointF location_in_target = event->location_f();
......
......@@ -5,6 +5,7 @@
#include "components/exo/seat.h"
#include <memory>
#include "ui/gfx/geometry/point_f.h"
#if defined(OS_CHROMEOS)
#include "ash/shell.h"
......@@ -98,11 +99,11 @@ void Seat::StartDrag(DataSource* source,
ui::mojom::DragEventSource event_source) {
// DragDropOperation manages its own lifetime.
drag_drop_operation_ = DragDropOperation::Create(
source, origin, icon, last_location_, event_source);
source, origin, icon, last_pointer_location_, event_source);
}
void Seat::SetLastLocation(const gfx::Point& last_location) {
last_location_ = last_location;
void Seat::SetLastPointerLocation(const gfx::PointF& last_pointer_location) {
last_pointer_location_ = last_pointer_location;
}
void Seat::AbortPendingDragOperation() {
......
......@@ -80,7 +80,7 @@ class Seat : public aura::client::FocusChangeObserver,
// Sets the last location in screen coordinates, irrespective of mouse or
// touch.
void SetLastLocation(const gfx::Point& last_location);
void SetLastPointerLocation(const gfx::PointF& last_pointer_location);
// Abort any drag operations that haven't been started yet.
void AbortPendingDragOperation();
......@@ -159,7 +159,7 @@ 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_;
gfx::PointF last_pointer_location_;
bool shutdown_ = false;
......
......@@ -60,7 +60,7 @@ bool Touch::HasStylusDelegate() const {
// ui::EventHandler overrides:
void Touch::OnTouchEvent(ui::TouchEvent* event) {
seat_->SetLastLocation(event->root_location());
seat_->SetLastPointerLocation(event->root_location_f());
bool send_details = false;
......
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