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

Side by Side Diff: base/message_pump_x.h

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 #ifndef BASE_MESSAGE_PUMP_X_H 5 #ifndef BASE_MESSAGE_PUMP_X_H
6 #define BASE_MESSAGE_PUMP_X_H 6 #define BASE_MESSAGE_PUMP_X_H
7 7
8 #include "base/message_pump.h" 8 #include "base/message_pump.h"
9 #include "base/message_pump_glib.h" 9 #include "base/message_pump_glib.h"
10 #include "base/message_pump_observer.h"
10 11
11 #include <bitset> 12 #include <bitset>
12 13
13 #include <glib.h> 14 #include <glib.h>
14 15
15 #if defined(TOOLKIT_USES_GTK) 16 #if defined(TOOLKIT_USES_GTK)
16 #include <gtk/gtk.h> 17 #include <gtk/gtk.h>
17 #endif 18 #endif
18 19
19 typedef union _XEvent XEvent;
20 typedef struct _XDisplay Display; 20 typedef struct _XDisplay Display;
21 21
22 namespace base { 22 namespace base {
23 23
24 // The documentation for this class is in message_pump_glib.h 24 // The documentation for this class is in message_pump_glib.h
25 class BASE_EXPORT MessagePumpObserver {
26 public:
27 enum EventStatus {
28 EVENT_CONTINUE, // The event should be dispatched as normal.
29 EVENT_HANDLED // The event should not be processed any farther.
30 };
31
32 // This method is called before processing an XEvent. If the method returns
33 // EVENT_HANDLED, it indicates the event has already been handled, so the
34 // event is not processed any farther. If the method returns EVENT_CONTINUE,
35 // the event dispatching proceeds as normal.
36 virtual EventStatus WillProcessXEvent(XEvent* xevent);
37
38 protected:
39 virtual ~MessagePumpObserver() {}
40 };
41
42 // The documentation for this class is in message_pump_glib.h
43 // 25 //
44 // The nested loop is exited by either posting a quit, or returning EVENT_QUIT 26 // The nested loop is exited by either posting a quit, or returning EVENT_QUIT
45 // from Dispatch. 27 // from Dispatch.
46 class MessagePumpDispatcher { 28 class MessagePumpDispatcher {
47 public: 29 public:
48 enum DispatchStatus { 30 enum DispatchStatus {
49 EVENT_IGNORED, // The event was not processed. 31 EVENT_IGNORED, // The event was not processed.
50 EVENT_PROCESSED, // The event has been processed. 32 EVENT_PROCESSED, // The event has been processed.
51 EVENT_QUIT // The event was processed and the message-loop should 33 EVENT_QUIT // The event was processed and the message-loop should
52 // terminate. 34 // terminate.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 bool ShouldCaptureXEvent(XEvent* event); 72 bool ShouldCaptureXEvent(XEvent* event);
91 73
92 // Dispatches the XEvent and returns true if we should exit the current loop 74 // Dispatches the XEvent and returns true if we should exit the current loop
93 // of message processing. 75 // of message processing.
94 bool ProcessXEvent(XEvent* event); 76 bool ProcessXEvent(XEvent* event);
95 77
96 // Sends the event to the observers. If an observer returns true, then it does 78 // Sends the event to the observers. If an observer returns true, then it does
97 // not send the event to any other observers and returns true. Returns false 79 // not send the event to any other observers and returns true. Returns false
98 // if no observer returns true. 80 // if no observer returns true.
99 bool WillProcessXEvent(XEvent* xevent); 81 bool WillProcessXEvent(XEvent* xevent);
82 void DidProcessXEvent(XEvent* xevent);
100 #if defined(TOOLKIT_USES_GTK) 83 #if defined(TOOLKIT_USES_GTK)
101 // Some XEvent's can't be directly read from X event queue and will go 84 // Some XEvent's can't be directly read from X event queue and will go
102 // through GDK's dispatching process and may get discarded. This function 85 // through GDK's dispatching process and may get discarded. This function
103 // sets up a filter to intercept those XEvent's we are interested in 86 // sets up a filter to intercept those XEvent's we are interested in
104 // and dispatches them so that they won't get lost. 87 // and dispatches them so that they won't get lost.
105 static GdkFilterReturn GdkEventFilter(GdkXEvent* gxevent, 88 static GdkFilterReturn GdkEventFilter(GdkXEvent* gxevent,
106 GdkEvent* gevent, 89 GdkEvent* gevent,
107 gpointer data); 90 gpointer data);
108 91
109 static void EventDispatcherX(GdkEvent* event, gpointer data); 92 static void EventDispatcherX(GdkEvent* event, gpointer data);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 GSource* x_source_; 134 GSource* x_source_;
152 135
153 DISALLOW_COPY_AND_ASSIGN(MessagePumpX); 136 DISALLOW_COPY_AND_ASSIGN(MessagePumpX);
154 }; 137 };
155 138
156 typedef MessagePumpX MessagePumpForUI; 139 typedef MessagePumpX MessagePumpForUI;
157 140
158 } // namespace base 141 } // namespace base
159 142
160 #endif // BASE_MESSAGE_PUMP_X_H 143 #endif // BASE_MESSAGE_PUMP_X_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698