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

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

Issue 2319933002: X11: Remove calls to XSelectInput (Closed)
Patch Set: Use WeakPtr 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
index 0ac5a5f96c7b5517ca3c7947bc9911ef74b72189..e4bce9a62e058f7e973e4896d6d7f22f72535dc9 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();
@@ -63,11 +61,20 @@ class UI_BASE_X_EXPORT XWindowEventManager {
// Updates the event mask with respect to the server, if necessary.
Daniel Erat 2016/09/14 04:56:10 change this sentence to "Calls ChangeEventMask if
Tom (Use chromium acct) 2016/09/14 17:51:08 Done.
void AfterMaskChanged(XID xid, uint32_t old_mask);
+ // Updates the event mask of |xid| to |new_mask|, regardless of any
Daniel Erat 2016/09/14 04:56:10 i was confused by this comment because it didn't m
Tom (Use chromium acct) 2016/09/14 17:51:08 Done.
+ // XScopedEventSelectors that might exist.
+ void ChangeEventMask(XID xid, uint32_t new_mask);
Daniel Erat 2016/09/14 04:56:10 this method doesn't need to access any members, do
Tom (Use chromium acct) 2016/09/14 17:51:08 Done.
+
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_

Powered by Google App Engine
This is Rietveld 408576698