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

Side by Side Diff: base/message_loop/message_pump_x11.cc

Issue 223483002: base: Do not allow MessagePumpObservers to consume events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | « base/message_loop/message_pump_x11.h ('k') | chrome/browser/chromeos/device_uma.h » ('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 "base/message_loop/message_pump_x11.h" 5 #include "base/message_loop/message_pump_x11.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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 246
247 void MessagePumpX11::ProcessXEvent(MessagePumpDispatcher* dispatcher, 247 void MessagePumpX11::ProcessXEvent(MessagePumpDispatcher* dispatcher,
248 XEvent* xev) { 248 XEvent* xev) {
249 CHECK(dispatcher); 249 CHECK(dispatcher);
250 bool have_cookie = false; 250 bool have_cookie = false;
251 if (xev->type == GenericEvent && 251 if (xev->type == GenericEvent &&
252 XGetEventData(xev->xgeneric.display, &xev->xcookie)) { 252 XGetEventData(xev->xgeneric.display, &xev->xcookie)) {
253 have_cookie = true; 253 have_cookie = true;
254 } 254 }
255 255
256 if (!WillProcessXEvent(xev)) { 256 WillProcessXEvent(xev);
257 uint32_t action = dispatcher->Dispatch(xev); 257 uint32_t action = dispatcher->Dispatch(xev);
258 bool should_quit = (action & POST_DISPATCH_QUIT_LOOP); 258 bool should_quit = (action & POST_DISPATCH_QUIT_LOOP);
259 if (dispatcher != this && (action & POST_DISPATCH_PERFORM_DEFAULT)) 259 if (dispatcher != this && (action & POST_DISPATCH_PERFORM_DEFAULT))
260 action = Dispatch(xev); 260 action = Dispatch(xev);
261 if ((action & POST_DISPATCH_QUIT_LOOP) || should_quit) 261 if ((action & POST_DISPATCH_QUIT_LOOP) || should_quit)
262 Quit(); 262 Quit();
263 DidProcessXEvent(xev); 263 DidProcessXEvent(xev);
264 }
265 264
266 if (have_cookie) 265 if (have_cookie)
267 XFreeEventData(xev->xgeneric.display, &xev->xcookie); 266 XFreeEventData(xev->xgeneric.display, &xev->xcookie);
268 } 267 }
269 268
270 bool MessagePumpX11::WillProcessXEvent(XEvent* xevent) { 269 void MessagePumpX11::WillProcessXEvent(XEvent* xevent) {
271 if (!observers().might_have_observers()) 270 FOR_EACH_OBSERVER(MessagePumpObserver, observers(), WillProcessEvent(xevent));
sky 2014/04/03 15:43:21 I would just inline this now.
sadrul 2014/04/03 16:22:50 I have kept this in a separate function for now si
272 return false;
273 ObserverListBase<MessagePumpObserver>::Iterator it(observers());
274 MessagePumpObserver* obs;
275 while ((obs = it.GetNext()) != NULL) {
276 if (obs->WillProcessEvent(xevent))
277 return true;
278 }
279 return false;
280 } 271 }
281 272
282 void MessagePumpX11::DidProcessXEvent(XEvent* xevent) { 273 void MessagePumpX11::DidProcessXEvent(XEvent* xevent) {
283 FOR_EACH_OBSERVER(MessagePumpObserver, observers(), DidProcessEvent(xevent)); 274 FOR_EACH_OBSERVER(MessagePumpObserver, observers(), DidProcessEvent(xevent));
284 } 275 }
285 276
286 MessagePumpDispatcher* MessagePumpX11::GetDispatcherForXEvent( 277 MessagePumpDispatcher* MessagePumpX11::GetDispatcherForXEvent(
287 const NativeEvent& xev) const { 278 const NativeEvent& xev) const {
288 ::Window x_window = FindEventTarget(xev); 279 ::Window x_window = FindEventTarget(xev);
289 DispatchersMap::const_iterator it = dispatchers_.find(x_window); 280 DispatchersMap::const_iterator it = dispatchers_.find(x_window);
(...skipping 15 matching lines...) Expand all
305 if (FindEventTarget(xev) == x_root_window_) { 296 if (FindEventTarget(xev) == x_root_window_) {
306 FOR_EACH_OBSERVER(MessagePumpDispatcher, root_window_dispatchers_, 297 FOR_EACH_OBSERVER(MessagePumpDispatcher, root_window_dispatchers_,
307 Dispatch(xev)); 298 Dispatch(xev));
308 return POST_DISPATCH_NONE; 299 return POST_DISPATCH_NONE;
309 } 300 }
310 MessagePumpDispatcher* dispatcher = GetDispatcherForXEvent(xev); 301 MessagePumpDispatcher* dispatcher = GetDispatcherForXEvent(xev);
311 return dispatcher ? dispatcher->Dispatch(xev) : POST_DISPATCH_NONE; 302 return dispatcher ? dispatcher->Dispatch(xev) : POST_DISPATCH_NONE;
312 } 303 }
313 304
314 } // namespace base 305 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_pump_x11.h ('k') | chrome/browser/chromeos/device_uma.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698