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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ui/base/x/x11_window_event_manager.h
diff --git a/ui/base/x/x11_window_event_manager.h b/ui/base/x/x11_window_event_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..9d24acda520c95b92b340b9395ec2fae3b0a77fe
--- /dev/null
+++ b/ui/base/x/x11_window_event_manager.h
@@ -0,0 +1,70 @@
+// 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.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_BASE_X_X11_WINDOW_EVENT_MANAGER_H_
+#define UI_BASE_X_X11_WINDOW_EVENT_MANAGER_H_
+
+#include <map>
+#include <vector>
+
+#include "base/compiler_specific.h"
+#include "base/macros.h"
+#include "ui/base/x/ui_base_x_export.h"
+#include "ui/gfx/x/x11_types.h"
+
+// A process wide singleton for selecting events on X windows which were not
+// created by Chrome.
+namespace base {
+template <typename T>
+struct DefaultSingletonTraits;
+}
+
+namespace ui {
+
+// Ensures events in |event_mask| are selected on |xid| for the duration of this
+// object's lifetime.
+class UI_BASE_X_EXPORT XScopedEventSelector {
+ public:
+ XScopedEventSelector(XID xid, uint32_t event_mask);
+ ~XScopedEventSelector();
+
+ private:
+ XID xid_;
+ uint32_t event_mask_;
+};
+
+// Manages the events that Chrome has selected on X windows which were not
+// created by Chrome. This class allows multiple clients within Chrome to select
+// events on the same X window.
+class UI_BASE_X_EXPORT XWindowEventManager {
+ public:
+ static XWindowEventManager* GetInstance();
+
+ // Guarantees that events in |event_mask| will be reported to Chrome.
+ void SelectEvents(XID xid, uint32_t event_mask);
+
+ // Deselects events on |event_mask|. Chrome will stop receiving events for
+ // any set bit in |event_mask| only if no other client has selected that bit.
+ void DeselectEvents(XID xid, uint32_t event_mask);
+
+ private:
+ friend struct base::DefaultSingletonTraits<XWindowEventManager>;
+
+ class MultiMask;
+
+ XWindowEventManager();
+ ~XWindowEventManager();
+
+ // Called whenever the mask corresponding to window |xid| might have changed.
+ // Updates the event mask with respect to the server, if necessary.
+ void AfterMaskChanged(XID xid, uint32_t old_mask);
+
+ std::map<XID, std::unique_ptr<MultiMask>> mask_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(XWindowEventManager);
+};
+
+} // namespace ui
+
+#endif // UI_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698