summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorrjkroege@google.com <rjkroege@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-26 18:43:18 +0000
committerrjkroege@google.com <rjkroege@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-26 18:43:18 +0000
commitb2f7ac4583b968d0c20ea8f6c4110aeb6882699a (patch)
tree7bcf1278af056ab056221da0ee01e81851e9ebde /base
parentbd2b41afb25b648e3f77dce87064971f63894a7f (diff)
downloadchromium_src-b2f7ac4583b968d0c20ea8f6c4110aeb6882699a.zip
chromium_src-b2f7ac4583b968d0c20ea8f6c4110aeb6882699a.tar.gz
chromium_src-b2f7ac4583b968d0c20ea8f6c4110aeb6882699a.tar.bz2
touchui: Directly process key and mouse events.
Capture the keyboard and mouse events directly from X, create a corresponding views::Event out of it, and send it to the associated RootView. Includes Chad's (wyck) function FindRootViewForGdkEvent (from #3704005) slightly modified (called FindRootViewForGdkWindow). BUG=None TEST=Click/Keypress events in a webpage should work correctly. Review URL: http://codereview.chromium.org/3801011 Patch from Sadrul Chowdhury <sadrul@chromium.org>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63916 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/base.gypi1
-rw-r--r--base/message_loop.h7
-rw-r--r--base/message_pump_glib.cc4
-rw-r--r--base/message_pump_glib.h4
-rw-r--r--base/message_pump_glib_x.cc27
-rw-r--r--base/message_pump_glib_x_dispatch.h28
6 files changed, 64 insertions, 7 deletions
diff --git a/base/base.gypi b/base/base.gypi
index 9a32325..690b852 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -456,6 +456,7 @@
'message_pump_glib.h',
'message_pump_glib_x.cc',
'message_pump_glib_x.h',
+ 'message_pump_glib_x_dispatch.h',
'message_pump_libevent.cc',
'message_pump_libevent.h',
'message_pump_mac.h',
diff --git a/base/message_loop.h b/base/message_loop.h
index 37e4b81..f4b1a4d 100644
--- a/base/message_loop.h
+++ b/base/message_loop.h
@@ -26,6 +26,9 @@
#include "base/message_pump_glib.h"
#endif
#endif
+#if defined(TOUCH_UI)
+#include "base/message_pump_glib_x_dispatch.h"
+#endif
namespace base {
class Histogram;
@@ -290,7 +293,11 @@ class MessageLoop : public base::MessagePump::Delegate {
typedef base::MessagePumpWin::Dispatcher Dispatcher;
typedef base::MessagePumpForUI::Observer Observer;
#elif !defined(OS_MACOSX)
+#if defined(TOUCH_UI)
+ typedef base::MessagePumpGlibXDispatcher Dispatcher;
+#else
typedef base::MessagePumpForUI::Dispatcher Dispatcher;
+#endif
typedef base::MessagePumpForUI::Observer Observer;
#endif
diff --git a/base/message_pump_glib.cc b/base/message_pump_glib.cc
index ad6d177..616c24c 100644
--- a/base/message_pump_glib.cc
+++ b/base/message_pump_glib.cc
@@ -303,6 +303,10 @@ void MessagePumpForUI::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
+MessagePumpForUI::Dispatcher* MessagePumpForUI::GetDispatcher() {
+ return state_ ? state_->dispatcher : NULL;
+}
+
void MessagePumpForUI::WillProcessEvent(GdkEvent* event) {
FOR_EACH_OBSERVER(Observer, observers_, WillProcessEvent(event));
}
diff --git a/base/message_pump_glib.h b/base/message_pump_glib.h
index 31d37c0..d8cbbda 100644
--- a/base/message_pump_glib.h
+++ b/base/message_pump_glib.h
@@ -88,6 +88,10 @@ class MessagePumpForUI : public MessagePump {
// some task before/after calling the default handler (EventDispatcher).
virtual void DispatchEvents(GdkEvent* event);
+ protected:
+ // Returns the dispatcher for the current run state (|state_->dispatcher|).
+ Dispatcher* GetDispatcher();
+
private:
// We may make recursive calls to Run, so we save state that needs to be
// separate between them in this structure type.
diff --git a/base/message_pump_glib_x.cc b/base/message_pump_glib_x.cc
index f77f61d..675774e 100644
--- a/base/message_pump_glib_x.cc
+++ b/base/message_pump_glib_x.cc
@@ -7,6 +7,8 @@
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
+#include "base/message_pump_glib_x_dispatch.h"
+
namespace {
gboolean PlaceholderDispatch(GSource* source,
@@ -41,14 +43,16 @@ bool MessagePumpGlibX::RunOnce(GMainContext* context, bool block) {
if (capture_x_events_[xev.type]) {
XNextEvent(display, &xev);
- DLOG(INFO) << "nom noming event";
+ bool processed = static_cast<MessagePumpGlibXDispatcher*>
+ (GetDispatcher())->Dispatch(&xev);
- // TODO(sad): Create a GdkEvent from |xev| and pass it on to
- // EventDispatcherX. The ultimate goal is to create a views::Event from
- // |xev| and send it to a rootview. When done, the preceding DLOG will be
- // removed.
+ if (!processed) {
+ DLOG(WARNING) << "Event (" << xev.type << ") not handled.";
+ }
} else {
- // TODO(sad): A couple of extra events can still sneak in during this
+ // 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.
g_main_context_iteration(context, FALSE);
}
}
@@ -81,6 +85,15 @@ void MessagePumpGlibX::InitializeEventsToCapture(void) {
capture_x_events_[KeyRelease] = true;
capture_gdk_events_[GDK_KEY_RELEASE] = true;
+
+ capture_x_events_[ButtonPress] = true;
+ capture_gdk_events_[GDK_BUTTON_PRESS] = true;
+
+ capture_x_events_[ButtonRelease] = true;
+ capture_gdk_events_[GDK_BUTTON_RELEASE] = true;
+
+ capture_x_events_[MotionNotify] = true;
+ capture_gdk_events_[GDK_MOTION_NOTIFY] = true;
}
void MessagePumpGlibX::EventDispatcherX(GdkEvent* event, gpointer data) {
@@ -94,7 +107,7 @@ void MessagePumpGlibX::EventDispatcherX(GdkEvent* event, gpointer data) {
// TODO(sad): An X event is caught by the GDK handler. Put it back in the
// X queue so that we catch it in the next iteration. When done, the
// following DLOG statement will be removed.
- DLOG(INFO) << "GDK ruined it!!";
+ DLOG(WARNING) << "GDK received an event it shouldn't have";
}
}
diff --git a/base/message_pump_glib_x_dispatch.h b/base/message_pump_glib_x_dispatch.h
new file mode 100644
index 0000000..95364a2
--- /dev/null
+++ b/base/message_pump_glib_x_dispatch.h
@@ -0,0 +1,28 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_MESSAGE_PUMP_GLIB_X_DISPATCH_H
+#define BASE_MESSAGE_PUMP_GLIB_X_DISPATCH_H
+
+#include "base/message_pump.h"
+#include "base/message_pump_glib.h"
+
+typedef union _XEvent XEvent;
+
+namespace base {
+
+// The message pump used for TOUCH_UI on linux is MessagePumpGlibX, which can
+// dispatch both GdkEvents* and XEvents* captured directly from X.
+// MessagePumpForUI::Dispatcher provides the mechanism for dispatching
+// GdkEvents. This class provides additional mechanism for dispatching XEvents.
+class MessagePumpGlibXDispatcher : public MessagePumpForUI::Dispatcher {
+ public:
+ // Dispatches the event. If true is returned processing continues as
+ // normal. If false is returned, the nested loop exits immediately.
+ virtual bool Dispatch(XEvent* xevent) = 0;
+};
+
+} // namespace base
+
+#endif // BASE_MESSAGE_PUMP_GLIB_X_DISPATCH_H