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

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: sync Created 9 years, 2 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 bool MessagePumpX::ProcessXEvent(XEvent* xev) { 187 bool MessagePumpX::ProcessXEvent(XEvent* xev) {
188 bool should_quit = false; 188 bool should_quit = false;
189 189
190 bool have_cookie = false; 190 bool have_cookie = false;
191 if (xev->type == GenericEvent && 191 if (xev->type == GenericEvent &&
192 XGetEventData(xev->xgeneric.display, &xev->xcookie)) { 192 XGetEventData(xev->xgeneric.display, &xev->xcookie)) {
193 have_cookie = true; 193 have_cookie = true;
194 } 194 }
195 195
196 if (WillProcessXEvent(xev) == MessagePumpObserver::EVENT_CONTINUE) { 196 if (WillProcessXEvent(xev) == EVENT_CONTINUE) {
197 MessagePumpDispatcher::DispatchStatus status = 197 MessagePumpDispatcher::DispatchStatus status =
198 GetDispatcher()->Dispatch(xev); 198 GetDispatcher()->Dispatch(xev);
199 199
200 if (status == MessagePumpDispatcher::EVENT_QUIT) { 200 if (status == MessagePumpDispatcher::EVENT_QUIT) {
201 should_quit = true; 201 should_quit = true;
202 Quit(); 202 Quit();
203 } else if (status == MessagePumpDispatcher::EVENT_IGNORED) { 203 } else if (status == MessagePumpDispatcher::EVENT_IGNORED) {
204 VLOG(1) << "Event (" << xev->type << ") not handled."; 204 VLOG(1) << "Event (" << xev->type << ") not handled.";
205 } 205 }
206 DidProcessXEvent(xev);
206 } 207 }
207 208
208 if (have_cookie) { 209 if (have_cookie) {
209 XFreeEventData(xev->xgeneric.display, &xev->xcookie); 210 XFreeEventData(xev->xgeneric.display, &xev->xcookie);
210 } 211 }
211 212
212 return should_quit; 213 return should_quit;
213 } 214 }
214 215
215 bool MessagePumpX::RunOnce(GMainContext* context, bool block) { 216 bool MessagePumpX::RunOnce(GMainContext* context, bool block) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 retvalue = g_main_context_iteration(context, block); 258 retvalue = g_main_context_iteration(context, block);
258 #endif 259 #endif
259 260
260 return retvalue; 261 return retvalue;
261 } 262 }
262 263
263 bool MessagePumpX::WillProcessXEvent(XEvent* xevent) { 264 bool MessagePumpX::WillProcessXEvent(XEvent* xevent) {
264 ObserverListBase<MessagePumpObserver>::Iterator it(observers()); 265 ObserverListBase<MessagePumpObserver>::Iterator it(observers());
265 MessagePumpObserver* obs; 266 MessagePumpObserver* obs;
266 while ((obs = it.GetNext()) != NULL) { 267 while ((obs = it.GetNext()) != NULL) {
267 if (obs->WillProcessXEvent(xevent)) 268 if (obs->WillProcessEvent(xevent))
268 return true; 269 return true;
269 } 270 }
270 return false; 271 return false;
271 } 272 }
272 273
274 void MessagePumpX::DidProcessXEvent(XEvent* xevent) {
275 ObserverListBase<MessagePumpObserver>::Iterator it(observers());
276 MessagePumpObserver* obs;
277 while ((obs = it.GetNext()) != NULL) {
278 obs->DidProcessEvent(xevent);
279 }
280 }
281
273 #if defined(TOOLKIT_USES_GTK) 282 #if defined(TOOLKIT_USES_GTK)
274 GdkFilterReturn MessagePumpX::GdkEventFilter(GdkXEvent* gxevent, 283 GdkFilterReturn MessagePumpX::GdkEventFilter(GdkXEvent* gxevent,
275 GdkEvent* gevent, 284 GdkEvent* gevent,
276 gpointer data) { 285 gpointer data) {
277 MessagePumpX* pump = static_cast<MessagePumpX*>(data); 286 MessagePumpX* pump = static_cast<MessagePumpX*>(data);
278 XEvent* xev = static_cast<XEvent*>(gxevent); 287 XEvent* xev = static_cast<XEvent*>(gxevent);
279 288
280 if (pump->ShouldCaptureXEvent(xev) && pump->GetDispatcher()) { 289 if (pump->ShouldCaptureXEvent(xev) && pump->GetDispatcher()) {
281 pump->ProcessXEvent(xev); 290 pump->ProcessXEvent(xev);
282 return GDK_FILTER_REMOVE; 291 return GDK_FILTER_REMOVE;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 capture_x_events_[MotionNotify] = true; 330 capture_x_events_[MotionNotify] = true;
322 capture_gdk_events_[GDK_MOTION_NOTIFY] = true; 331 capture_gdk_events_[GDK_MOTION_NOTIFY] = true;
323 332
324 capture_x_events_[GenericEvent] = true; 333 capture_x_events_[GenericEvent] = true;
325 } 334 }
326 335
327 COMPILE_ASSERT(XLASTEvent >= LASTEvent, XLASTEvent_too_small); 336 COMPILE_ASSERT(XLASTEvent >= LASTEvent, XLASTEvent_too_small);
328 337
329 #endif // defined(TOOLKIT_USES_GTK) 338 #endif // defined(TOOLKIT_USES_GTK)
330 339
331 MessagePumpObserver::EventStatus
332 MessagePumpObserver::WillProcessXEvent(XEvent* xev) {
333 return EVENT_CONTINUE;
334 }
335
336 } // namespace base 340 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698