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

Unified Diff: ui/base/x/x11_window_event_manager.h

Issue 2319933002: X11: Remove calls to XSelectInput (Closed)
Patch Set: Comments 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
« no previous file with comments | « ui/base/clipboard/clipboard_aurax11.cc ('k') | ui/base/x/x11_window_event_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index 0ac5a5f96c7b5517ca3c7947bc9911ef74b72189..d5a2f37e05695e3fc15b5f157019626abebc8697 100644
--- a/ui/base/x/x11_window_event_manager.h
+++ b/ui/base/x/x11_window_event_manager.h
@@ -6,15 +6,12 @@
#define UI_BASE_X_X11_WINDOW_EVENT_MANAGER_H_
#include <map>
-#include <vector>
-#include "base/compiler_specific.h"
#include "base/macros.h"
+#include "base/memory/weak_ptr.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;
@@ -22,6 +19,8 @@ struct DefaultSingletonTraits;
namespace ui {
+class XWindowEventManager;
+
// Ensures events in |event_mask| are selected on |xid| for the duration of this
// object's lifetime.
class UI_BASE_X_EXPORT XScopedEventSelector {
@@ -32,14 +31,13 @@ class UI_BASE_X_EXPORT XScopedEventSelector {
private:
XID xid_;
uint32_t event_mask_;
+ base::WeakPtr<XWindowEventManager> event_manager_;
DISALLOW_COPY_AND_ASSIGN(XScopedEventSelector);
};
-// 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 {
+// Allows multiple clients within Chrome to select events on the same X window.
+class XWindowEventManager {
public:
static XWindowEventManager* GetInstance();
@@ -59,15 +57,21 @@ class UI_BASE_X_EXPORT XWindowEventManager {
// any set bit in |event_mask| only if no other client has selected that bit.
void DeselectEvents(XID xid, uint32_t event_mask);
- // Called whenever the mask corresponding to window |xid| might have changed.
- // Updates the event mask with respect to the server, if necessary.
+ // Helper method called by SelectEvents and DeselectEvents whenever the mask
+ // corresponding to window |xid| might have changed. Calls SetEventMask if
+ // necessary.
void AfterMaskChanged(XID xid, uint32_t old_mask);
std::map<XID, std::unique_ptr<MultiMask>> mask_map_;
+ // This is used to set XScopedEventSelector::event_manager_. If |this| is
+ // destroyed before any XScopedEventSelector, the |event_manager_| will become
+ // invalidated.
+ base::WeakPtrFactory<XWindowEventManager> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(XWindowEventManager);
};
} // namespace ui
-#endif // UI_BASE_X_X11_FOREIGN_WINDOW_MANAGER_H_
+#endif // UI_BASE_X_X11_WINDOW_EVENT_MANAGER_H_
« no previous file with comments | « ui/base/clipboard/clipboard_aurax11.cc ('k') | ui/base/x/x11_window_event_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698