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

Unified Diff: ui/aura/dispatcher_linux.cc

Issue 10407081: Multiple dispatchers for root windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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/aura/dispatcher_linux.cc
diff --git a/ui/aura/dispatcher_linux.cc b/ui/aura/dispatcher_linux.cc
index 87810c50cb87eef991884d53a3db00e6b5bd85a8..a4a1dcec77ced550baf473337258379f5e16bf0f 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()
+ : root_window_(
+ DefaultRootWindow(base::MessagePumpX::GetDefaultXDisplay())) {
base::MessagePumpX::SetDefaultDispatcher(this);
MessageLoopForUI::current()->AddObserver(this);
}
@@ -47,16 +49,33 @@ DispatcherLinux::~DispatcherLinux() {
base::MessagePumpX::SetDefaultDispatcher(NULL);
}
-void DispatcherLinux::WindowDispatcherCreated(
+void DispatcherLinux::RegisterDispatcher(
::Window window,
MessageLoop::Dispatcher* dispatcher) {
dispatchers_.insert(std::make_pair(window, dispatcher));
}
-void DispatcherLinux::WindowDispatcherDestroying(::Window window) {
+void DispatcherLinux::RegisterRootWindowDispatcher(
+ MessageLoop::Dispatcher* 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::UnregisterDispatcher(::Window window) {
Daniel Erat 2012/05/22 14:33:42 nit: move this after RegisterDispatcher() to match
oshima 2012/05/22 19:50:02 Done.
dispatchers_.erase(window);
}
+void DispatcherLinux::UnregisterRootWindowDispatcher(
+ 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) {
// XI_HierarchyChanged events are special. There is no window associated with
// these events. So process them directly from here.
@@ -76,7 +95,10 @@ bool DispatcherLinux::Dispatch(const base::NativeEvent& xev) {
}
return true;
}
-
+ if (xev->xany.window == root_window_) {
+ DispatchRootWindowEvent(xev);
+ return true;
+ }
MessageLoop::Dispatcher* dispatcher = GetDispatcherForXEvent(xev);
return dispatcher ? dispatcher->Dispatch(xev) : true;
}
@@ -101,6 +123,14 @@ MessageLoop::Dispatcher* DispatcherLinux::GetDispatcherForXEvent(
return it != dispatchers_.end() ? it->second : NULL;
}
+void DispatcherLinux::DispatchRootWindowEvent(XEvent* xev) {
+ for (Dispatchers::const_iterator it = root_window_dispatchers_.begin();
Daniel Erat 2012/05/22 14:33:42 nit: maybe move this into Dispatch() to improve re
oshima 2012/05/22 19:50:02 Done.
+ it != root_window_dispatchers_.end();
+ ++it) {
+ (*it)->Dispatch(xev);
+ }
+}
+
MessageLoop::Dispatcher* CreateDispatcher() {
return new DispatcherLinux;
}

Powered by Google App Engine
This is Rietveld 408576698