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

Side by Side Diff: base/message_pump_aurax11.cc

Issue 11593015: MessagePumpAuraX11: Make root_window_dispatchers_ an ObserverList. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years 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 | « base/message_pump_aurax11.h ('k') | no next file » | 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 "base/message_pump_aurax11.h" 5 #include "base/message_pump_aurax11.h"
6 6
7 #include <glib.h> 7 #include <glib.h>
8 #include <X11/X.h> 8 #include <X11/X.h>
9 #include <X11/extensions/XInput2.h> 9 #include <X11/extensions/XInput2.h>
10 #include <X11/XKBlib.h> 10 #include <X11/XKBlib.h>
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 unsigned long xid) { 162 unsigned long xid) {
163 dispatchers_.insert(std::make_pair(xid, dispatcher)); 163 dispatchers_.insert(std::make_pair(xid, dispatcher));
164 } 164 }
165 165
166 void MessagePumpAuraX11::RemoveDispatcherForWindow(unsigned long xid) { 166 void MessagePumpAuraX11::RemoveDispatcherForWindow(unsigned long xid) {
167 dispatchers_.erase(xid); 167 dispatchers_.erase(xid);
168 } 168 }
169 169
170 void MessagePumpAuraX11::AddDispatcherForRootWindow( 170 void MessagePumpAuraX11::AddDispatcherForRootWindow(
171 MessagePumpDispatcher* dispatcher) { 171 MessagePumpDispatcher* dispatcher) {
172 DCHECK(std::find(root_window_dispatchers_.begin(), 172 root_window_dispatchers_.AddObserver(dispatcher);
173 root_window_dispatchers_.end(),
174 dispatcher) ==
175 root_window_dispatchers_.end());
176 root_window_dispatchers_.push_back(dispatcher);
177 } 173 }
178 174
179 void MessagePumpAuraX11::RemoveDispatcherForRootWindow( 175 void MessagePumpAuraX11::RemoveDispatcherForRootWindow(
180 MessagePumpDispatcher* dispatcher) { 176 MessagePumpDispatcher* dispatcher) {
181 root_window_dispatchers_.erase( 177 root_window_dispatchers_.RemoveObserver(dispatcher);
182 std::remove(root_window_dispatchers_.begin(),
183 root_window_dispatchers_.end(),
184 dispatcher));
185 } 178 }
186 179
187 bool MessagePumpAuraX11::DispatchXEvents() { 180 bool MessagePumpAuraX11::DispatchXEvents() {
188 Display* display = GetDefaultXDisplay(); 181 Display* display = GetDefaultXDisplay();
189 DCHECK(display); 182 DCHECK(display);
190 MessagePumpDispatcher* dispatcher = 183 MessagePumpDispatcher* dispatcher =
191 GetDispatcher() ? GetDispatcher() : this; 184 GetDispatcher() ? GetDispatcher() : this;
192 185
193 // In the general case, we want to handle all pending events before running 186 // In the general case, we want to handle all pending events before running
194 // the tasks. This is what happens in the message_pump_glib case. 187 // the tasks. This is what happens in the message_pump_glib case.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // dispatchers. 289 // dispatchers.
297 if (xev->type == MappingNotify) { 290 if (xev->type == MappingNotify) {
298 for (DispatchersMap::const_iterator it = dispatchers_.begin(); 291 for (DispatchersMap::const_iterator it = dispatchers_.begin();
299 it != dispatchers_.end(); ++it) { 292 it != dispatchers_.end(); ++it) {
300 it->second->Dispatch(xev); 293 it->second->Dispatch(xev);
301 } 294 }
302 return true; 295 return true;
303 } 296 }
304 297
305 if (FindEventTarget(xev) == x_root_window_) { 298 if (FindEventTarget(xev) == x_root_window_) {
306 for (Dispatchers::const_iterator it = root_window_dispatchers_.begin(); 299 FOR_EACH_OBSERVER(MessagePumpDispatcher, root_window_dispatchers_,
307 it != root_window_dispatchers_.end(); 300 Dispatch(xev));
308 ++it) {
309 (*it)->Dispatch(xev);
310 }
311 return true; 301 return true;
312 } 302 }
313 MessagePumpDispatcher* dispatcher = GetDispatcherForXEvent(xev); 303 MessagePumpDispatcher* dispatcher = GetDispatcherForXEvent(xev);
314 return dispatcher ? dispatcher->Dispatch(xev) : true; 304 return dispatcher ? dispatcher->Dispatch(xev) : true;
315 } 305 }
316 306
317 } // namespace base 307 } // namespace base
OLDNEW
« no previous file with comments | « base/message_pump_aurax11.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698