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_ |