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

Side by Side Diff: base/message_pump_glib_x.cc

Issue 5110011: A non-GTK version of menus for touchui. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: '' Created 10 years, 1 month 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_glib_x.h" 5 #include "base/message_pump_glib_x.h"
6 6
7 #include <gdk/gdkx.h> 7 #include <gdk/gdkx.h>
8 #if defined(HAVE_XINPUT2) 8 #if defined(HAVE_XINPUT2)
9 #include <X11/extensions/XInput2.h> 9 #include <X11/extensions/XInput2.h>
10 #else 10 #else
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 #endif 78 #endif
79 InitializeEventsToCapture(); 79 InitializeEventsToCapture();
80 } 80 }
81 81
82 MessagePumpGlibX::~MessagePumpGlibX() { 82 MessagePumpGlibX::~MessagePumpGlibX() {
83 } 83 }
84 84
85 bool MessagePumpGlibX::RunOnce(GMainContext* context, bool block) { 85 bool MessagePumpGlibX::RunOnce(GMainContext* context, bool block) {
86 GdkDisplay* gdisp = gdk_display_get_default(); 86 GdkDisplay* gdisp = gdk_display_get_default();
87 Display* display = GDK_DISPLAY_XDISPLAY(gdisp); 87 Display* display = GDK_DISPLAY_XDISPLAY(gdisp);
88 static gboolean (*gdkdispatcher)(GSource*, GSourceFunc, void*) = NULL;
Evan Martin 2010/11/22 20:43:26 Is this really the best place for this state? Why
sadrul 2010/11/22 21:23:06 The default GDK event dispatcher should not change
89
90 if (!gdkdispatcher && gdksource_) {
91 gdkdispatcher = gdksource_->source_funcs->dispatch;
92 }
93
88 if (XPending(display)) { 94 if (XPending(display)) {
89 XEvent xev; 95 XEvent xev;
90 XPeekEvent(display, &xev); 96 XPeekEvent(display, &xev);
91 if (capture_x_events_[xev.type] 97 if (capture_x_events_[xev.type]
92 #if defined(HAVE_XINPUT2) 98 #if defined(HAVE_XINPUT2)
93 && (xev.type != GenericEvent || xev.xcookie.extension == xiopcode_) 99 && (xev.type != GenericEvent || xev.xcookie.extension == xiopcode_)
94 #endif 100 #endif
95 ) { 101 ) {
96 XNextEvent(display, &xev); 102 XNextEvent(display, &xev);
97 103
104 #if defined(HAVE_XINPUT2)
105 bool have_cookie = false;
106 if (xev.type == GenericEvent &&
107 XGetEventData(xev.xgeneric.display, &xev.xcookie)) {
108 have_cookie = true;
109 }
110 #endif
111
98 bool processed = static_cast<MessagePumpGlibXDispatcher*> 112 bool processed = static_cast<MessagePumpGlibXDispatcher*>
99 (GetDispatcher())->Dispatch(&xev); 113 (GetDispatcher())->Dispatch(&xev);
100 114
101 if (!processed) { 115 if (!processed) {
102 DLOG(WARNING) << "Event (" << xev.type << ") not handled."; 116 DLOG(WARNING) << "Event (" << xev.type << ") not handled.";
103 117
104 // TODO(sad): It is necessary to put back the event so that the default 118 // TODO(sad): It is necessary to put back the event so that the default
105 // GDK events handler can take care of it. Without this, it is 119 // GDK events handler can take care of it. Without this, it is
106 // impossible to use the omnibox at the moment. However, this will 120 // impossible to use the omnibox at the moment. However, this will
107 // eventually be removed once the omnibox code is updated for touchui. 121 // eventually be removed once the omnibox code is updated for touchui.
108 XPutBackEvent(display, &xev); 122 XPutBackEvent(display, &xev);
123 if (gdksource_)
124 gdksource_->source_funcs->dispatch = gdkdispatcher;
109 g_main_context_iteration(context, FALSE); 125 g_main_context_iteration(context, FALSE);
110 } 126 }
127
128 #if defined(HAVE_XINPUT2)
129 if (have_cookie) {
130 XFreeEventData(xev.xgeneric.display, &xev.xcookie);
131 }
132 #endif
111 } else { 133 } else {
112 // TODO(sad): A couple of extra events can still sneak in during this. 134 // TODO(sad): A couple of extra events can still sneak in during this.
113 // Those should be sent back to the X queue from the dispatcher 135 // Those should be sent back to the X queue from the dispatcher
114 // EventDispatcherX. 136 // EventDispatcherX.
137 if (gdksource_)
138 gdksource_->source_funcs->dispatch = gdkdispatcher;
115 g_main_context_iteration(context, FALSE); 139 g_main_context_iteration(context, FALSE);
116 } 140 }
117 } 141 }
118 142
119 bool retvalue; 143 bool retvalue;
120 if (gdksource_) { 144 if (gdksource_) {
121 // Replace the dispatch callback of the GDK event source temporarily so that 145 // Replace the dispatch callback of the GDK event source temporarily so that
122 // it doesn't read events from X. 146 // it doesn't read events from X.
123 gboolean (*cb)(GSource*, GSourceFunc, void*) = 147 gboolean (*cb)(GSource*, GSourceFunc, void*) =
124 gdksource_->source_funcs->dispatch; 148 gdksource_->source_funcs->dispatch;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // X queue so that we catch it in the next iteration. When done, the 273 // X queue so that we catch it in the next iteration. When done, the
250 // following DLOG statement will be removed. 274 // following DLOG statement will be removed.
251 DLOG(WARNING) << "GDK received an event it shouldn't have"; 275 DLOG(WARNING) << "GDK received an event it shouldn't have";
252 } 276 }
253 } 277 }
254 278
255 pump_x->DispatchEvents(event); 279 pump_x->DispatchEvents(event);
256 } 280 }
257 281
258 } // namespace base 282 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/wrench_menu.cc » ('j') | views/focus/accelerator_handler_touch.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698