Chromium Code Reviews| Index: base/message_pump_glib_x.cc |
| diff --git a/base/message_pump_glib_x.cc b/base/message_pump_glib_x.cc |
| index 78c179933d00a7e5a70d0d94c3675fe7b9dd1379..d673e5062dd82c35e882e649cf0119cc25ab86db 100644 |
| --- a/base/message_pump_glib_x.cc |
| +++ b/base/message_pump_glib_x.cc |
| @@ -85,6 +85,12 @@ MessagePumpGlibX::~MessagePumpGlibX() { |
| bool MessagePumpGlibX::RunOnce(GMainContext* context, bool block) { |
| GdkDisplay* gdisp = gdk_display_get_default(); |
| Display* display = GDK_DISPLAY_XDISPLAY(gdisp); |
| + 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
|
| + |
| + if (!gdkdispatcher && gdksource_) { |
| + gdkdispatcher = gdksource_->source_funcs->dispatch; |
| + } |
| + |
| if (XPending(display)) { |
| XEvent xev; |
| XPeekEvent(display, &xev); |
| @@ -95,6 +101,14 @@ bool MessagePumpGlibX::RunOnce(GMainContext* context, bool block) { |
| ) { |
| XNextEvent(display, &xev); |
| +#if defined(HAVE_XINPUT2) |
| + bool have_cookie = false; |
| + if (xev.type == GenericEvent && |
| + XGetEventData(xev.xgeneric.display, &xev.xcookie)) { |
| + have_cookie = true; |
| + } |
| +#endif |
| + |
| bool processed = static_cast<MessagePumpGlibXDispatcher*> |
| (GetDispatcher())->Dispatch(&xev); |
| @@ -106,12 +120,22 @@ bool MessagePumpGlibX::RunOnce(GMainContext* context, bool block) { |
| // impossible to use the omnibox at the moment. However, this will |
| // eventually be removed once the omnibox code is updated for touchui. |
| XPutBackEvent(display, &xev); |
| + if (gdksource_) |
| + gdksource_->source_funcs->dispatch = gdkdispatcher; |
| g_main_context_iteration(context, FALSE); |
| } |
| + |
| +#if defined(HAVE_XINPUT2) |
| + if (have_cookie) { |
| + XFreeEventData(xev.xgeneric.display, &xev.xcookie); |
| + } |
| +#endif |
| } else { |
| // TODO(sad): A couple of extra events can still sneak in during this. |
| // Those should be sent back to the X queue from the dispatcher |
| // EventDispatcherX. |
| + if (gdksource_) |
| + gdksource_->source_funcs->dispatch = gdkdispatcher; |
| g_main_context_iteration(context, FALSE); |
| } |
| } |