summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspang@chromium.org <spang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-14 22:04:38 +0000
committerspang@chromium.org <spang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-14 22:04:38 +0000
commitc33e945c4416736ec1fee916ea14ff545a9e286f (patch)
tree44f0eb7b33a45fa021d923585e1555007e9c701f
parent0dff39e8fae5572f1a1e1f980c494edd0109236a (diff)
downloadchromium_src-c33e945c4416736ec1fee916ea14ff545a9e286f.zip
chromium_src-c33e945c4416736ec1fee916ea14ff545a9e286f.tar.gz
chromium_src-c33e945c4416736ec1fee916ea14ff545a9e286f.tar.bz2
ozone: evdev: Add CursorDelegateEvdev & implement cursor warp
Evdev needs the ability to move the cursor. Add CursorDelegateEvdev, which we'll call whenever the cursor needs to move as the result of an input event. Also implement warp, which is a cursor move that is generated by chrome rather than an input device. A warp must still result in a MOUSE_MOVED event even through chrome initiates the wrap. Thus, it fits better on EventFactoryOzone than CursorFactoryOzone, so move it there. BUG=252315 Review URL: https://codereview.chromium.org/193743002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257222 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/aura/window_tree_host_ozone.cc4
-rw-r--r--ui/base/cursor/ozone/cursor_factory_ozone.cc13
-rw-r--r--ui/base/cursor/ozone/cursor_factory_ozone.h9
-rw-r--r--ui/events/ozone/evdev/cursor_delegate_evdev.h32
-rw-r--r--ui/events/ozone/evdev/event_factory_evdev.cc22
-rw-r--r--ui/events/ozone/evdev/event_factory_evdev.h10
-rw-r--r--ui/events/ozone/event_factory_ozone.cc5
-rw-r--r--ui/events/ozone/event_factory_ozone.h11
8 files changed, 86 insertions, 20 deletions
diff --git a/ui/aura/window_tree_host_ozone.cc b/ui/aura/window_tree_host_ozone.cc
index d9f1996..cb3ddb9 100644
--- a/ui/aura/window_tree_host_ozone.cc
+++ b/ui/aura/window_tree_host_ozone.cc
@@ -104,8 +104,8 @@ void WindowTreeHostOzone::SetCursorNative(gfx::NativeCursor cursor) {
}
void WindowTreeHostOzone::MoveCursorToNative(const gfx::Point& location) {
- ui::CursorFactoryOzone::GetInstance()->MoveCursorTo(GetAcceleratedWidget(),
- location);
+ ui::EventFactoryOzone::GetInstance()->WarpCursorTo(GetAcceleratedWidget(),
+ location);
}
void WindowTreeHostOzone::OnCursorVisibilityChangedNative(bool show) {
diff --git a/ui/base/cursor/ozone/cursor_factory_ozone.cc b/ui/base/cursor/ozone/cursor_factory_ozone.cc
index 13672cf..46c1da3 100644
--- a/ui/base/cursor/ozone/cursor_factory_ozone.cc
+++ b/ui/base/cursor/ozone/cursor_factory_ozone.cc
@@ -34,17 +34,16 @@ PlatformCursor CursorFactoryOzone::CreateImageCursor(
return NULL;
}
-void CursorFactoryOzone::RefImageCursor(PlatformCursor cursor) {}
-
-void CursorFactoryOzone::UnrefImageCursor(PlatformCursor cursor) {}
+void CursorFactoryOzone::RefImageCursor(PlatformCursor cursor) {
+ NOTIMPLEMENTED();
+}
-void CursorFactoryOzone::SetCursor(gfx::AcceleratedWidget widget,
- PlatformCursor cursor) {
+void CursorFactoryOzone::UnrefImageCursor(PlatformCursor cursor) {
NOTIMPLEMENTED();
}
-void CursorFactoryOzone::MoveCursorTo(gfx::AcceleratedWidget widget,
- const gfx::Point& location) {
+void CursorFactoryOzone::SetCursor(gfx::AcceleratedWidget widget,
+ PlatformCursor cursor) {
NOTIMPLEMENTED();
}
diff --git a/ui/base/cursor/ozone/cursor_factory_ozone.h b/ui/base/cursor/ozone/cursor_factory_ozone.h
index 3af637f..8ea2e74 100644
--- a/ui/base/cursor/ozone/cursor_factory_ozone.h
+++ b/ui/base/cursor/ozone/cursor_factory_ozone.h
@@ -9,10 +9,6 @@
#include "ui/base/ui_base_export.h"
#include "ui/gfx/native_widget_types.h"
-namespace gfx {
-class Point;
-}
-
namespace ui {
class UI_BASE_EXPORT CursorFactoryOzone {
@@ -47,11 +43,6 @@ class UI_BASE_EXPORT CursorFactoryOzone {
// TODO(spang): Move this.
virtual void SetCursor(gfx::AcceleratedWidget widget, PlatformCursor cursor);
- // Warp the cursor within an AccelerateWidget.
- // TODO(spang): Move this.
- virtual void MoveCursorTo(gfx::AcceleratedWidget widget,
- const gfx::Point& location);
-
private:
static CursorFactoryOzone* impl_; // not owned
};
diff --git a/ui/events/ozone/evdev/cursor_delegate_evdev.h b/ui/events/ozone/evdev/cursor_delegate_evdev.h
new file mode 100644
index 0000000..b9ed4e9
--- /dev/null
+++ b/ui/events/ozone/evdev/cursor_delegate_evdev.h
@@ -0,0 +1,32 @@
+// Copyright 2014 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 UI_EVENTS_OZONE_EVDEV_CURSOR_DELEGATE_EVDEV_H_
+#define UI_EVENTS_OZONE_EVDEV_CURSOR_DELEGATE_EVDEV_H_
+
+#include "ui/events/events_export.h"
+#include "ui/gfx/geometry/point_f.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace gfx {
+class Vector2dF;
+}
+
+namespace ui {
+
+class EVENTS_EXPORT CursorDelegateEvdev {
+ public:
+ // Move the cursor.
+ virtual void MoveCursor(const gfx::Vector2dF& delta) = 0;
+ virtual void MoveCursorTo(gfx::AcceleratedWidget widget,
+ const gfx::PointF& location) = 0;
+
+ // Window under cursor & location in window.
+ virtual gfx::AcceleratedWidget window() = 0;
+ virtual gfx::PointF location() = 0;
+};
+
+} // namespace ui
+
+#endif // UI_EVENTS_OZONE_EVDEV_CURSOR_DELEGATE_EVDEV_H_
diff --git a/ui/events/ozone/evdev/event_factory_evdev.cc b/ui/events/ozone/evdev/event_factory_evdev.cc
index 8ff1767..9e66505 100644
--- a/ui/events/ozone/evdev/event_factory_evdev.cc
+++ b/ui/events/ozone/evdev/event_factory_evdev.cc
@@ -10,6 +10,7 @@
#include "base/debug/trace_event.h"
#include "base/stl_util.h"
#include "base/task_runner.h"
+#include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
#include "ui/events/ozone/evdev/device_manager_evdev.h"
#include "ui/events/ozone/evdev/event_device_info.h"
#include "ui/events/ozone/evdev/key_event_converter_evdev.h"
@@ -44,6 +45,7 @@ bool IsTouchScreen(const EventDeviceInfo& devinfo) {
void OpenInputDevice(
const base::FilePath& path,
EventModifiersEvdev* modifiers,
+ CursorDelegateEvdev* cursor,
scoped_refptr<base::TaskRunner> reply_runner,
base::Callback<void(scoped_ptr<EventConverterEvdev>)> reply_callback) {
TRACE_EVENT1("ozone", "OpenInputDevice", "path", path.value());
@@ -97,6 +99,13 @@ void CloseInputDevice(const base::FilePath& path,
EventFactoryEvdev::EventFactoryEvdev()
: ui_task_runner_(base::MessageLoopProxy::current()),
file_task_runner_(base::MessageLoopProxy::current()),
+ cursor_(NULL),
+ weak_ptr_factory_(this) {}
+
+EventFactoryEvdev::EventFactoryEvdev(CursorDelegateEvdev* cursor)
+ : ui_task_runner_(base::MessageLoopProxy::current()),
+ file_task_runner_(base::MessageLoopProxy::current()),
+ cursor_(cursor),
weak_ptr_factory_(this) {}
EventFactoryEvdev::~EventFactoryEvdev() { STLDeleteValues(&converters_); }
@@ -126,6 +135,7 @@ void EventFactoryEvdev::OnDeviceAdded(const base::FilePath& path) {
base::Bind(&OpenInputDevice,
path,
&modifiers_,
+ cursor_,
ui_task_runner_,
base::Bind(&EventFactoryEvdev::AttachInputDevice,
weak_ptr_factory_.GetWeakPtr(),
@@ -179,4 +189,16 @@ void EventFactoryEvdev::SetFileTaskRunner(
file_task_runner_ = task_runner;
}
+void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget,
+ const gfx::PointF& location) {
+ if (cursor_)
+ cursor_->MoveCursorTo(widget, location);
+ scoped_ptr<Event> ev(new MouseEvent(ET_MOUSE_MOVED,
+ cursor_->location(),
+ cursor_->location(),
+ modifiers_.GetModifierFlags(),
+ /* changed_button_flags */ 0));
+ DispatchEvent(ev.Pass());
+}
+
} // namespace ui
diff --git a/ui/events/ozone/evdev/event_factory_evdev.h b/ui/events/ozone/evdev/event_factory_evdev.h
index 2dfd21c..39d61ba 100644
--- a/ui/events/ozone/evdev/event_factory_evdev.h
+++ b/ui/events/ozone/evdev/event_factory_evdev.h
@@ -17,19 +17,22 @@
namespace ui {
+class CursorDelegateEvdev;
class DeviceManagerEvdev;
// Ozone events implementation for the Linux input subsystem ("evdev").
class EVENTS_EXPORT EventFactoryEvdev : public EventFactoryOzone {
public:
EventFactoryEvdev();
+ explicit EventFactoryEvdev(CursorDelegateEvdev* cursor);
virtual ~EventFactoryEvdev();
+ // EventFactoryOzone:
virtual void StartProcessingEvents() OVERRIDE;
-
- // Set task runner to use for device polling & initialization.
virtual void SetFileTaskRunner(scoped_refptr<base::TaskRunner> task_runner)
OVERRIDE;
+ virtual void WarpCursorTo(gfx::AcceleratedWidget widget,
+ const gfx::PointF& location) OVERRIDE;
private:
// Open device at path & starting processing events (on UI thread).
@@ -60,6 +63,9 @@ class EVENTS_EXPORT EventFactoryEvdev : public EventFactoryOzone {
// Modifier key state (shift, ctrl, etc).
EventModifiersEvdev modifiers_;
+ // Cursor movement.
+ CursorDelegateEvdev* cursor_;
+
// Support weak pointers for attach & detach callbacks.
base::WeakPtrFactory<EventFactoryEvdev> weak_ptr_factory_;
diff --git a/ui/events/ozone/event_factory_ozone.cc b/ui/events/ozone/event_factory_ozone.cc
index cc9acc8..730975b 100644
--- a/ui/events/ozone/event_factory_ozone.cc
+++ b/ui/events/ozone/event_factory_ozone.cc
@@ -41,6 +41,11 @@ void EventFactoryOzone::StartProcessingEvents() {}
void EventFactoryOzone::SetFileTaskRunner(
scoped_refptr<base::TaskRunner> task_runner) {}
+void EventFactoryOzone::WarpCursorTo(gfx::AcceleratedWidget widget,
+ const gfx::PointF& location) {
+ NOTIMPLEMENTED();
+}
+
// static
void EventFactoryOzone::DispatchEvent(scoped_ptr<ui::Event> event) {
base::MessageLoop::current()->PostTask(
diff --git a/ui/events/ozone/event_factory_ozone.h b/ui/events/ozone/event_factory_ozone.h
index 438a57f..49e92dd 100644
--- a/ui/events/ozone/event_factory_ozone.h
+++ b/ui/events/ozone/event_factory_ozone.h
@@ -11,6 +11,11 @@
#include "base/message_loop/message_pump_libevent.h"
#include "base/task_runner.h"
#include "ui/events/events_export.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace gfx {
+class PointF;
+}
namespace ui {
@@ -39,6 +44,12 @@ class EVENTS_EXPORT EventFactoryOzone {
// to event dispatching.
virtual void SetFileTaskRunner(scoped_refptr<base::TaskRunner> task_runner);
+ // Request to warp the cursor to a location within an AccelerateWidget.
+ // If the cursor actually moves, the implementation must dispatch a mouse
+ // move event with the new location.
+ virtual void WarpCursorTo(gfx::AcceleratedWidget widget,
+ const gfx::PointF& location);
+
// Returns the static instance last set using SetInstance().
static EventFactoryOzone* GetInstance();