diff options
author | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-26 22:04:44 +0000 |
---|---|---|
committer | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-26 22:04:44 +0000 |
commit | a3e2de75e309b527cd694b16d23100bbec1710d9 (patch) | |
tree | 30f49027fbf74758595ee30b0b301206a4c2becf /views/focus | |
parent | e30e4d816f7e32f2be39f32159e020d3b037de04 (diff) | |
download | chromium_src-a3e2de75e309b527cd694b16d23100bbec1710d9.zip chromium_src-a3e2de75e309b527cd694b16d23100bbec1710d9.tar.gz chromium_src-a3e2de75e309b527cd694b16d23100bbec1710d9.tar.bz2 |
Consolidate/cleanup event cracking code; single out GdkEvents; saves ~850 lines.
Move ui::NativeEvent typdefs and common functions to ui/base/events.h.
Remove NativeEvent2 typedef, single out GdkEvent* uses that should be removed.
Implement platform specific ui/base/[platform]/events_[platform].cc.
Revise views::NativeEvent definitions (to support Aura abstraction).
Consolidate Event[Type/Flags/Location]FromNative(), GetMouseWheelOffset(), etc.
Remove GetRepeatCount(), GetWindowsFlags(), IsExtendedKey(), etc.
Add IsMouseEvent(), KeyboardCodeFromNative(), EF_EXTENDED flag, etc.
Localize GetFlagsFromGdkEvent(), move some file locals to new helpers files.
Move views/touchui/touch_factory.h|cc to ui/base/touch.
Stop mixing Windows mouse events' MK_*BUTTON into their wParams.
BUG=93945
TEST=No build breaks (many configs...), no mouse/key behavior changes.
Review URL: http://codereview.chromium.org/7942004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102815 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/focus')
-rw-r--r-- | views/focus/accelerator_handler_touch.cc | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/views/focus/accelerator_handler_touch.cc b/views/focus/accelerator_handler_touch.cc index fbfa2f8..c9784dd 100644 --- a/views/focus/accelerator_handler_touch.cc +++ b/views/focus/accelerator_handler_touch.cc @@ -8,11 +8,11 @@ #include <gtk/gtk.h> #include <X11/extensions/XInput2.h> +#include "ui/base/touch/touch_factory.h" #include "views/accelerator.h" #include "views/events/event.h" #include "views/focus/focus_manager.h" #include "views/ime/input_method.h" -#include "views/touchui/touch_factory.h" #include "views/view.h" #include "views/widget/native_widget.h" @@ -54,7 +54,7 @@ bool DispatchX2Event(Widget* widget, XEvent* xev) { Event::FromNativeEvent2 from_native; // Hide the cursor when a touch event comes in. - TouchFactory::GetInstance()->SetCursorVisible(false, false); + ui::TouchFactory::GetInstance()->SetCursorVisible(false, false); // If the TouchEvent is processed by |widget|, then return. TouchEvent touch(xev, from_native); @@ -71,19 +71,18 @@ bool DispatchX2Event(Widget* widget, XEvent* xev) { case XI_ButtonRelease: case XI_Motion: { XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(cookie->data); - Event::FromNativeEvent2 from_native; // Scrolling the wheel generates press/release events with button id's 4 // and 5. In case of a wheelscroll, we do not want to show the cursor. if (xievent->detail == 4 || xievent->detail == 5) { - MouseWheelEvent wheelev(xev, from_native); + MouseWheelEvent wheelev(xev); return widget->OnMouseEvent(wheelev); } // Is the event coming from a touch device? - if (TouchFactory::GetInstance()->IsTouchDevice(xievent->sourceid)) { + if (ui::TouchFactory::GetInstance()->IsTouchDevice(xievent->sourceid)) { // Hide the cursor when a touch event comes in. - TouchFactory::GetInstance()->SetCursorVisible(false, false); + ui::TouchFactory::GetInstance()->SetCursorVisible(false, false); // With XInput 2.0, XI_ButtonPress and XI_ButtonRelease events are // ignored, as XI_Motion events contain enough data to detect finger @@ -94,7 +93,7 @@ bool DispatchX2Event(Widget* widget, XEvent* xev) { // If the TouchEvent is processed by |widget|, then return. Otherwise // let it fall through so it can be used as a MouseEvent, if desired. - TouchEvent touch(xev, from_native); + TouchEvent touch(xev); if (widget->OnTouchEvent(touch) != ui::TOUCH_STATUS_UNKNOWN) return true; @@ -103,7 +102,7 @@ bool DispatchX2Event(Widget* widget, XEvent* xev) { // RootView::OnTouchEvent. return false; } else { - MouseEvent mouseev(xev, from_native); + MouseEvent mouseev(xev); // Show the cursor. Start a timer to hide the cursor after a delay on // move (not drag) events, or if the only button pressed is released. @@ -112,7 +111,7 @@ bool DispatchX2Event(Widget* widget, XEvent* xev) { (mouseev.IsOnlyLeftMouseButton() || mouseev.IsOnlyMiddleMouseButton() || mouseev.IsOnlyRightMouseButton()); - TouchFactory::GetInstance()->SetCursorVisible(true, start_timer); + ui::TouchFactory::GetInstance()->SetCursorVisible(true, start_timer); return widget->OnMouseEvent(mouseev); } @@ -126,12 +125,12 @@ bool DispatchXEvent(XEvent* xev) { XID xwindow = xev->xany.window; if (xev->type == GenericEvent) { - if (!TouchFactory::GetInstance()->ShouldProcessXI2Event(xev)) + if (!ui::TouchFactory::GetInstance()->ShouldProcessXI2Event(xev)) return true; // Consume the event. XGenericEventCookie* cookie = &xev->xcookie; if (cookie->evtype == XI_HierarchyChanged) { - TouchFactory::GetInstance()->UpdateDeviceList(cookie->display); + ui::TouchFactory::GetInstance()->UpdateDeviceList(cookie->display); return true; } @@ -142,11 +141,10 @@ bool DispatchXEvent(XEvent* xev) { GdkWindow* gwind = gdk_window_lookup_for_display(gdisp, xwindow); Widget* widget = FindWidgetForGdkWindow(gwind); if (widget) { - Event::FromNativeEvent2 from_native; switch (xev->type) { case KeyPress: case KeyRelease: { - KeyEvent keyev(xev, from_native); + KeyEvent keyev(xev); InputMethod* ime = widget->GetInputMethod(); // Always dispatch key events to the input method first, to make sure // that the input method's hotkeys work all time. @@ -160,12 +158,12 @@ bool DispatchXEvent(XEvent* xev) { case ButtonRelease: if (xev->xbutton.button == 4 || xev->xbutton.button == 5) { // Scrolling the wheel triggers button press/release events. - MouseWheelEvent wheelev(xev, from_native); + MouseWheelEvent wheelev(xev); return widget->OnMouseEvent(wheelev); } // fallthrough case MotionNotify: { - MouseEvent mouseev(xev, from_native); + MouseEvent mouseev(xev); return widget->OnMouseEvent(mouseev); } @@ -179,7 +177,7 @@ bool DispatchXEvent(XEvent* xev) { } void SetTouchDeviceList(std::vector<unsigned int>& devices) { - TouchFactory::GetInstance()->SetTouchDeviceList(devices); + ui::TouchFactory::GetInstance()->SetTouchDeviceList(devices); } AcceleratorHandler::AcceleratorHandler() {} |