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

Side by Side 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: renamed methods, fixed comment 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/dispatcher_linux.h ('k') | ui/aura/monitor_change_observer_x11.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 19 matching lines...) Expand all
30 XIClearMask(xievent->buttons.mask, 1); 30 XIClearMask(xievent->buttons.mask, 1);
31 xievent->mods.effective &= ~Button1Mask; 31 xievent->mods.effective &= ~Button1Mask;
32 } 32 }
33 } 33 }
34 } 34 }
35 35
36 } // namespace 36 } // namespace
37 37
38 namespace aura { 38 namespace aura {
39 39
40 DispatcherLinux::DispatcherLinux() { 40 DispatcherLinux::DispatcherLinux()
41 : x_root_window_(
42 DefaultRootWindow(base::MessagePumpX::GetDefaultXDisplay())) {
41 base::MessagePumpX::SetDefaultDispatcher(this); 43 base::MessagePumpX::SetDefaultDispatcher(this);
42 MessageLoopForUI::current()->AddObserver(this); 44 MessageLoopForUI::current()->AddObserver(this);
43 } 45 }
44 46
45 DispatcherLinux::~DispatcherLinux() { 47 DispatcherLinux::~DispatcherLinux() {
46 MessageLoopForUI::current()->RemoveObserver(this); 48 MessageLoopForUI::current()->RemoveObserver(this);
47 base::MessagePumpX::SetDefaultDispatcher(NULL); 49 base::MessagePumpX::SetDefaultDispatcher(NULL);
48 } 50 }
49 51
50 void DispatcherLinux::WindowDispatcherCreated( 52 void DispatcherLinux::AddDispatcherForWindow(
51 ::Window window, 53 MessageLoop::Dispatcher* dispatcher,
52 MessageLoop::Dispatcher* dispatcher) { 54 ::Window x_window) {
53 dispatchers_.insert(std::make_pair(window, dispatcher)); 55 dispatchers_.insert(std::make_pair(x_window, dispatcher));
54 } 56 }
55 57
56 void DispatcherLinux::WindowDispatcherDestroying(::Window window) { 58 void DispatcherLinux::RemoveDispatcherForWindow(::Window x_window) {
57 dispatchers_.erase(window); 59 dispatchers_.erase(x_window);
60 }
61
62 void DispatcherLinux::AddDispatcherForRootWindow(
63 MessageLoop::Dispatcher* dispatcher) {
64 DCHECK(std::find(root_window_dispatchers_.begin(),
65 root_window_dispatchers_.end(),
66 dispatcher) ==
67 root_window_dispatchers_.end());
68 root_window_dispatchers_.push_back(dispatcher);
69 }
70
71 void DispatcherLinux::RemoveDispatcherForRootWindow(
72 MessageLoop::Dispatcher* dispatcher) {
73 root_window_dispatchers_.erase(
74 std::remove(root_window_dispatchers_.begin(),
75 root_window_dispatchers_.end(),
76 dispatcher));
58 } 77 }
59 78
60 bool DispatcherLinux::Dispatch(const base::NativeEvent& xev) { 79 bool DispatcherLinux::Dispatch(const base::NativeEvent& xev) {
61 // XI_HierarchyChanged events are special. There is no window associated with 80 // XI_HierarchyChanged events are special. There is no window associated with
62 // these events. So process them directly from here. 81 // these events. So process them directly from here.
63 if (xev->type == GenericEvent && 82 if (xev->type == GenericEvent &&
64 xev->xgeneric.evtype == XI_HierarchyChanged) { 83 xev->xgeneric.evtype == XI_HierarchyChanged) {
65 ui::UpdateDeviceList(); 84 ui::UpdateDeviceList();
66 return true; 85 return true;
67 } 86 }
68 87
69 // MappingNotify events (meaning that the keyboard or pointer buttons have 88 // MappingNotify events (meaning that the keyboard or pointer buttons have
70 // been remapped) aren't associated with a window; send them to all 89 // been remapped) aren't associated with a window; send them to all
71 // dispatchers. 90 // dispatchers.
72 if (xev->type == MappingNotify) { 91 if (xev->type == MappingNotify) {
73 for (DispatchersMap::const_iterator it = dispatchers_.begin(); 92 for (DispatchersMap::const_iterator it = dispatchers_.begin();
74 it != dispatchers_.end(); ++it) { 93 it != dispatchers_.end(); ++it) {
75 it->second->Dispatch(xev); 94 it->second->Dispatch(xev);
76 } 95 }
77 return true; 96 return true;
78 } 97 }
79 98 if (xev->xany.window == x_root_window_) {
99 for (Dispatchers::const_iterator it = root_window_dispatchers_.begin();
100 it != root_window_dispatchers_.end();
101 ++it) {
102 (*it)->Dispatch(xev);
103 }
104 return true;
105 }
80 MessageLoop::Dispatcher* dispatcher = GetDispatcherForXEvent(xev); 106 MessageLoop::Dispatcher* dispatcher = GetDispatcherForXEvent(xev);
81 return dispatcher ? dispatcher->Dispatch(xev) : true; 107 return dispatcher ? dispatcher->Dispatch(xev) : true;
82 } 108 }
83 109
84 base::EventStatus DispatcherLinux::WillProcessEvent( 110 base::EventStatus DispatcherLinux::WillProcessEvent(
85 const base::NativeEvent& event) { 111 const base::NativeEvent& event) {
86 PreprocessXEvent(event); 112 PreprocessXEvent(event);
87 return base::EVENT_CONTINUE; 113 return base::EVENT_CONTINUE;
88 } 114 }
89 115
90 void DispatcherLinux::DidProcessEvent(const base::NativeEvent& event) { 116 void DispatcherLinux::DidProcessEvent(const base::NativeEvent& event) {
91 } 117 }
92 118
93 MessageLoop::Dispatcher* DispatcherLinux::GetDispatcherForXEvent( 119 MessageLoop::Dispatcher* DispatcherLinux::GetDispatcherForXEvent(
94 XEvent* xev) const { 120 XEvent* xev) const {
95 ::Window window = xev->xany.window; 121 ::Window x_window = xev->xany.window;
96 if (xev->type == GenericEvent) { 122 if (xev->type == GenericEvent) {
97 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data); 123 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data);
98 window = xievent->event; 124 x_window = xievent->event;
99 } 125 }
100 DispatchersMap::const_iterator it = dispatchers_.find(window); 126 DispatchersMap::const_iterator it = dispatchers_.find(x_window);
101 return it != dispatchers_.end() ? it->second : NULL; 127 return it != dispatchers_.end() ? it->second : NULL;
102 } 128 }
103 129
104 MessageLoop::Dispatcher* CreateDispatcher() { 130 MessageLoop::Dispatcher* CreateDispatcher() {
105 return new DispatcherLinux; 131 return new DispatcherLinux;
106 } 132 }
107 133
108 } // namespace aura 134 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/dispatcher_linux.h ('k') | ui/aura/monitor_change_observer_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698