Index: ui/aura/dispatcher_linux.cc |
diff --git a/ui/aura/dispatcher_linux.cc b/ui/aura/dispatcher_linux.cc |
index 87810c50cb87eef991884d53a3db00e6b5bd85a8..a4b80d149d3fda62c16073561ac3e2a0ad9be1ad 100644 |
--- a/ui/aura/dispatcher_linux.cc |
+++ b/ui/aura/dispatcher_linux.cc |
@@ -37,7 +37,9 @@ void PreprocessXEvent(XEvent* xevent) { |
namespace aura { |
-DispatcherLinux::DispatcherLinux() { |
+DispatcherLinux::DispatcherLinux() |
+ : x_root_window_( |
+ DefaultRootWindow(base::MessagePumpX::GetDefaultXDisplay())) { |
base::MessagePumpX::SetDefaultDispatcher(this); |
MessageLoopForUI::current()->AddObserver(this); |
} |
@@ -47,14 +49,31 @@ DispatcherLinux::~DispatcherLinux() { |
base::MessagePumpX::SetDefaultDispatcher(NULL); |
} |
-void DispatcherLinux::WindowDispatcherCreated( |
- ::Window window, |
+void DispatcherLinux::RegisterDispatcherForWindow( |
+ MessageLoop::Dispatcher* dispatcher, |
+ ::Window x_window) { |
+ dispatchers_.insert(std::make_pair(x_window, dispatcher)); |
+} |
+ |
+void DispatcherLinux::UnregisterDispatcherForWindow(::Window x_window) { |
+ dispatchers_.erase(x_window); |
+} |
+ |
+void DispatcherLinux::RegisterDispatcherForRootWindow( |
MessageLoop::Dispatcher* dispatcher) { |
- dispatchers_.insert(std::make_pair(window, dispatcher)); |
+ DCHECK(std::find(root_window_dispatchers_.begin(), |
+ root_window_dispatchers_.end(), |
+ dispatcher) == |
+ root_window_dispatchers_.end()); |
+ root_window_dispatchers_.push_back(dispatcher); |
} |
-void DispatcherLinux::WindowDispatcherDestroying(::Window window) { |
- dispatchers_.erase(window); |
+void DispatcherLinux::UnregisterDispatcherForRootWindow( |
+ MessageLoop::Dispatcher* dispatcher) { |
+ root_window_dispatchers_.erase( |
+ std::remove(root_window_dispatchers_.begin(), |
+ root_window_dispatchers_.end(), |
+ dispatcher)); |
} |
bool DispatcherLinux::Dispatch(const base::NativeEvent& xev) { |
@@ -76,7 +95,14 @@ bool DispatcherLinux::Dispatch(const base::NativeEvent& xev) { |
} |
return true; |
} |
- |
+ if (xev->xany.window == x_root_window_) { |
+ for (Dispatchers::const_iterator it = root_window_dispatchers_.begin(); |
+ it != root_window_dispatchers_.end(); |
+ ++it) { |
+ (*it)->Dispatch(xev); |
+ } |
+ return true; |
+ } |
MessageLoop::Dispatcher* dispatcher = GetDispatcherForXEvent(xev); |
return dispatcher ? dispatcher->Dispatch(xev) : true; |
} |
@@ -92,12 +118,12 @@ void DispatcherLinux::DidProcessEvent(const base::NativeEvent& event) { |
MessageLoop::Dispatcher* DispatcherLinux::GetDispatcherForXEvent( |
XEvent* xev) const { |
- ::Window window = xev->xany.window; |
+ ::Window x_window = xev->xany.window; |
if (xev->type == GenericEvent) { |
XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data); |
- window = xievent->event; |
+ x_window = xievent->event; |
} |
- DispatchersMap::const_iterator it = dispatchers_.find(window); |
+ DispatchersMap::const_iterator it = dispatchers_.find(x_window); |
return it != dispatchers_.end() ? it->second : NULL; |
} |