summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-23 22:33:17 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-23 22:33:17 +0000
commit2e75b1d84ded96bd8e38b2f7ccb8a1b1cb96a2e4 (patch)
treec9d8e78ef23f59bed5cd3396550512b408ef11a2 /ui
parent6619897f398b46546de1dce5a04027aabf0516f6 (diff)
downloadchromium_src-2e75b1d84ded96bd8e38b2f7ccb8a1b1cb96a2e4.zip
chromium_src-2e75b1d84ded96bd8e38b2f7ccb8a1b1cb96a2e4.tar.gz
chromium_src-2e75b1d84ded96bd8e38b2f7ccb8a1b1cb96a2e4.tar.bz2
aura: Make sure event copying works properly for X11.
This includes two changes: * In X11, copying event is tricky, especially for XInput2 events. So avoid doing that when possible. * Mouse-wheel events used to piggy-back on MouseEvents during dispatch, and the offset used to be extracted from the native-event. Fix this to make sure the wheel-events are more like scroll-events so that the offset is carried with the ui::Event during dispatch to avoid dependency on the native-event. BUG=144211 Review URL: https://chromiumcodereview.appspot.com/10875018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153094 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/root_window.cc13
-rw-r--r--ui/aura/root_window_host_linux.cc6
-rw-r--r--ui/base/event.cc8
-rw-r--r--ui/base/event.h10
4 files changed, 32 insertions, 5 deletions
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index 797560b..d274b86 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -1025,9 +1025,16 @@ bool RootWindow::DispatchMouseEventToTarget(ui::MouseEvent* event,
Window::ConvertPointToTarget(this, target, &location_in_window);
if (IsNonClientLocation(target, location_in_window))
flags |= ui::EF_IS_NON_CLIENT;
- ui::MouseEvent translated_event(
- *event, static_cast<Window*>(this), target, event->type(), flags);
- return ProcessMouseEvent(target, &translated_event);
+ if (event->type() == ui::ET_MOUSEWHEEL) {
+ ui::MouseWheelEvent translated_event(
+ *static_cast<ui::MouseWheelEvent*>(event),
+ static_cast<Window*>(this), target, event->type(), flags);
+ return ProcessMouseEvent(target, &translated_event);
+ } else {
+ ui::MouseEvent translated_event(
+ *event, static_cast<Window*>(this), target, event->type(), flags);
+ return ProcessMouseEvent(target, &translated_event);
+ }
}
return false;
}
diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc
index 503286d..bcf1b6f 100644
--- a/ui/aura/root_window_host_linux.cc
+++ b/ui/aura/root_window_host_linux.cc
@@ -638,7 +638,6 @@ bool RootWindowHostLinux::Dispatch(const base::NativeEvent& event) {
case ui::ET_MOUSE_DRAGGED:
case ui::ET_MOUSE_PRESSED:
case ui::ET_MOUSE_RELEASED:
- case ui::ET_MOUSEWHEEL:
case ui::ET_MOUSE_ENTERED:
case ui::ET_MOUSE_EXITED: {
if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_DRAGGED) {
@@ -670,6 +669,11 @@ bool RootWindowHostLinux::Dispatch(const base::NativeEvent& event) {
delegate_->OnHostMouseEvent(&mouseev);
break;
}
+ case ui::ET_MOUSEWHEEL: {
+ ui::MouseWheelEvent mouseev(xev);
+ delegate_->OnHostMouseEvent(&mouseev);
+ break;
+ }
case ui::ET_SCROLL_FLING_START:
case ui::ET_SCROLL_FLING_CANCEL:
case ui::ET_SCROLL: {
diff --git a/ui/base/event.cc b/ui/base/event.cc
index 2db3b09..1b31197 100644
--- a/ui/base/event.cc
+++ b/ui/base/event.cc
@@ -23,6 +23,8 @@ namespace {
base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) {
#if defined(USE_X11)
+ if (!event || event->type == GenericEvent)
+ return NULL;
XEvent* copy = new XEvent;
*copy = *event;
return copy;
@@ -74,11 +76,15 @@ Event::Event(const base::NativeEvent& native_event,
}
Event::Event(const Event& copy)
- : native_event_(copy.native_event_),
+ : native_event_(::CopyNativeEvent(copy.native_event_)),
type_(copy.type_),
time_stamp_(copy.time_stamp_),
flags_(copy.flags_),
delete_native_event_(false) {
+#if defined(USE_X11)
+ if (native_event_)
+ delete_native_event_ = true;
+#endif
}
void Event::Init() {
diff --git a/ui/base/event.h b/ui/base/event.h
index c34b914..fe4a1e4 100644
--- a/ui/base/event.h
+++ b/ui/base/event.h
@@ -294,6 +294,16 @@ class UI_EXPORT MouseWheelEvent : public MouseEvent {
explicit MouseWheelEvent(const MouseEvent& mouse_event);
explicit MouseWheelEvent(const ScrollEvent& scroll_event);
+ template <class T>
+ MouseWheelEvent(const MouseWheelEvent& model,
+ T* source,
+ T* target,
+ EventType type,
+ int flags)
+ : MouseEvent(model, source, target, type, flags),
+ offset_(model.offset_) {
+ }
+
// The amount to scroll. This is in multiples of kWheelDelta.
// Note: offset() > 0 means scroll up / left.
int offset() const { return offset_; }