diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-15 17:52:02 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-15 17:52:02 +0000 |
commit | aca200e532f35181e8ae0d66e7f27ca7c6966bd1 (patch) | |
tree | 299d4785d08390f53efb91ac31c1c6d80d6dc130 /ui/aura | |
parent | 112f03ff93d980249601674796f12f5bab4ee839 (diff) | |
download | chromium_src-aca200e532f35181e8ae0d66e7f27ca7c6966bd1.zip chromium_src-aca200e532f35181e8ae0d66e7f27ca7c6966bd1.tar.gz chromium_src-aca200e532f35181e8ae0d66e7f27ca7c6966bd1.tar.bz2 |
CMT can now generate motion events w/ valuators instead of a sequence of button events. This supports them
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/8907005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114660 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura')
-rw-r--r-- | ui/aura/event.cc | 5 | ||||
-rw-r--r-- | ui/aura/event.h | 23 | ||||
-rw-r--r-- | ui/aura/root_window.cc | 22 | ||||
-rw-r--r-- | ui/aura/root_window.h | 5 | ||||
-rw-r--r-- | ui/aura/root_window_host_linux.cc | 28 |
5 files changed, 72 insertions, 11 deletions
diff --git a/ui/aura/event.cc b/ui/aura/event.cc index 5cb2fd8..980b129 100644 --- a/ui/aura/event.cc +++ b/ui/aura/event.cc @@ -251,4 +251,9 @@ uint16 KeyEvent::GetUnmodifiedCharacter() const { #endif } +ScrollEvent::ScrollEvent(const base::NativeEvent& native_event) + : MouseEvent(native_event) { + ui::GetScrollOffsets(native_event, &x_offset_, &y_offset_); +} + } // namespace aura diff --git a/ui/aura/event.h b/ui/aura/event.h index 5dcb726..f4478f8 100644 --- a/ui/aura/event.h +++ b/ui/aura/event.h @@ -204,6 +204,29 @@ class AURA_EXPORT DropTargetEvent : public LocatedEvent { DISALLOW_COPY_AND_ASSIGN(DropTargetEvent); }; +class AURA_EXPORT ScrollEvent : public MouseEvent { + public: + ScrollEvent(const base::NativeEvent& native_event); + ScrollEvent(const ScrollEvent& model, + Window* source, + Window* target, + ui::EventType type, + int flags) + : MouseEvent(model, source, target, type, flags), + x_offset_(model.x_offset_), + y_offset_(model.y_offset_) { + } + + float x_offset() const { return x_offset_; } + float y_offset() const { return y_offset_; } + + private: + float x_offset_; + float y_offset_; + + DISALLOW_COPY_AND_ASSIGN(ScrollEvent); +}; + } // namespace aura #endif // UI_AURA_EVENT_H_ diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc index 10535a7..ed230a5 100644 --- a/ui/aura/root_window.cc +++ b/ui/aura/root_window.cc @@ -170,6 +170,28 @@ bool RootWindow::DispatchKeyEvent(KeyEvent* event) { return false; } +bool RootWindow::DispatchScrollEvent(ScrollEvent* event) { + event->UpdateForTransform(layer()->transform()); + + last_mouse_location_ = event->location(); + + Window* target = + mouse_pressed_handler_ ? mouse_pressed_handler_ : capture_window_; + if (!target) + target = GetEventHandlerForPoint(event->location()); + + if (target && target->delegate()) { + int flags = event->flags(); + gfx::Point location_in_window = event->location(); + Window::ConvertPointToWindow(this, target, &location_in_window); + if (IsNonClientLocation(target, location_in_window)) + flags |= ui::EF_IS_NON_CLIENT; + ScrollEvent translated_event(*event, this, target, event->type(), flags); + return ProcessMouseEvent(target, &translated_event); + } + return false; +} + bool RootWindow::DispatchTouchEvent(TouchEvent* event) { event->UpdateForTransform(layer()->transform()); bool handled = false; diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h index 76f70b5..f7b0862 100644 --- a/ui/aura/root_window.h +++ b/ui/aura/root_window.h @@ -37,6 +37,8 @@ class RootWindowObserver; class KeyEvent; class MouseEvent; class ScreenAura; +class StackingClient; +class ScrollEvent; class TouchEvent; // RootWindow is responsible for hosting a set of windows. @@ -81,6 +83,9 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate, // Handles a key event. Returns true if handled. bool DispatchKeyEvent(KeyEvent* event); + // Handles a scroll event. Returns true if handled. + bool DispatchScrollEvent(ScrollEvent* event); + // Handles a touch event. Returns true if handled. bool DispatchTouchEvent(TouchEvent* event); diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc index d577acd..6ed655b 100644 --- a/ui/aura/root_window_host_linux.cc +++ b/ui/aura/root_window_host_linux.cc @@ -197,7 +197,8 @@ int CoalescePendingXIMotionEvents(const XEvent* xev, XEvent* last_event) { } if (next_event.type == GenericEvent && - next_event.xgeneric.evtype == XI_Motion) { + next_event.xgeneric.evtype == XI_Motion && + !ui::GetScrollOffsets(&next_event, NULL, NULL)) { XIDeviceEvent* next_xievent = static_cast<XIDeviceEvent*>(next_event.xcookie.data); // Confirm that the motion event is targeted at the same window @@ -343,7 +344,6 @@ RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds) XSelectInput(xdisplay_, x_root_window_, StructureNotifyMask); XFlush(xdisplay_); - // TODO(sad): Re-enable once crbug.com/106516 is fixed. if (base::MessagePumpForUI::HasXInput2()) ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_); @@ -422,22 +422,17 @@ base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch( // Update the device list if necessary. if (xev->xgeneric.evtype == XI_HierarchyChanged) { - factory->UpdateDeviceList(xdisplay_); + ui::UpdateDeviceList(); handled = true; break; } + ui::EventType type = ui::EventTypeFromNative(xev); // If this is a motion event we want to coalesce all pending motion // events that are at the top of the queue. XEvent last_event; int num_coalesced = 0; - if (xev->xgeneric.evtype == XI_Motion) { - num_coalesced = CoalescePendingXIMotionEvents(xev, &last_event); - if (num_coalesced > 0) - xev = &last_event; - } - ui::EventType type = ui::EventTypeFromNative(xev); switch (type) { case ui::ET_TOUCH_PRESSED: case ui::ET_TOUCH_RELEASED: @@ -446,10 +441,16 @@ base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch( handled = root_window_->DispatchTouchEvent(&touchev); break; } + case ui::ET_MOUSE_MOVED: + case ui::ET_MOUSE_DRAGGED: { + // If this is a motion event we want to coalesce all pending motion + // events that are at the top of the queue. + num_coalesced = CoalescePendingXIMotionEvents(xev, &last_event); + if (num_coalesced > 0) + xev = &last_event; + } case ui::ET_MOUSE_PRESSED: case ui::ET_MOUSE_RELEASED: - case ui::ET_MOUSE_MOVED: - case ui::ET_MOUSE_DRAGGED: case ui::ET_MOUSEWHEEL: case ui::ET_MOUSE_ENTERED: case ui::ET_MOUSE_EXITED: { @@ -457,6 +458,11 @@ base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch( handled = root_window_->DispatchMouseEvent(&mouseev); break; } + case ui::ET_SCROLL: { + ScrollEvent scrollev(xev); + handled = root_window_->DispatchScrollEvent(&scrollev); + break; + } case ui::ET_UNKNOWN: handled = false; break; |