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

Side by Side Diff: base/message_pump_x.h

Issue 7978007: Revert 102005 - aura: Explicitly disable GTK. (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
« no previous file with comments | « base/message_pump_glib_unittest.cc ('k') | base/message_pump_x.cc » ('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) 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 10
11 #include <bitset> 11 #include <bitset>
12 12
13 #include <glib.h> 13 #include <glib.h>
14
15 #if defined(TOOLKIT_USES_GTK)
16 #include <gtk/gtk.h> 14 #include <gtk/gtk.h>
17 #endif
18 15
19 typedef union _XEvent XEvent; 16 typedef union _XEvent XEvent;
20 typedef struct _XDisplay Display; 17 typedef struct _XDisplay Display;
21 18
22 namespace base { 19 namespace base {
23 20
24 // The documentation for this class is in message_pump_glib.h 21 // The documentation for this class is in message_pump_glib.h
25 class BASE_EXPORT MessagePumpObserver { 22 class BASE_EXPORT MessagePumpObserver {
26 public: 23 public:
27 enum EventStatus { 24 enum EventStatus {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 protected: 57 protected:
61 virtual ~MessagePumpDispatcher() {} 58 virtual ~MessagePumpDispatcher() {}
62 }; 59 };
63 60
64 // This class implements a message-pump for dispatching X events. 61 // This class implements a message-pump for dispatching X events.
65 class BASE_EXPORT MessagePumpX : public MessagePumpGlib { 62 class BASE_EXPORT MessagePumpX : public MessagePumpGlib {
66 public: 63 public:
67 MessagePumpX(); 64 MessagePumpX();
68 virtual ~MessagePumpX(); 65 virtual ~MessagePumpX();
69 66
67 // Indicates whether a GDK event was injected by chrome (when |true|) or if it
68 // was captured and being processed by GDK (when |false|).
69 bool IsDispatchingEvent(void) { return dispatching_event_; }
70
70 // Overridden from MessagePumpGlib: 71 // Overridden from MessagePumpGlib:
71 virtual bool RunOnce(GMainContext* context, bool block) OVERRIDE; 72 virtual bool RunOnce(GMainContext* context, bool block) OVERRIDE;
72 73
73 #if defined(TOOLKIT_USES_GTK)
74 // Disables Gtk/Gdk event pumping. This will be used when 74 // Disables Gtk/Gdk event pumping. This will be used when
75 // NativeWidgetX is enabled. 75 // NativeWidgetX is enabled.
76 static void DisableGtkMessagePump(); 76 static void DisableGtkMessagePump();
77 #endif
78 77
79 // Returns default X Display. 78 // Returns default X Display.
80 static Display* GetDefaultXDisplay(); 79 static Display* GetDefaultXDisplay();
81 80
82 // Returns true if the system supports XINPUT2. 81 // Returns true if the system supports XINPUT2.
83 static bool HasXInput2(); 82 static bool HasXInput2();
84 83
85 private: 84 private:
86 // Initializes the glib event source for X. 85 // Some XEvent's can't be directly read from X event queue and will go
87 void InitXSource(); 86 // through GDK's dispatching process and may get discarded. This function
87 // sets up a filter to intercept those XEvent's we are interested in
88 // and dispatches them so that they won't get lost.
89 static GdkFilterReturn GdkEventFilter(GdkXEvent* gxevent,
90 GdkEvent* gevent,
91 gpointer data);
92
93 static void EventDispatcherX(GdkEvent* event, gpointer data);
88 94
89 // Decides whether we are interested in processing this XEvent. 95 // Decides whether we are interested in processing this XEvent.
90 bool ShouldCaptureXEvent(XEvent* event); 96 bool ShouldCaptureXEvent(XEvent* event);
91 97
92 // Dispatches the XEvent and returns true if we should exit the current loop 98 // Dispatches the XEvent and returns true if we should exit the current loop
93 // of message processing. 99 // of message processing.
94 bool ProcessXEvent(XEvent* event); 100 bool ProcessXEvent(XEvent* event);
95 101
96 // Sends the event to the observers. If an observer returns true, then it does 102 // 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 103 // not send the event to any other observers and returns true. Returns false
98 // if no observer returns true. 104 // if no observer returns true.
99 bool WillProcessXEvent(XEvent* xevent); 105 bool WillProcessXEvent(XEvent* xevent);
100 #if defined(TOOLKIT_USES_GTK)
101 // 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
103 // sets up a filter to intercept those XEvent's we are interested in
104 // and dispatches them so that they won't get lost.
105 static GdkFilterReturn GdkEventFilter(GdkXEvent* gxevent,
106 GdkEvent* gevent,
107 gpointer data);
108
109 static void EventDispatcherX(GdkEvent* event, gpointer data);
110
111 // Indicates whether a GDK event was injected by chrome (when |true|) or if it
112 // was captured and being processed by GDK (when |false|).
113 bool IsDispatchingEvent(void) { return dispatching_event_; }
114 106
115 // Update the lookup table and flag the events that should be captured and 107 // Update the lookup table and flag the events that should be captured and
116 // processed so that GDK doesn't get to them. 108 // processed so that GDK doesn't get to them.
117 void InitializeEventsToCapture(void); 109 void InitializeEventsToCapture(void);
118 110
111 // The event source for X events (used only when GTK event processing is
112 // disabled).
113 GSource* x_source_;
114
119 // The event source for GDK events. 115 // The event source for GDK events.
120 GSource* gdksource_; 116 GSource* gdksource_;
121 117
122 // The default GDK event dispatcher. This is stored so that it can be restored 118 // The default GDK event dispatcher. This is stored so that it can be restored
123 // when necessary during nested event dispatching. 119 // when necessary during nested event dispatching.
124 gboolean (*gdkdispatcher_)(GSource*, GSourceFunc, void*); 120 gboolean (*gdkdispatcher_)(GSource*, GSourceFunc, void*);
125 121
126 // Indicates whether a GDK event was injected by chrome (when |true|) or if it 122 // Indicates whether a GDK event was injected by chrome (when |true|) or if it
127 // was captured and being processed by GDK (when |false|). 123 // was captured and being processed by GDK (when |false|).
128 bool dispatching_event_; 124 bool dispatching_event_;
129 125
130 #if ! GTK_CHECK_VERSION(2,18,0) 126 #if ! GTK_CHECK_VERSION(2,18,0)
131 // GDK_EVENT_LAST was introduced in GTK+ 2.18.0. For earlier versions, we pick a 127 // GDK_EVENT_LAST was introduced in GTK+ 2.18.0. For earlier versions, we pick a
132 // large enough value (the value of GDK_EVENT_LAST in 2.18.0) so that it works 128 // large enough value (the value of GDK_EVENT_LAST in 2.18.0) so that it works
133 // for all versions. 129 // for all versions.
134 #define GDK_EVENT_LAST 37 130 #define GDK_EVENT_LAST 37
135 #endif 131 #endif
136 132
137 // Ideally we would #include X.h for LASTEvent, but it brings in a lot of stupid 133 // Ideally we would #include X.h for LASTEvent, but it brings in a lot of stupid
138 // stuff (like Time, CurrentTime etc.) that messes up a lot of things. So define 134 // stuff (like Time, CurrentTime etc.) that messes up a lot of things. So define
139 // XLASTEvent here to a large enough value so that it works. 135 // XLASTEvent here to a large enough value so that it works.
140 #define XLASTEvent 40 136 #define XLASTEvent 40
141 137
142 // We do not want to process all the events ourselves. So we use a lookup 138 // We do not want to process all the events ourselves. So we use a lookup
143 // table to quickly check if a particular event should be handled by us or if 139 // table to quickly check if a particular event should be handled by us or if
144 // it should be passed on to the default GDK handler. 140 // it should be passed on to the default GDK handler.
145 std::bitset<XLASTEvent> capture_x_events_; 141 std::bitset<XLASTEvent> capture_x_events_;
146 std::bitset<GDK_EVENT_LAST> capture_gdk_events_; 142 std::bitset<GDK_EVENT_LAST> capture_gdk_events_;
147 #endif // defined(TOOLKIT_USES_GTK)
148
149 // The event source for X events (used only when GTK event processing is
150 // disabled).
151 GSource* x_source_;
152 143
153 DISALLOW_COPY_AND_ASSIGN(MessagePumpX); 144 DISALLOW_COPY_AND_ASSIGN(MessagePumpX);
154 }; 145 };
155 146
156 typedef MessagePumpX MessagePumpForUI; 147 typedef MessagePumpX MessagePumpForUI;
157 148
158 } // namespace base 149 } // namespace base
159 150
160 #endif // BASE_MESSAGE_PUMP_X_H 151 #endif // BASE_MESSAGE_PUMP_X_H
OLDNEW
« no previous file with comments | « base/message_pump_glib_unittest.cc ('k') | base/message_pump_x.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698