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

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: Don't hide cursor when a mouse event is in progress. Created 9 years, 10 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/focus/accelerator_handler_touch.cc ('k') | views/touchui/touch_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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. Also indicate whether
44 // the timer should be started to automatically hide the cursor after a
45 // certain duration of inactivity (i.e. it is ignored if |show| is false).
46 void SetCursorVisible(bool show, bool start_timer);
47
48 // Whether the cursor is currently visible or not.
49 bool IsCursorVisible() {
sky 2011/01/26 21:08:19 Name this is_cursor_visible() . Style guide says a
50 return is_cursor_visible_;
51 }
52
41 private: 53 private:
42 TouchFactory(); 54 TouchFactory();
43 55
56 ~TouchFactory();
57
58 void HideCursorForInactivity() {
59 SetCursorVisible(false, false);
60 }
61
44 // Requirement for Signleton 62 // Requirement for Signleton
45 friend struct DefaultSingletonTraits<TouchFactory>; 63 friend struct DefaultSingletonTraits<TouchFactory>;
46 64
65 // The default cursor is hidden after startup, and when the mouse pointer is
66 // idle for a while. Once there is some event from a mouse device, the cursor
67 // is immediately displayed.
68 bool is_cursor_visible_;
69
70 // The cursor is hidden if it is idle for a certain amount time. This timer
71 // is used to keep track of the idleness.
72 base::OneShotTimer<TouchFactory> cursor_timer_;
73
74 // The invisible cursor.
75 Cursor invisible_cursor_;
76
47 // NOTE: To keep track of touch devices, we currently maintain a lookup table 77 // 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 78 // 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, 79 // 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 80 // 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 81 // identifier for the touch device. This can be completed after enough testing
52 // on real touch devices. 82 // on real touch devices.
53 83
54 // A quick lookup table for determining if a device is a touch device. 84 // A quick lookup table for determining if a device is a touch device.
55 std::bitset<128> touch_device_lookup_; 85 std::bitset<128> touch_device_lookup_;
56 86
57 // The list of touch devices. 87 // The list of touch devices.
58 std::vector<int> touch_device_list_; 88 std::vector<int> touch_device_list_;
59 89
60 DISALLOW_COPY_AND_ASSIGN(TouchFactory); 90 DISALLOW_COPY_AND_ASSIGN(TouchFactory);
61 }; 91 };
62 92
63 } // namespace views 93 } // namespace views
64 94
65 #endif // VIEWS_TOUCHUI_TOUCH_FACTORY_H_ 95 #endif // VIEWS_TOUCHUI_TOUCH_FACTORY_H_
OLDNEW
« no previous file with comments | « views/focus/accelerator_handler_touch.cc ('k') | views/touchui/touch_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698