OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_BASE_X_X11_WINDOW_EVENT_MANAGER_H_ | |
6 #define UI_BASE_X_X11_WINDOW_EVENT_MANAGER_H_ | |
7 | |
8 #include <map> | |
9 #include <vector> | |
10 | |
11 #include "base/compiler_specific.h" | |
12 #include "base/macros.h" | |
13 #include "ui/base/x/ui_base_x_export.h" | |
14 #include "ui/gfx/x/x11_types.h" | |
15 | |
16 // A process wide singleton for selecting events on X windows which were not | |
17 // created by Chrome. | |
18 namespace base { | |
19 template <typename T> | |
20 struct DefaultSingletonTraits; | |
21 } | |
22 | |
23 namespace ui { | |
24 | |
25 // Manages the events that Chrome has selected on X windows which were not | |
26 // created by Chrome. This class allows several clients to select events | |
Daniel Erat
2016/09/07 00:37:33
nit: maybe "... allows multiple clients within Chr
Tom (Use chromium acct)
2016/09/07 18:02:23
Done.
| |
27 // on the same X window. | |
28 class UI_BASE_X_EXPORT XWindowEventManager { | |
29 public: | |
30 static XWindowEventManager* GetInstance(); | |
31 | |
32 class ScopedEventSelector { | |
Daniel Erat
2016/09/07 00:37:33
nit: add a comment documenting what this does
Tom (Use chromium acct)
2016/09/07 18:02:23
Done.
| |
33 public: | |
34 ScopedEventSelector(XID xid, uint32_t event_mask); | |
35 ~ScopedEventSelector(); | |
36 | |
37 private: | |
38 XID xid_; | |
39 uint32_t event_mask_; | |
40 }; | |
41 | |
42 // Guarantees that events on |event_mask| will be reported to Chrome. | |
Daniel Erat
2016/09/07 00:37:33
nit: s/on/in/
Tom (Use chromium acct)
2016/09/07 18:02:23
Done.
| |
43 void SelectEvents(XID xid, uint32_t event_mask); | |
Daniel Erat
2016/09/07 00:37:33
under what circumstances would a caller use this i
Tom (Use chromium acct)
2016/09/07 18:02:23
There are some classes where an X window is not bo
Daniel Erat
2016/09/07 20:00:07
okay, but can't X11WholeScreenMoveLoop just have a
| |
44 | |
45 // Deselects events on |event_mask|. Chrome will stop receiving events for | |
46 // any set bit in |event_mask| only if no other client has selected that bit. | |
47 void DeselectEvents(XID xid, uint32_t event_mask); | |
48 | |
49 private: | |
50 friend struct base::DefaultSingletonTraits<XWindowEventManager>; | |
51 | |
52 struct MultiMask { | |
Daniel Erat
2016/09/07 00:37:33
this should be a class instead of a struct, since
Tom (Use chromium acct)
2016/09/07 18:02:22
Done.
| |
53 MultiMask(); | |
54 ~MultiMask(); | |
55 | |
56 void AddMask(uint32_t mask); | |
57 void RemoveMask(uint32_t mask); | |
58 uint32_t ToMask() const; | |
59 | |
60 static constexpr auto kMaskSize = 25; | |
61 | |
62 unsigned int mask_bits[kMaskSize]; | |
Daniel Erat
2016/09/07 00:37:33
rename to mask_bits_; also just make this be an in
Tom (Use chromium acct)
2016/09/07 18:02:23
Done.
| |
63 }; | |
Daniel Erat
2016/09/07 00:37:33
DISALLOW_COPY_AND_ASSIGN(MultiMask);
Tom (Use chromium acct)
2016/09/07 18:02:23
Done.
| |
64 | |
65 XWindowEventManager(); | |
66 ~XWindowEventManager(); | |
67 | |
68 void BeforeMaskChanged(XID xid); | |
Daniel Erat
2016/09/07 00:37:33
nit: add comments documenting what these methods d
Tom (Use chromium acct)
2016/09/07 18:02:23
Done.
| |
69 void AfterMaskChanged(XID xid); | |
70 | |
71 // State for [Before|After]MaskChanged | |
72 uint32_t old_mask_; | |
73 | |
74 std::map<XID, MultiMask> mask_map_; | |
Daniel Erat
2016/09/07 00:37:33
std::unique_ptr<MultiMask>
Tom (Use chromium acct)
2016/09/07 18:02:23
Done.
| |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(XWindowEventManager); | |
77 }; | |
78 | |
79 } // namespace ui | |
80 | |
81 #endif // UI_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_ | |
OLD | NEW |