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

Side by Side Diff: ui/base/x/x11_window_event_manager.h

Issue 2313033002: Refactor X11ForeignWindowManager (Reland) (Closed)
Patch Set: Make Select/Deselect private Created 4 years, 3 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
OLDNEW
(Empty)
1 // Copyright 2016 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 // Ensures events in |event_mask| are selected on |xid| for the duration of this
26 // object's lifetime.
27 class UI_BASE_X_EXPORT XScopedEventSelector {
28 public:
29 XScopedEventSelector(XID xid, uint32_t event_mask);
30 ~XScopedEventSelector();
31
32 private:
33 XID xid_;
34 uint32_t event_mask_;
35 };
Daniel Erat 2016/09/07 21:45:06 DISALLOW_COPY_AND_ASSIGN(XScopedEventSelector)
Tom (Use chromium acct) 2016/09/07 23:11:06 Done.
36
37 // Manages the events that Chrome has selected on X windows which were not
38 // created by Chrome. This class allows multiple clients within Chrome to select
39 // events on the same X window.
40 class UI_BASE_X_EXPORT XWindowEventManager {
41 public:
42 static XWindowEventManager* GetInstance();
43
44 private:
45 friend struct base::DefaultSingletonTraits<XWindowEventManager>;
46 friend class XScopedEventSelector;
47
48 class MultiMask;
49
50 XWindowEventManager();
51 ~XWindowEventManager();
52
53 // Guarantees that events in |event_mask| will be reported to Chrome.
54 void SelectEvents(XID xid, uint32_t event_mask);
55
56 // Deselects events on |event_mask|. Chrome will stop receiving events for
57 // any set bit in |event_mask| only if no other client has selected that bit.
58 void DeselectEvents(XID xid, uint32_t event_mask);
59
60 // Called whenever the mask corresponding to window |xid| might have changed.
61 // Updates the event mask with respect to the server, if necessary.
62 void AfterMaskChanged(XID xid, uint32_t old_mask);
63
64 std::map<XID, std::unique_ptr<MultiMask>> mask_map_;
65
66 DISALLOW_COPY_AND_ASSIGN(XWindowEventManager);
67 };
68
69 } // namespace ui
70
71 #endif // UI_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698