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/base/events.h" | 9 #include "ui/base/events.h" |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 base::MessagePumpDispatcher::DispatchStatus DispatcherLinux::Dispatch( | 31 base::MessagePumpDispatcher::DispatchStatus DispatcherLinux::Dispatch( |
32 XEvent* xev) { | 32 XEvent* xev) { |
33 // XI_HierarchyChanged events are special. There is no window associated with | 33 // XI_HierarchyChanged events are special. There is no window associated with |
34 // these events. So process them directly from here. | 34 // these events. So process them directly from here. |
35 if (xev->type == GenericEvent && | 35 if (xev->type == GenericEvent && |
36 xev->xgeneric.evtype == XI_HierarchyChanged) { | 36 xev->xgeneric.evtype == XI_HierarchyChanged) { |
37 ui::UpdateDeviceList(); | 37 ui::UpdateDeviceList(); |
38 return EVENT_PROCESSED; | 38 return EVENT_PROCESSED; |
39 } | 39 } |
| 40 |
| 41 // MappingNotify events (meaning that the keyboard or pointer buttons have |
| 42 // been remapped) aren't associated with a window; send them to all |
| 43 // dispatchers. |
| 44 if (xev->type == MappingNotify) { |
| 45 for (DispatchersMap::const_iterator it = dispatchers_.begin(); |
| 46 it != dispatchers_.end(); ++it) { |
| 47 it->second->Dispatch(xev); |
| 48 } |
| 49 return EVENT_PROCESSED; |
| 50 } |
| 51 |
40 MessageLoop::Dispatcher* dispatcher = GetDispatcherForXEvent(xev); | 52 MessageLoop::Dispatcher* dispatcher = GetDispatcherForXEvent(xev); |
41 return dispatcher ? dispatcher->Dispatch(xev) : EVENT_IGNORED; | 53 return dispatcher ? dispatcher->Dispatch(xev) : EVENT_IGNORED; |
42 } | 54 } |
43 | 55 |
44 MessageLoop::Dispatcher* DispatcherLinux::GetDispatcherForXEvent( | 56 MessageLoop::Dispatcher* DispatcherLinux::GetDispatcherForXEvent( |
45 XEvent* xev) const { | 57 XEvent* xev) const { |
46 ::Window window = xev->xany.window; | 58 ::Window window = xev->xany.window; |
47 if (xev->type == GenericEvent) { | 59 if (xev->type == GenericEvent) { |
48 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data); | 60 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data); |
49 window = xievent->event; | 61 window = xievent->event; |
50 } | 62 } |
51 DispatchersMap::const_iterator it = dispatchers_.find(window); | 63 DispatchersMap::const_iterator it = dispatchers_.find(window); |
52 return it != dispatchers_.end() ? it->second : NULL; | 64 return it != dispatchers_.end() ? it->second : NULL; |
53 } | 65 } |
54 | 66 |
55 MessageLoop::Dispatcher* CreateDispatcher() { | 67 MessageLoop::Dispatcher* CreateDispatcher() { |
56 return new DispatcherLinux; | 68 return new DispatcherLinux; |
57 } | 69 } |
58 | 70 |
59 } // namespace aura | 71 } // namespace aura |
OLD | NEW |