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

Side by Side Diff: base/message_pump_x.cc

Issue 8021009: Consolidate message observer API for win and aura (and touch). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_x.h" 5 #include "base/message_pump_x.h"
6 6
7 #include <X11/extensions/XInput2.h> 7 #include <X11/extensions/XInput2.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 bool MessagePumpX::ProcessXEvent(XEvent* xev) { 174 bool MessagePumpX::ProcessXEvent(XEvent* xev) {
175 bool should_quit = false; 175 bool should_quit = false;
176 176
177 bool have_cookie = false; 177 bool have_cookie = false;
178 if (xev->type == GenericEvent && 178 if (xev->type == GenericEvent &&
179 XGetEventData(xev->xgeneric.display, &xev->xcookie)) { 179 XGetEventData(xev->xgeneric.display, &xev->xcookie)) {
180 have_cookie = true; 180 have_cookie = true;
181 } 181 }
182 182
183 if (WillProcessXEvent(xev) == MessagePumpObserver::EVENT_CONTINUE) { 183 if (WillProcessXEvent(xev) == EVENT_CONTINUE) {
184 MessagePumpDispatcher::DispatchStatus status = 184 MessagePumpDispatcher::DispatchStatus status =
185 GetDispatcher()->Dispatch(xev); 185 GetDispatcher()->Dispatch(xev);
186 186
187 if (status == MessagePumpDispatcher::EVENT_QUIT) { 187 if (status == MessagePumpDispatcher::EVENT_QUIT) {
188 should_quit = true; 188 should_quit = true;
189 Quit(); 189 Quit();
190 } else if (status == MessagePumpDispatcher::EVENT_IGNORED) { 190 } else if (status == MessagePumpDispatcher::EVENT_IGNORED) {
191 VLOG(1) << "Event (" << xev->type << ") not handled."; 191 VLOG(1) << "Event (" << xev->type << ") not handled.";
192 } 192 }
193 DidProcessXEvent(xev);
193 } 194 }
194 195
195 if (have_cookie) { 196 if (have_cookie) {
196 XFreeEventData(xev->xgeneric.display, &xev->xcookie); 197 XFreeEventData(xev->xgeneric.display, &xev->xcookie);
197 } 198 }
198 199
199 return should_quit; 200 return should_quit;
200 } 201 }
201 202
202 bool MessagePumpX::RunOnce(GMainContext* context, bool block) { 203 bool MessagePumpX::RunOnce(GMainContext* context, bool block) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 retvalue = g_main_context_iteration(context, block); 245 retvalue = g_main_context_iteration(context, block);
245 #endif 246 #endif
246 247
247 return retvalue; 248 return retvalue;
248 } 249 }
249 250
250 bool MessagePumpX::WillProcessXEvent(XEvent* xevent) { 251 bool MessagePumpX::WillProcessXEvent(XEvent* xevent) {
251 ObserverListBase<MessagePumpObserver>::Iterator it(observers()); 252 ObserverListBase<MessagePumpObserver>::Iterator it(observers());
252 MessagePumpObserver* obs; 253 MessagePumpObserver* obs;
253 while ((obs = it.GetNext()) != NULL) { 254 while ((obs = it.GetNext()) != NULL) {
254 if (obs->WillProcessXEvent(xevent)) 255 if (obs->WillProcessEvent(xevent))
255 return true; 256 return true;
256 } 257 }
257 return false; 258 return false;
258 } 259 }
259 260
261 void MessagePumpX::DidProcessXEvent(XEvent* xevent) {
262 ObserverListBase<MessagePumpObserver>::Iterator it(observers());
263 MessagePumpObserver* obs;
264 while ((obs = it.GetNext()) != NULL) {
265 obs->DidProcessEvent(xevent);
266 }
267 }
268
260 #if defined(TOOLKIT_USES_GTK) 269 #if defined(TOOLKIT_USES_GTK)
261 GdkFilterReturn MessagePumpX::GdkEventFilter(GdkXEvent* gxevent, 270 GdkFilterReturn MessagePumpX::GdkEventFilter(GdkXEvent* gxevent,
262 GdkEvent* gevent, 271 GdkEvent* gevent,
263 gpointer data) { 272 gpointer data) {
264 MessagePumpX* pump = static_cast<MessagePumpX*>(data); 273 MessagePumpX* pump = static_cast<MessagePumpX*>(data);
265 XEvent* xev = static_cast<XEvent*>(gxevent); 274 XEvent* xev = static_cast<XEvent*>(gxevent);
266 275
267 if (pump->ShouldCaptureXEvent(xev) && pump->GetDispatcher()) { 276 if (pump->ShouldCaptureXEvent(xev) && pump->GetDispatcher()) {
268 pump->ProcessXEvent(xev); 277 pump->ProcessXEvent(xev);
269 return GDK_FILTER_REMOVE; 278 return GDK_FILTER_REMOVE;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 capture_x_events_[MotionNotify] = true; 317 capture_x_events_[MotionNotify] = true;
309 capture_gdk_events_[GDK_MOTION_NOTIFY] = true; 318 capture_gdk_events_[GDK_MOTION_NOTIFY] = true;
310 319
311 capture_x_events_[GenericEvent] = true; 320 capture_x_events_[GenericEvent] = true;
312 } 321 }
313 322
314 COMPILE_ASSERT(XLASTEvent >= LASTEvent, XLASTEvent_too_small); 323 COMPILE_ASSERT(XLASTEvent >= LASTEvent, XLASTEvent_too_small);
315 324
316 #endif // defined(TOOLKIT_USES_GTK) 325 #endif // defined(TOOLKIT_USES_GTK)
317 326
318 MessagePumpObserver::EventStatus
319 MessagePumpObserver::WillProcessXEvent(XEvent* xev) {
320 return EVENT_CONTINUE;
321 }
322
323 } // namespace base 327 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698