diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-20 00:35:34 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-20 00:35:34 +0000 |
commit | 7d10b558d19c70318f9d5f2f0e99b44d679d92d5 (patch) | |
tree | cd67a1a238ce0ab28e26f98987f1b64cb3073ad6 /views/focus/accelerator_handler_touch.cc | |
parent | 75d78246ad3bff129539b8259e7b35f2d49117a8 (diff) | |
download | chromium_src-7d10b558d19c70318f9d5f2f0e99b44d679d92d5.zip chromium_src-7d10b558d19c70318f9d5f2f0e99b44d679d92d5.tar.gz chromium_src-7d10b558d19c70318f9d5f2f0e99b44d679d92d5.tar.bz2 |
Revert 71879 due to compile failure - touch: Allow grabbing/ungrabbing touch devices for XInput2.
This allows touch devices to be grabbed when events from the mouse/keyboard are
grabbed. This also exposes TouchFactory, which will eventually be used in more
places.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6300007
TBR=sadrul@chromium.org
Review URL: http://codereview.chromium.org/6349008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71885 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/focus/accelerator_handler_touch.cc')
-rw-r--r-- | views/focus/accelerator_handler_touch.cc | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/views/focus/accelerator_handler_touch.cc b/views/focus/accelerator_handler_touch.cc index b24d8f0..84c042d 100644 --- a/views/focus/accelerator_handler_touch.cc +++ b/views/focus/accelerator_handler_touch.cc @@ -15,12 +15,41 @@ #include "views/accelerator.h" #include "views/event.h" #include "views/focus/focus_manager.h" -#include "views/touchui/touch_factory.h" #include "views/widget/root_view.h" #include "views/widget/widget_gtk.h" namespace views { +#if defined(HAVE_XINPUT2) +// Functions related to determining touch devices. +class TouchFactory { + public: + // Keep a list of touch devices so that it is possible to determine if a + // pointer event is a touch-event or a mouse-event. + static void SetTouchDeviceListInternal( + const std::vector<unsigned int>& devices) { + for (std::vector<unsigned int>::const_iterator iter = devices.begin(); + iter != devices.end(); ++iter) { + DCHECK(*iter < touch_devices.size()); + touch_devices[*iter] = true; + } + } + + // Is the device a touch-device? + static bool IsTouchDevice(unsigned int deviceid) { + return deviceid < touch_devices.size() ? touch_devices[deviceid] : false; + } + + private: + // A quick lookup table for determining if a device is a touch device. + static std::bitset<128> touch_devices; + + DISALLOW_COPY_AND_ASSIGN(TouchFactory); +}; + +std::bitset<128> TouchFactory::touch_devices; +#endif + namespace { RootView* FindRootViewForGdkWindow(GdkWindow* gdk_window) { @@ -49,7 +78,7 @@ bool X2EventIsTouchEvent(XEvent* xev) { case XI_ButtonRelease: case XI_Motion: { // Is the event coming from a touch device? - return TouchFactory::GetInstance()->IsTouchDevice( + return TouchFactory::IsTouchDevice( static_cast<XIDeviceEvent*>(cookie->data)->sourceid); } default: @@ -171,7 +200,7 @@ bool DispatchXEvent(XEvent* xev) { #if defined(HAVE_XINPUT2) void SetTouchDeviceList(std::vector<unsigned int>& devices) { - TouchFactory::GetInstance()->SetTouchDeviceList(devices); + TouchFactory::SetTouchDeviceListInternal(devices); } #endif |