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

Unified Diff: base/message_pump_aurax11.h

Issue 10895020: Merge aura::DispatcherLinux into base::MessagePumpAuraX11. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win_aura Created 8 years, 4 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: base/message_pump_aurax11.h
diff --git a/base/message_pump_aurax11.h b/base/message_pump_aurax11.h
index 3f58df71fbe41977620f87dac777f9f0d38c0370..92386a59084ccc887a61efb74021f24238db77f8 100644
--- a/base/message_pump_aurax11.h
+++ b/base/message_pump_aurax11.h
@@ -12,6 +12,8 @@
#include "base/message_pump_observer.h"
#include <bitset>
+#include <map>
+#include <vector>
// It would be nice to include the X11 headers here so that we use Window
// instead of its typedef of unsigned long, but we can't because everything in
@@ -25,7 +27,12 @@ typedef struct _XDisplay Display;
namespace base {
// This class implements a message-pump for dispatching X events.
-class BASE_EXPORT MessagePumpAuraX11 : public MessagePumpGlib {
+//
+// If there's a current dispatcher given through RunWithDispatcher(), that
+// dispatcher receives events. Otherwise, we route to messages to dispatchers
+// who have subscribed to messages from a specific X11 window.
+class BASE_EXPORT MessagePumpAuraX11 : public MessagePumpGlib,
+ public MessagePumpDispatcher {
public:
MessagePumpAuraX11();
@@ -35,12 +42,19 @@ class BASE_EXPORT MessagePumpAuraX11 : public MessagePumpGlib {
// Returns true if the system supports XINPUT2.
static bool HasXInput2();
- // Sets the default dispatcher to process native events.
- static void SetDefaultDispatcher(MessagePumpDispatcher* dispatcher);
-
// Returns the UI message pump.
static MessagePumpAuraX11* Current();
+ // Adds/Removes |dispatcher| for the |x_window|.
+ void AddDispatcherForWindow(MessagePumpDispatcher* dispatcher,
+ unsigned long x_window);
sadrul 2012/08/29 16:01:25 Use XID?
+ void RemoveDispatcherForWindow(unsigned long x_window);
+
+ // Adds/Removes |dispatcher| to receive all events sent to the X
+ // root window.
+ void AddDispatcherForRootWindow(MessagePumpDispatcher* dispatcher);
+ void RemoveDispatcherForRootWindow(MessagePumpDispatcher* dispatcher);
sadrul 2012/08/29 16:01:25 It makes sense to explicitly state in the comments
+
// Internal function. Called by the glib source dispatch function. Processes
// all available X events.
bool DispatchXEvents();
@@ -54,12 +68,15 @@ class BASE_EXPORT MessagePumpAuraX11 : public MessagePumpGlib {
// dropped on the floor. This method exists because mapping a window is
// asynchronous (and we receive an XEvent when mapped), while there are also
// functions which require a mapped window.
- void BlockUntilWindowMapped(unsigned long window);
+ void BlockUntilWindowMapped(unsigned long x_window);
protected:
virtual ~MessagePumpAuraX11();
private:
+ typedef std::map<unsigned long, MessagePumpDispatcher*> DispatchersMap;
+ typedef std::vector<MessagePumpDispatcher*> Dispatchers;
+
// Initializes the glib event source for X.
void InitXSource();
@@ -73,12 +90,24 @@ class BASE_EXPORT MessagePumpAuraX11 : public MessagePumpGlib {
bool WillProcessXEvent(XEvent* xevent);
void DidProcessXEvent(XEvent* xevent);
+ // Returns the Dispatcher based on the event's target window.
+ MessagePumpDispatcher* GetDispatcherForXEvent(
+ const base::NativeEvent& xev) const;
+
+ // Overridden from MessagePumpDispatcher:
+ virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;
+
// The event source for X events.
GSource* x_source_;
// The poll attached to |x_source_|.
scoped_ptr<GPollFD> x_poll_;
+ DispatchersMap dispatchers_;
+ Dispatchers root_window_dispatchers_;
+
+ unsigned long x_root_window_;
+
DISALLOW_COPY_AND_ASSIGN(MessagePumpAuraX11);
};
« no previous file with comments | « ash/shell.cc ('k') | base/message_pump_aurax11.cc » ('j') | base/message_pump_aurax11.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698