summaryrefslogtreecommitdiffstats
path: root/views/touchui
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-20 00:35:34 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-20 00:35:34 +0000
commit7d10b558d19c70318f9d5f2f0e99b44d679d92d5 (patch)
treecd67a1a238ce0ab28e26f98987f1b64cb3073ad6 /views/touchui
parent75d78246ad3bff129539b8259e7b35f2d49117a8 (diff)
downloadchromium_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/touchui')
-rw-r--r--views/touchui/touch_factory.cc79
-rw-r--r--views/touchui/touch_factory.h65
2 files changed, 0 insertions, 144 deletions
diff --git a/views/touchui/touch_factory.cc b/views/touchui/touch_factory.cc
deleted file mode 100644
index 8608782..0000000
--- a/views/touchui/touch_factory.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "views/touchui/touch_factory.h"
-
-#include <gdk/gdkx.h>
-#include <X11/extensions/XInput2.h>
-
-#include "base/logging.h"
-
-namespace views {
-
-// static
-TouchFactory* TouchFactory::GetInstance() {
- return Singleton<TouchFactory>::get();
-}
-
-TouchFactory::TouchFactory()
- : touch_device_lookup_(),
- touch_device_list_() {
-}
-
-void TouchFactory::SetTouchDeviceList(
- const std::vector<unsigned int>& devices) {
- touch_device_lookup_.reset();
- touch_device_list_.clear();
- for (std::vector<unsigned int>::const_iterator iter = devices.begin();
- iter != devices.end(); ++iter) {
- DCHECK(*iter < touch_device_lookup_.size());
- touch_device_lookup_[*iter] = true;
- touch_device_list_.push_back(*iter);
- }
-}
-
-bool TouchFactory::IsTouchDevice(unsigned deviceid) {
- return deviceid < touch_device_lookup_.size() ?
- touch_device_lookup_[deviceid] : false;
-}
-
-bool TouchFactory::GrabTouchDevices(Display* display, ::Window window) {
- if (touch_device_list_.empty())
- return true;
-
- unsigned char mask[(XI_LASTEVENT + 7) / 8];
- bool success = true;
-
- memset(mask, 0, sizeof(mask));
- XISetMask(mask, XI_ButtonPress);
- XISetMask(mask, XI_ButtonRelease);
- XISetMask(mask, XI_Motion);
-
- XIEventMask evmask;
- evmask.mask_len = sizeof(mask);
- evmask.mask = mask;
- for (std::vector<int>::const_iterator iter =
- touch_device_list_.begin();
- iter != touch_device_list_.end(); ++iter) {
- evmask.deviceid = *iter;
- Status status = XIGrabDevice(display, *iter, window, CurrentTime, None,
- GrabModeAsync, GrabModeAsync, False, &evmask);
- success = success && status == GrabSuccess;
- }
-
- return success;
-}
-
-bool TouchFactory::UngrabTouchDevices(Display* display) {
- bool success = true;
- for (std::vector<int>::const_iterator iter =
- touch_device_list_.begin();
- iter != touch_device_list_.end(); ++iter) {
- Status status = XIUngrabDevice(display, *iter, CurrentTime);
- success = success && status == GrabSuccess;
- }
- return success;
-}
-
-} // namespace views
diff --git a/views/touchui/touch_factory.h b/views/touchui/touch_factory.h
deleted file mode 100644
index 04114be..0000000
--- a/views/touchui/touch_factory.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef VIEWS_TOUCHUI_TOUCH_FACTORY_H_
-#define VIEWS_TOUCHUI_TOUCH_FACTORY_H_
-#pragma once
-
-#include <bitset>
-#include <vector>
-
-#include "base/singleton.h"
-
-typedef unsigned long Window;
-typedef struct _XDisplay Display;
-
-namespace views {
-
-// Functions related to determining touch devices.
-class TouchFactory {
- public:
- // Returns the TouchFactory singleton.
- static TouchFactory* GetInstance();
-
- // 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. The list is reset each
- // time this is called.
- void SetTouchDeviceList(const std::vector<unsigned int>& devices);
-
- // Is the device a touch-device?
- bool IsTouchDevice(unsigned int deviceid);
-
- // Grab the touch devices for the specified window on the specified display.
- // Returns if grab was successful for all touch devices.
- bool GrabTouchDevices(Display* display, ::Window window);
-
- // Ungrab the touch devices. Returns if ungrab was successful for all touch
- // devices.
- bool UngrabTouchDevices(Display* display);
-
- private:
- TouchFactory();
-
- // Requirement for Signleton
- friend struct DefaultSingletonTraits<TouchFactory>;
-
- // NOTE: To keep track of touch devices, we currently maintain a lookup table
- // to quickly decide if a device is a touch device or not. We also maintain a
- // list of the touch devices. Ideally, there will be only one touch device,
- // and instead of having the lookup table and the list, there will be a single
- // identifier for the touch device. This can be completed after enough testing
- // on real touch devices.
-
- // A quick lookup table for determining if a device is a touch device.
- std::bitset<128> touch_device_lookup_;
-
- // The list of touch devices.
- std::vector<int> touch_device_list_;
-
- DISALLOW_COPY_AND_ASSIGN(TouchFactory);
-};
-
-} // namespace views
-
-#endif // VIEWS_TOUCHUI_TOUCH_FACTORY_H_