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

Side by Side Diff: base/message_pump_glib_x.cc

Issue 3801011: touchui: Directly process key and mouse events. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: nit Created 10 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
« no previous file with comments | « base/message_pump_glib.cc ('k') | base/message_pump_glib_x_dispatch.h » ('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) 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 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 #include "base/message_pump_glib_x_dispatch.h"
11
10 namespace { 12 namespace {
11 13
12 gboolean PlaceholderDispatch(GSource* source, 14 gboolean PlaceholderDispatch(GSource* source,
13 GSourceFunc cb, 15 GSourceFunc cb,
14 gpointer data) { 16 gpointer data) {
15 return TRUE; 17 return TRUE;
16 } 18 }
17 19
18 } // namespace 20 } // namespace
19 21
(...skipping 14 matching lines...) Expand all
34 36
35 bool MessagePumpGlibX::RunOnce(GMainContext* context, bool block) { 37 bool MessagePumpGlibX::RunOnce(GMainContext* context, bool block) {
36 GdkDisplay* gdisp = gdk_display_get_default(); 38 GdkDisplay* gdisp = gdk_display_get_default();
37 Display* display = GDK_DISPLAY_XDISPLAY(gdisp); 39 Display* display = GDK_DISPLAY_XDISPLAY(gdisp);
38 if (XPending(display)) { 40 if (XPending(display)) {
39 XEvent xev; 41 XEvent xev;
40 XPeekEvent(display, &xev); 42 XPeekEvent(display, &xev);
41 if (capture_x_events_[xev.type]) { 43 if (capture_x_events_[xev.type]) {
42 XNextEvent(display, &xev); 44 XNextEvent(display, &xev);
43 45
44 DLOG(INFO) << "nom noming event"; 46 bool processed = static_cast<MessagePumpGlibXDispatcher*>
47 (GetDispatcher())->Dispatch(&xev);
45 48
46 // TODO(sad): Create a GdkEvent from |xev| and pass it on to 49 if (!processed) {
47 // EventDispatcherX. The ultimate goal is to create a views::Event from 50 DLOG(WARNING) << "Event (" << xev.type << ") not handled.";
48 // |xev| and send it to a rootview. When done, the preceding DLOG will be 51 }
49 // removed.
50 } else { 52 } else {
51 // TODO(sad): A couple of extra events can still sneak in during this 53 // TODO(sad): A couple of extra events can still sneak in during this.
54 // Those should be sent back to the X queue from the dispatcher
55 // EventDispatcherX.
52 g_main_context_iteration(context, FALSE); 56 g_main_context_iteration(context, FALSE);
53 } 57 }
54 } 58 }
55 59
56 bool retvalue; 60 bool retvalue;
57 if (gdksource_) { 61 if (gdksource_) {
58 // Replace the dispatch callback of the GDK event source temporarily so that 62 // Replace the dispatch callback of the GDK event source temporarily so that
59 // it doesn't read events from X. 63 // it doesn't read events from X.
60 gboolean (*cb)(GSource*, GSourceFunc, void*) = 64 gboolean (*cb)(GSource*, GSourceFunc, void*) =
61 gdksource_->source_funcs->dispatch; 65 gdksource_->source_funcs->dispatch;
(...skipping 12 matching lines...) Expand all
74 } 78 }
75 79
76 void MessagePumpGlibX::InitializeEventsToCapture(void) { 80 void MessagePumpGlibX::InitializeEventsToCapture(void) {
77 // TODO(sad): Decide which events we want to capture and update the tables 81 // TODO(sad): Decide which events we want to capture and update the tables
78 // accordingly. 82 // accordingly.
79 capture_x_events_[KeyPress] = true; 83 capture_x_events_[KeyPress] = true;
80 capture_gdk_events_[GDK_KEY_PRESS] = true; 84 capture_gdk_events_[GDK_KEY_PRESS] = true;
81 85
82 capture_x_events_[KeyRelease] = true; 86 capture_x_events_[KeyRelease] = true;
83 capture_gdk_events_[GDK_KEY_RELEASE] = true; 87 capture_gdk_events_[GDK_KEY_RELEASE] = true;
88
89 capture_x_events_[ButtonPress] = true;
90 capture_gdk_events_[GDK_BUTTON_PRESS] = true;
91
92 capture_x_events_[ButtonRelease] = true;
93 capture_gdk_events_[GDK_BUTTON_RELEASE] = true;
94
95 capture_x_events_[MotionNotify] = true;
96 capture_gdk_events_[GDK_MOTION_NOTIFY] = true;
84 } 97 }
85 98
86 void MessagePumpGlibX::EventDispatcherX(GdkEvent* event, gpointer data) { 99 void MessagePumpGlibX::EventDispatcherX(GdkEvent* event, gpointer data) {
87 MessagePumpGlibX* pump_x = reinterpret_cast<MessagePumpGlibX*>(data); 100 MessagePumpGlibX* pump_x = reinterpret_cast<MessagePumpGlibX*>(data);
88 101
89 if (!pump_x->gdksource_) { 102 if (!pump_x->gdksource_) {
90 pump_x->gdksource_ = g_main_current_source(); 103 pump_x->gdksource_ = g_main_current_source();
91 } else if (!pump_x->IsDispatchingEvent()) { 104 } else if (!pump_x->IsDispatchingEvent()) {
92 if (event->type != GDK_NOTHING && 105 if (event->type != GDK_NOTHING &&
93 pump_x->capture_gdk_events_[event->type]) { 106 pump_x->capture_gdk_events_[event->type]) {
94 // TODO(sad): An X event is caught by the GDK handler. Put it back in the 107 // TODO(sad): An X event is caught by the GDK handler. Put it back in the
95 // X queue so that we catch it in the next iteration. When done, the 108 // X queue so that we catch it in the next iteration. When done, the
96 // following DLOG statement will be removed. 109 // following DLOG statement will be removed.
97 DLOG(INFO) << "GDK ruined it!!"; 110 DLOG(WARNING) << "GDK received an event it shouldn't have";
98 } 111 }
99 } 112 }
100 113
101 pump_x->DispatchEvents(event); 114 pump_x->DispatchEvents(event);
102 } 115 }
103 116
104 } // namespace base 117 } // namespace base
OLDNEW
« no previous file with comments | « base/message_pump_glib.cc ('k') | base/message_pump_glib_x_dispatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698