summaryrefslogtreecommitdiffstats
path: root/ui/base
diff options
context:
space:
mode:
Diffstat (limited to 'ui/base')
-rw-r--r--ui/base/cocoa/events_mac.mm7
-rw-r--r--ui/base/event.cc12
-rw-r--r--ui/base/event.h20
-rw-r--r--ui/base/events.h4
-rw-r--r--ui/base/win/events_win.cc7
-rw-r--r--ui/base/x/events_x.cc29
6 files changed, 72 insertions, 7 deletions
diff --git a/ui/base/cocoa/events_mac.mm b/ui/base/cocoa/events_mac.mm
index 437b465..4471882 100644
--- a/ui/base/cocoa/events_mac.mm
+++ b/ui/base/cocoa/events_mac.mm
@@ -128,6 +128,13 @@ gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) {
return gfx::Point(NSPointToCGPoint(location));
}
+gfx::Point EventSystemLocationFromNative(
+ const base::NativeEvent& native_event) {
+ // TODO(port): Needs to always return screen position here. Returning normal
+ // origin for now since that's obviously wrong.
+ return gfx::Point(0, 0);
+}
+
KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) {
return ui::KeyboardCodeFromNSEvent(native_event);
}
diff --git a/ui/base/event.cc b/ui/base/event.cc
index f8ab8b6..0294ddd 100644
--- a/ui/base/event.cc
+++ b/ui/base/event.cc
@@ -100,7 +100,9 @@ LocatedEvent::LocatedEvent(const base::NativeEvent& native_event)
EventTypeFromNative(native_event),
EventFlagsFromNative(native_event)),
location_(EventLocationFromNative(native_event)),
- root_location_(location_) {
+ root_location_(location_),
+ valid_system_location_(true),
+ system_location_(ui::EventSystemLocationFromNative(native_event)) {
}
LocatedEvent::LocatedEvent(EventType type,
@@ -109,13 +111,17 @@ LocatedEvent::LocatedEvent(EventType type,
int flags)
: Event(type, flags),
location_(location),
- root_location_(root_location) {
+ root_location_(root_location),
+ valid_system_location_(false),
+ system_location_(0, 0) {
}
LocatedEvent::LocatedEvent(const LocatedEvent& model)
: Event(model),
location_(model.location_),
- root_location_(model.root_location_) {
+ root_location_(model.root_location_),
+ valid_system_location_(model.valid_system_location_),
+ system_location_(model.system_location_) {
}
void LocatedEvent::UpdateForRootTransform(const Transform& root_transform) {
diff --git a/ui/base/event.h b/ui/base/event.h
index 43fb253..d7b2c2c 100644
--- a/ui/base/event.h
+++ b/ui/base/event.h
@@ -136,6 +136,13 @@ class UI_EXPORT LocatedEvent : public Event {
gfx::Point location() const { return location_; }
gfx::Point root_location() const { return root_location_; }
+ bool valid_system_location() const { return valid_system_location_; }
+ void set_system_location(const gfx::Point& loc) {
+ valid_system_location_ = true;
+ system_location_ = loc;
+ }
+ const gfx::Point& system_location() const { return system_location_; }
+
// Applies |root_transform| to the event.
// This is applied to both |location_| and |root_location_|.
virtual void UpdateForRootTransform(const Transform& root_transform);
@@ -150,7 +157,11 @@ class UI_EXPORT LocatedEvent : public Event {
LocatedEvent(const LocatedEvent& model, T* source, T* target)
: Event(model),
location_(model.location_),
- root_location_(model.root_location_) {
+ root_location_(model.root_location_),
+ valid_system_location_(model.valid_system_location_),
+ system_location_(model.system_location_) {
+ // TODO(erg): May need to create system_location_ by converting location to
+ // system coordinates here.
if (target && target != source)
T::ConvertPointToTarget(source, target, &location_);
}
@@ -166,7 +177,14 @@ class UI_EXPORT LocatedEvent : public Event {
gfx::Point location_;
+ // |location_| multiplied by an optional transformation matrix for
+ // rotations, animations and skews.
gfx::Point root_location_;
+
+ // |location_| in underlying system screen coordinates. This can be invalid
+ // |during synthesized events if a location isn't explicitly set.
+ bool valid_system_location_;
+ gfx::Point system_location_;
};
class UI_EXPORT MouseEvent : public LocatedEvent {
diff --git a/ui/base/events.h b/ui/base/events.h
index 9c6a36d..69d04f8 100644
--- a/ui/base/events.h
+++ b/ui/base/events.h
@@ -141,6 +141,10 @@ UI_EXPORT base::TimeDelta EventTimeFromNative(
UI_EXPORT gfx::Point EventLocationFromNative(
const base::NativeEvent& native_event);
+// Gets the location in native system coordinate space.
+UI_EXPORT gfx::Point EventSystemLocationFromNative(
+ const base::NativeEvent& native_event);
+
#if defined(USE_X11)
// Returns the 'real' button for an event. The button reported in slave events
// does not take into account any remapping (e.g. using xmodmap), while the
diff --git a/ui/base/win/events_win.cc b/ui/base/win/events_win.cc
index 984e7ca..5cf937c 100644
--- a/ui/base/win/events_win.cc
+++ b/ui/base/win/events_win.cc
@@ -215,6 +215,13 @@ gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) {
return gfx::Point(native_point);
}
+gfx::Point EventSystemLocationFromNative(
+ const base::NativeEvent& native_event) {
+ // TODO(ben): Needs to always return screen position here. Returning normal
+ // origin for now since that's obviously wrong.
+ return gfx::Point(0, 0);
+}
+
KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) {
return KeyboardCodeForWindowsKeyCode(native_event.wParam);
}
diff --git a/ui/base/x/events_x.cc b/ui/base/x/events_x.cc
index 1b8816a..8c2dff2 100644
--- a/ui/base/x/events_x.cc
+++ b/ui/base/x/events_x.cc
@@ -684,12 +684,13 @@ EventType EventTypeFromNative(const base::NativeEvent& native_event) {
bool is_cancel;
if (GetFlingData(native_event, &vx, &vy, &is_cancel)) {
return is_cancel ? ET_SCROLL_FLING_CANCEL : ET_SCROLL_FLING_START;
- } else if (GetScrollOffsets(native_event, NULL, NULL))
+ } else if (GetScrollOffsets(native_event, NULL, NULL)) {
return ET_SCROLL;
- else if (GetButtonMaskForX2Event(xievent)) {
+ } else if (GetButtonMaskForX2Event(xievent)) {
return ET_MOUSE_DRAGGED;
- } else
+ } else {
return ET_MOUSE_MOVED;
+ }
}
}
}
@@ -830,6 +831,28 @@ gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) {
return gfx::Point();
}
+gfx::Point EventSystemLocationFromNative(
+ const base::NativeEvent& native_event) {
+ switch (native_event->type) {
+ case ButtonPress:
+ case ButtonRelease: {
+ return gfx::Point(native_event->xbutton.x_root,
+ native_event->xbutton.y_root);
+ }
+ case MotionNotify: {
+ return gfx::Point(native_event->xmotion.x_root,
+ native_event->xmotion.y_root);
+ }
+ case GenericEvent: {
+ XIDeviceEvent* xievent =
+ static_cast<XIDeviceEvent*>(native_event->xcookie.data);
+ return gfx::Point(xievent->root_x, xievent->root_y);
+ }
+ }
+
+ return gfx::Point();
+}
+
int EventButtonFromNative(const base::NativeEvent& native_event) {
CHECK_EQ(GenericEvent, native_event->type);
XIDeviceEvent* xievent =