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

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

Issue 6242012: touch: Hide the X cursor when not in use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplify 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef VIEWS_TOUCHUI_TOUCH_FACTORY_H_ 5 #ifndef VIEWS_TOUCHUI_TOUCH_FACTORY_H_
6 #define VIEWS_TOUCHUI_TOUCH_FACTORY_H_ 6 #define VIEWS_TOUCHUI_TOUCH_FACTORY_H_
7 #pragma once 7 #pragma once
8 8
9 #include <bitset> 9 #include <bitset>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/singleton.h" 12 #include "base/singleton.h"
13 #include "base/timer.h"
13 14
15 typedef unsigned long Cursor;
14 typedef unsigned long Window; 16 typedef unsigned long Window;
15 typedef struct _XDisplay Display; 17 typedef struct _XDisplay Display;
16 18
17 namespace views { 19 namespace views {
18 20
19 // Functions related to determining touch devices. 21 // Functions related to determining touch devices.
20 class TouchFactory { 22 class TouchFactory {
21 public: 23 public:
22 // Returns the TouchFactory singleton. 24 // Returns the TouchFactory singleton.
23 static TouchFactory* GetInstance(); 25 static TouchFactory* GetInstance();
24 26
25 // Keep a list of touch devices so that it is possible to determine if a 27 // Keep a list of touch devices so that it is possible to determine if a
26 // pointer event is a touch-event or a mouse-event. The list is reset each 28 // pointer event is a touch-event or a mouse-event. The list is reset each
27 // time this is called. 29 // time this is called.
28 void SetTouchDeviceList(const std::vector<unsigned int>& devices); 30 void SetTouchDeviceList(const std::vector<unsigned int>& devices);
29 31
30 // Is the device a touch-device? 32 // Is the device a touch-device?
31 bool IsTouchDevice(unsigned int deviceid); 33 bool IsTouchDevice(unsigned int deviceid);
32 34
33 // Grab the touch devices for the specified window on the specified display. 35 // Grab the touch devices for the specified window on the specified display.
34 // Returns if grab was successful for all touch devices. 36 // Returns if grab was successful for all touch devices.
35 bool GrabTouchDevices(Display* display, ::Window window); 37 bool GrabTouchDevices(Display* display, ::Window window);
36 38
37 // Ungrab the touch devices. Returns if ungrab was successful for all touch 39 // Ungrab the touch devices. Returns if ungrab was successful for all touch
38 // devices. 40 // devices.
39 bool UngrabTouchDevices(Display* display); 41 bool UngrabTouchDevices(Display* display);
40 42
43 // Update the root window to show (or hide) the cursor.
44 void SetCursorVisibility(bool show);
sky 2011/01/26 16:17:00 SetCursorVisible.
sadrul 2011/01/26 17:57:11 Done.
45
46 // Whether the cursor is currently visible or not.
47 bool IsCursorVisible() {
sky 2011/01/26 16:17:00 Name of method should match field name and be unix
sadrul 2011/01/26 17:57:11 Cool. Done.
48 return !hiding_cursor_;
49 }
50
41 private: 51 private:
42 TouchFactory(); 52 TouchFactory();
43 53
54 ~TouchFactory();
55
56 void HideCursorForInactivity() {
57 SetCursorVisibility(false);
58 }
59
44 // Requirement for Signleton 60 // Requirement for Signleton
45 friend struct DefaultSingletonTraits<TouchFactory>; 61 friend struct DefaultSingletonTraits<TouchFactory>;
46 62
63 // The default cursor is hidden after startup, and when the mouse pointer is
64 // idle for a while. Once there is some event from a mouse device, the cursor
65 // is immediately displayed.
66 bool hiding_cursor_;
67
68 // The cursor is hidden if it is idle for a certain amount time. This timer
69 // is used to keep track of the idleness.
70 base::DelayTimer<TouchFactory> cursor_timer_;
71
72 // The invisible cursor.
73 Cursor invisible_;
sky 2011/01/26 16:17:00 invisible_ -> invisible_cursor_
sadrul 2011/01/26 17:57:11 Done.
74
47 // NOTE: To keep track of touch devices, we currently maintain a lookup table 75 // NOTE: To keep track of touch devices, we currently maintain a lookup table
48 // to quickly decide if a device is a touch device or not. We also maintain a 76 // to quickly decide if a device is a touch device or not. We also maintain a
49 // list of the touch devices. Ideally, there will be only one touch device, 77 // list of the touch devices. Ideally, there will be only one touch device,
50 // and instead of having the lookup table and the list, there will be a single 78 // and instead of having the lookup table and the list, there will be a single
51 // identifier for the touch device. This can be completed after enough testing 79 // identifier for the touch device. This can be completed after enough testing
52 // on real touch devices. 80 // on real touch devices.
53 81
54 // A quick lookup table for determining if a device is a touch device. 82 // A quick lookup table for determining if a device is a touch device.
55 std::bitset<128> touch_device_lookup_; 83 std::bitset<128> touch_device_lookup_;
56 84
57 // The list of touch devices. 85 // The list of touch devices.
58 std::vector<int> touch_device_list_; 86 std::vector<int> touch_device_list_;
59 87
60 DISALLOW_COPY_AND_ASSIGN(TouchFactory); 88 DISALLOW_COPY_AND_ASSIGN(TouchFactory);
61 }; 89 };
62 90
63 } // namespace views 91 } // namespace views
64 92
65 #endif // VIEWS_TOUCHUI_TOUCH_FACTORY_H_ 93 #endif // VIEWS_TOUCHUI_TOUCH_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698