OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 UI_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_ | 5 #ifndef UI_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_ |
6 #define UI_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_ | 6 #define UI_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "ui/base/ui_base_export.h" | 13 #include "ui/base/ui_base_export.h" |
14 #include "ui/gfx/x/x11_types.h" | 14 #include "ui/gfx/x/x11_types.h" |
15 | 15 |
16 // A process wide singleton for selecting events on X windows which were not | 16 // A process wide singleton for selecting events on X windows which were not |
17 // created by Chrome. | 17 // created by Chrome. |
| 18 namespace base { |
18 template <typename T> struct DefaultSingletonTraits; | 19 template <typename T> struct DefaultSingletonTraits; |
| 20 } |
19 | 21 |
20 namespace ui { | 22 namespace ui { |
21 | 23 |
22 // Manages the events that Chrome has selected on X windows which were not | 24 // Manages the events that Chrome has selected on X windows which were not |
23 // created by Chrome. This class allows several clients to select events | 25 // created by Chrome. This class allows several clients to select events |
24 // on the same X window. | 26 // on the same X window. |
25 class UI_BASE_EXPORT XForeignWindowManager { | 27 class UI_BASE_EXPORT XForeignWindowManager { |
26 public: | 28 public: |
27 static XForeignWindowManager* GetInstance(); | 29 static XForeignWindowManager* GetInstance(); |
28 | 30 |
29 // Requests that events associated with |event_mask| on |xid| be reported to | 31 // Requests that events associated with |event_mask| on |xid| be reported to |
30 // Chrome. Returns an id to use for canceling the request. | 32 // Chrome. Returns an id to use for canceling the request. |
31 int RequestEvents(XID xid, long event_mask) WARN_UNUSED_RESULT; | 33 int RequestEvents(XID xid, long event_mask) WARN_UNUSED_RESULT; |
32 | 34 |
33 // Cancels the request with |request_id|. Unless there is another request for | 35 // Cancels the request with |request_id|. Unless there is another request for |
34 // events on the X window associated with |request_id|, this stops Chrome from | 36 // events on the X window associated with |request_id|, this stops Chrome from |
35 // getting events for the X window. | 37 // getting events for the X window. |
36 void CancelRequest(int request_id); | 38 void CancelRequest(int request_id); |
37 | 39 |
38 // Called by X11DesktopHandler when |xid| is destroyed. | 40 // Called by X11DesktopHandler when |xid| is destroyed. |
39 void OnWindowDestroyed(XID xid); | 41 void OnWindowDestroyed(XID xid); |
40 | 42 |
41 private: | 43 private: |
42 friend struct DefaultSingletonTraits<XForeignWindowManager>; | 44 friend struct base::DefaultSingletonTraits<XForeignWindowManager>; |
43 | 45 |
44 struct Request { | 46 struct Request { |
45 Request(int request_id, long entry_event_mask); | 47 Request(int request_id, long entry_event_mask); |
46 ~Request(); | 48 ~Request(); |
47 | 49 |
48 int request_id; | 50 int request_id; |
49 long event_mask; | 51 long event_mask; |
50 }; | 52 }; |
51 | 53 |
52 XForeignWindowManager(); | 54 XForeignWindowManager(); |
53 ~XForeignWindowManager(); | 55 ~XForeignWindowManager(); |
54 | 56 |
55 // Updates which events are selected on |xid|. | 57 // Updates which events are selected on |xid|. |
56 void UpdateSelectedEvents(XID xid); | 58 void UpdateSelectedEvents(XID xid); |
57 | 59 |
58 // The id of the next request. | 60 // The id of the next request. |
59 int next_request_id_; | 61 int next_request_id_; |
60 | 62 |
61 typedef std::vector<Request> RequestVector; | 63 typedef std::vector<Request> RequestVector; |
62 std::map<XID, RequestVector> request_map_; | 64 std::map<XID, RequestVector> request_map_; |
63 | 65 |
64 DISALLOW_COPY_AND_ASSIGN(XForeignWindowManager); | 66 DISALLOW_COPY_AND_ASSIGN(XForeignWindowManager); |
65 }; | 67 }; |
66 | 68 |
67 } // namespace ui | 69 } // namespace ui |
68 | 70 |
69 #endif // UI_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_ | 71 #endif // UI_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_ |
OLD | NEW |