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

Side by Side Diff: ui/events/platform/x11/x11_event_source.cc

Issue 219743002: x11: Move X event handling out of the message-pump. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge-r261267 Created 6 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/events/platform/x11/x11_event_source.h" 5 #include "ui/events/platform/x11/x11_event_source.h"
6 6
7 #include <glib.h> 7 #include <glib.h>
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <X11/X.h> 9 #include <X11/X.h>
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
11 #include <X11/XKBlib.h> 11 #include <X11/XKBlib.h>
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "ui/events/platform/platform_event_dispatcher.h" 15 #include "ui/events/platform/platform_event_dispatcher.h"
16 #include "ui/gfx/x/x11_types.h"
16 17
17 namespace ui { 18 namespace ui {
18 19
19 namespace { 20 namespace {
20 21
21 struct GLibX11Source : public GSource { 22 struct GLibX11Source : public GSource {
22 // Note: The GLibX11Source is created and destroyed by GLib. So its 23 // Note: The GLibX11Source is created and destroyed by GLib. So its
23 // constructor/destructor may or may not get called. 24 // constructor/destructor may or may not get called.
24 XDisplay* display; 25 XDisplay* display;
25 GPollFD* poll_fd; 26 GPollFD* poll_fd;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 g_source_set_callback(x_source_, NULL, this, NULL); 186 g_source_set_callback(x_source_, NULL, this, NULL);
186 g_source_attach(x_source_, g_main_context_default()); 187 g_source_attach(x_source_, g_main_context_default());
187 } 188 }
188 189
189 uint32_t X11EventSource::DispatchEvent(XEvent* xevent) { 190 uint32_t X11EventSource::DispatchEvent(XEvent* xevent) {
190 bool have_cookie = false; 191 bool have_cookie = false;
191 if (xevent->type == GenericEvent && 192 if (xevent->type == GenericEvent &&
192 XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) { 193 XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) {
193 have_cookie = true; 194 have_cookie = true;
194 } 195 }
195 int action = PlatformEventSource::DispatchEvent(xevent); 196
197 // TODO(sad): Remove this once all MessagePumpObservers are turned into
198 // PlatformEventObservers.
199 uint32_t action = ui::POST_DISPATCH_NONE;
200 if (!base::MessagePumpX11::Current()->WillProcessXEvent(xevent)) {
201 action = PlatformEventSource::DispatchEvent(xevent);
202 base::MessagePumpX11::Current()->DidProcessXEvent(xevent);
203 }
204
196 if (have_cookie) 205 if (have_cookie)
197 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie); 206 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie);
198 return action; 207 return action;
199 } 208 }
200 209
210 scoped_ptr<PlatformEventSource> PlatformEventSource::CreateDefault() {
211 return scoped_ptr<PlatformEventSource>(
212 new X11EventSource(gfx::GetXDisplay()));
213 }
214
201 } // namespace ui 215 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/platform/platform_event_source_stub.cc ('k') | ui/views/controls/menu/menu_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698