summaryrefslogtreecommitdiffstats
path: root/base/message_pump_glib_x.h
diff options
context:
space:
mode:
authorrjkroege@google.com <rjkroege@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-21 19:35:50 +0000
committerrjkroege@google.com <rjkroege@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-21 19:35:50 +0000
commit4b170c5fbe7fcf69487424d580ce4dbeb7035a01 (patch)
tree350b297be642f4e0b50a5b1fe05f9c6007f4336e /base/message_pump_glib_x.h
parent923b561488b3b5fd733c703c287c720d3c3f3088 (diff)
downloadchromium_src-4b170c5fbe7fcf69487424d580ce4dbeb7035a01.zip
chromium_src-4b170c5fbe7fcf69487424d580ce4dbeb7035a01.tar.gz
chromium_src-4b170c5fbe7fcf69487424d580ce4dbeb7035a01.tar.bz2
Add a message pump for touchui=1
The message pump reads events directly from X. For most events, it passes them on to GDK for normal processing. It consumes some events (e.g. keypress events) to demonstrate how it's intended to work. This, of course, makes chrome mostly unusable since you can only use the mouse to do things. But this is a small first step towards capturing events through MPX (e.g. touch etc.) and processing them as chrome pleases. glib message pump: Slightly change architecture This changeset breaks down the glib message pump a little so that it can be easily subclassed. The next set of commits will introduce a subclass that still uses GTK and GDK widgets, but reads events directly from X instead of through GTK/GDK. Review URL: http://codereview.chromium.org/3748002 Patch from Sadrul Chowdhury <sadrul@chromium.org>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63397 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_pump_glib_x.h')
-rw-r--r--base/message_pump_glib_x.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/base/message_pump_glib_x.h b/base/message_pump_glib_x.h
new file mode 100644
index 0000000..2f50731
--- /dev/null
+++ b/base/message_pump_glib_x.h
@@ -0,0 +1,63 @@
+// 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_H
+#define BASE_MESSAGE_PUMP_GLIB_X_H
+
+#include "base/message_pump.h"
+#include "base/message_pump_glib.h"
+
+#include <bitset>
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <X11/X.h>
+
+namespace base {
+
+class MessagePumpGlibX : public MessagePumpForUI {
+ public:
+ MessagePumpGlibX();
+ virtual ~MessagePumpGlibX();
+
+ // MessagePumpForUI implementation.
+ virtual bool RunOnce(GMainContext* context, bool block);
+
+ // Indicates whether a GDK event was injected by chrome (when |true|) or if it
+ // was captured and being processed by GDK (when |false|).
+ bool IsDispatchingEvent(void) { return dispatching_event_; }
+
+ private:
+ static void EventDispatcherX(GdkEvent* event, gpointer data);
+
+ // Update the lookup table and flag the events that should be captured and
+ // processed so that GDK doesn't get to them.
+ void InitializeEventsToCapture(void);
+
+ // The event source for GDK events.
+ GSource* gdksource_;
+
+ // Indicates whether a GDK event was injected by chrome (when |true|) or if it
+ // was captured and being processed by GDK (when |false|).
+ bool dispatching_event_;
+
+#if ! GTK_CHECK_VERSION(2,18,0)
+// GDK_EVENT_LAST was introduced in GTK+ 2.18.0. For earlier versions, we pick a
+// large enough value (the value of GDK_EVENT_LAST in 2.18.0) so that it works
+// for all versions.
+#define GDK_EVENT_LAST 37
+#endif
+
+ // We do not want to process all the events ourselves. So we use a lookup
+ // table to quickly check if a particular event should be handled by us or if
+ // it should be passed on to the default GDK handler.
+ std::bitset<LASTEvent> capture_x_events_;
+ std::bitset<GDK_EVENT_LAST> capture_gdk_events_;
+
+ DISALLOW_COPY_AND_ASSIGN(MessagePumpGlibX);
+};
+
+} // namespace base
+
+#endif // BASE_MESSAGE_PUMP_GLIB_X_H