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

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: sync 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..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;
}

Powered by Google App Engine
This is Rietveld 408576698