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

Side by Side Diff: ui/aura/dispatcher_linux.cc

Issue 9958152: Consolidate win/x dispatchers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync, addressed comments Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/dispatcher_linux.h ('k') | ui/aura/dispatcher_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 void DispatcherLinux::WindowDispatcherCreated( 21 void DispatcherLinux::WindowDispatcherCreated(
22 ::Window window, 22 ::Window window,
23 MessageLoop::Dispatcher* dispatcher) { 23 MessageLoop::Dispatcher* dispatcher) {
24 dispatchers_.insert(std::make_pair(window, dispatcher)); 24 dispatchers_.insert(std::make_pair(window, dispatcher));
25 } 25 }
26 26
27 void DispatcherLinux::WindowDispatcherDestroying(::Window window) { 27 void DispatcherLinux::WindowDispatcherDestroying(::Window window) {
28 dispatchers_.erase(window); 28 dispatchers_.erase(window);
29 } 29 }
30 30
31 base::MessagePumpDispatcher::DispatchStatus DispatcherLinux::Dispatch( 31 bool DispatcherLinux::Dispatch(const base::NativeEvent& xev) {
32 XEvent* xev) {
33 // XI_HierarchyChanged events are special. There is no window associated with 32 // XI_HierarchyChanged events are special. There is no window associated with
34 // these events. So process them directly from here. 33 // these events. So process them directly from here.
35 if (xev->type == GenericEvent && 34 if (xev->type == GenericEvent &&
36 xev->xgeneric.evtype == XI_HierarchyChanged) { 35 xev->xgeneric.evtype == XI_HierarchyChanged) {
37 ui::UpdateDeviceList(); 36 ui::UpdateDeviceList();
38 return EVENT_PROCESSED; 37 return true;
39 } 38 }
40 39
41 // MappingNotify events (meaning that the keyboard or pointer buttons have 40 // MappingNotify events (meaning that the keyboard or pointer buttons have
42 // been remapped) aren't associated with a window; send them to all 41 // been remapped) aren't associated with a window; send them to all
43 // dispatchers. 42 // dispatchers.
44 if (xev->type == MappingNotify) { 43 if (xev->type == MappingNotify) {
45 for (DispatchersMap::const_iterator it = dispatchers_.begin(); 44 for (DispatchersMap::const_iterator it = dispatchers_.begin();
46 it != dispatchers_.end(); ++it) { 45 it != dispatchers_.end(); ++it) {
47 it->second->Dispatch(xev); 46 it->second->Dispatch(xev);
48 } 47 }
49 return EVENT_PROCESSED; 48 return true;
50 } 49 }
51 50
52 MessageLoop::Dispatcher* dispatcher = GetDispatcherForXEvent(xev); 51 MessageLoop::Dispatcher* dispatcher = GetDispatcherForXEvent(xev);
53 return dispatcher ? dispatcher->Dispatch(xev) : EVENT_IGNORED; 52 return dispatcher ? dispatcher->Dispatch(xev) : true;
54 } 53 }
55 54
56 MessageLoop::Dispatcher* DispatcherLinux::GetDispatcherForXEvent( 55 MessageLoop::Dispatcher* DispatcherLinux::GetDispatcherForXEvent(
57 XEvent* xev) const { 56 XEvent* xev) const {
58 ::Window window = xev->xany.window; 57 ::Window window = xev->xany.window;
59 if (xev->type == GenericEvent) { 58 if (xev->type == GenericEvent) {
60 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data); 59 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data);
61 window = xievent->event; 60 window = xievent->event;
62 } 61 }
63 DispatchersMap::const_iterator it = dispatchers_.find(window); 62 DispatchersMap::const_iterator it = dispatchers_.find(window);
64 return it != dispatchers_.end() ? it->second : NULL; 63 return it != dispatchers_.end() ? it->second : NULL;
65 } 64 }
66 65
67 MessageLoop::Dispatcher* CreateDispatcher() { 66 MessageLoop::Dispatcher* CreateDispatcher() {
68 return new DispatcherLinux; 67 return new DispatcherLinux;
69 } 68 }
70 69
71 } // namespace aura 70 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/dispatcher_linux.h ('k') | ui/aura/dispatcher_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698