Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Side by Side Diff: views/touchui/touch_factory.cc

Issue 6349008: Revert 71879 due to compile failure - touch: Allow grabbing/ungrabbing touch ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/touchui/touch_factory.h ('k') | views/views.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "views/touchui/touch_factory.h"
6
7 #include <gdk/gdkx.h>
8 #include <X11/extensions/XInput2.h>
9
10 #include "base/logging.h"
11
12 namespace views {
13
14 // static
15 TouchFactory* TouchFactory::GetInstance() {
16 return Singleton<TouchFactory>::get();
17 }
18
19 TouchFactory::TouchFactory()
20 : touch_device_lookup_(),
21 touch_device_list_() {
22 }
23
24 void TouchFactory::SetTouchDeviceList(
25 const std::vector<unsigned int>& devices) {
26 touch_device_lookup_.reset();
27 touch_device_list_.clear();
28 for (std::vector<unsigned int>::const_iterator iter = devices.begin();
29 iter != devices.end(); ++iter) {
30 DCHECK(*iter < touch_device_lookup_.size());
31 touch_device_lookup_[*iter] = true;
32 touch_device_list_.push_back(*iter);
33 }
34 }
35
36 bool TouchFactory::IsTouchDevice(unsigned deviceid) {
37 return deviceid < touch_device_lookup_.size() ?
38 touch_device_lookup_[deviceid] : false;
39 }
40
41 bool TouchFactory::GrabTouchDevices(Display* display, ::Window window) {
42 if (touch_device_list_.empty())
43 return true;
44
45 unsigned char mask[(XI_LASTEVENT + 7) / 8];
46 bool success = true;
47
48 memset(mask, 0, sizeof(mask));
49 XISetMask(mask, XI_ButtonPress);
50 XISetMask(mask, XI_ButtonRelease);
51 XISetMask(mask, XI_Motion);
52
53 XIEventMask evmask;
54 evmask.mask_len = sizeof(mask);
55 evmask.mask = mask;
56 for (std::vector<int>::const_iterator iter =
57 touch_device_list_.begin();
58 iter != touch_device_list_.end(); ++iter) {
59 evmask.deviceid = *iter;
60 Status status = XIGrabDevice(display, *iter, window, CurrentTime, None,
61 GrabModeAsync, GrabModeAsync, False, &evmask);
62 success = success && status == GrabSuccess;
63 }
64
65 return success;
66 }
67
68 bool TouchFactory::UngrabTouchDevices(Display* display) {
69 bool success = true;
70 for (std::vector<int>::const_iterator iter =
71 touch_device_list_.begin();
72 iter != touch_device_list_.end(); ++iter) {
73 Status status = XIUngrabDevice(display, *iter, CurrentTime);
74 success = success && status == GrabSuccess;
75 }
76 return success;
77 }
78
79 } // namespace views
OLDNEW
« no previous file with comments | « views/touchui/touch_factory.h ('k') | views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698