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