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

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

Issue 2313033002: Refactor X11ForeignWindowManager (Reland) (Closed)
Patch Set: Fix bug 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 2014 The Chromium Authors. All rights reserved.
Daniel Erat 2016/09/07 20:00:07 nit: 2016?
Tom (Use chromium acct) 2016/09/07 21:32:21 Done.
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 };
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 // Guarantees that events in |event_mask| will be reported to Chrome.
45 void SelectEvents(XID xid, uint32_t event_mask);
46
47 // Deselects events on |event_mask|. Chrome will stop receiving events for
48 // any set bit in |event_mask| only if no other client has selected that bit.
49 void DeselectEvents(XID xid, uint32_t event_mask);
50
51 private:
52 friend struct base::DefaultSingletonTraits<XWindowEventManager>;
53
54 class MultiMask;
55
56 XWindowEventManager();
57 ~XWindowEventManager();
58
59 // Called whenever the mask corresponding to window |xid| might have changed.
60 // Updates the event mask with respect to the server, if necessary.
61 void AfterMaskChanged(XID xid, uint32_t old_mask);
62
63 std::map<XID, std::unique_ptr<MultiMask>> mask_map_;
64
65 DISALLOW_COPY_AND_ASSIGN(XWindowEventManager);
66 };
67
68 } // namespace ui
69
70 #endif // UI_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698