| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/aura/dispatcher_linux.h" | 5 #include "ui/aura/dispatcher_linux.h" |
| 6 | 6 |
| 7 #include <X11/extensions/XInput2.h> | 7 #include <X11/extensions/XInput2.h> |
| 8 | 8 |
| 9 #include "ui/aura/root_window_host_linux.h" | 9 #include "ui/aura/root_window_host_linux.h" |
| 10 #include "ui/base/events.h" | 10 #include "ui/base/events.h" |
| 11 | 11 |
| 12 namespace aura { | 12 namespace aura { |
| 13 | 13 |
| 14 DispatcherLinux::DispatcherLinux() { | 14 DispatcherLinux::DispatcherLinux() { |
| 15 base::MessagePumpX::SetDefaultDispatcher(this); | 15 base::MessagePumpX::SetDefaultDispatcher(this); |
| 16 } | 16 } |
| 17 | 17 |
| 18 DispatcherLinux::~DispatcherLinux() { | 18 DispatcherLinux::~DispatcherLinux() { |
| 19 base::MessagePumpX::SetDefaultDispatcher(NULL); | 19 base::MessagePumpX::SetDefaultDispatcher(NULL); |
| 20 } | 20 } |
| 21 | 21 |
| 22 void DispatcherLinux::RootWindowHostCreated(::Window window, | 22 void DispatcherLinux::RootWindowHostCreated(::Window window, |
| 23 ::Window root, | 23 ::Window root, |
| 24 RootWindowHostLinux* host) { | 24 RootWindowHostLinux* host) { |
| 25 hosts_.insert(std::make_pair(window, host)); | 25 hosts_.insert(std::make_pair(window, host)); |
| 26 hosts_.insert(std::make_pair(root, host)); | 26 // Only the 1st root window listens to the root window. |
| 27 if (hosts_.find(root) == hosts_.end()) |
| 28 hosts_.insert(std::make_pair(root, host)); |
| 27 } | 29 } |
| 28 | 30 |
| 29 void DispatcherLinux::RootWindowHostDestroying(::Window window, ::Window root) { | 31 void DispatcherLinux::RootWindowHostDestroying(::Window window, ::Window root) { |
| 32 if (hosts_[window] == hosts_[root]) |
| 33 hosts_.erase(root); |
| 30 hosts_.erase(window); | 34 hosts_.erase(window); |
| 31 hosts_.erase(root); | |
| 32 } | 35 } |
| 33 | 36 |
| 34 base::MessagePumpDispatcher::DispatchStatus DispatcherLinux::Dispatch( | 37 base::MessagePumpDispatcher::DispatchStatus DispatcherLinux::Dispatch( |
| 35 XEvent* xev) { | 38 XEvent* xev) { |
| 36 // XI_HierarchyChanged events are special. There is no window associated with | 39 // XI_HierarchyChanged events are special. There is no window associated with |
| 37 // these events. So process them directly from here. | 40 // these events. So process them directly from here. |
| 38 if (xev->type == GenericEvent && | 41 if (xev->type == GenericEvent && |
| 39 xev->xgeneric.evtype == XI_HierarchyChanged) { | 42 xev->xgeneric.evtype == XI_HierarchyChanged) { |
| 40 ui::UpdateDeviceList(); | 43 ui::UpdateDeviceList(); |
| 41 return EVENT_PROCESSED; | 44 return EVENT_PROCESSED; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 53 } | 56 } |
| 54 HostsMap::const_iterator it = hosts_.find(window); | 57 HostsMap::const_iterator it = hosts_.find(window); |
| 55 return it != hosts_.end() ? it->second : NULL; | 58 return it != hosts_.end() ? it->second : NULL; |
| 56 } | 59 } |
| 57 | 60 |
| 58 Dispatcher* CreateDispatcher() { | 61 Dispatcher* CreateDispatcher() { |
| 59 return new DispatcherLinux; | 62 return new DispatcherLinux; |
| 60 } | 63 } |
| 61 | 64 |
| 62 } // namespace aura | 65 } // namespace aura |
| OLD | NEW |