summaryrefslogtreecommitdiffstats
path: root/base/message_pump_glib.cc
diff options
context:
space:
mode:
authorrjkroege@google.com <rjkroege@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-22 16:17:47 +0000
committerrjkroege@google.com <rjkroege@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-22 16:17:47 +0000
commit71ad9c6f69f69396f230e210a16ac5adeb6d180e (patch)
tree2b87b7ecbae601d5cbe03ab3395e557f6e0f7ed8 /base/message_pump_glib.cc
parent4fb42cfd8ddb98e6dad9955c43683cb5558a2a94 (diff)
downloadchromium_src-71ad9c6f69f69396f230e210a16ac5adeb6d180e.zip
chromium_src-71ad9c6f69f69396f230e210a16ac5adeb6d180e.tar.gz
chromium_src-71ad9c6f69f69396f230e210a16ac5adeb6d180e.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. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=63397 Review URL: http://codereview.chromium.org/3748002 Patch from Sadrul Chowdhury <sadrul@chromium.org>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63519 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_pump_glib.cc')
-rw-r--r--base/message_pump_glib.cc30
1 files changed, 18 insertions, 12 deletions
diff --git a/base/message_pump_glib.cc b/base/message_pump_glib.cc
index e85a712..ad6d177 100644
--- a/base/message_pump_glib.cc
+++ b/base/message_pump_glib.cc
@@ -207,8 +207,7 @@ void MessagePumpForUI::RunWithDispatcher(Delegate* delegate,
// Don't block if we think we have more work to do.
bool block = !more_work_is_plausible;
- // g_main_context_iteration returns true if events have been dispatched.
- more_work_is_plausible = g_main_context_iteration(context_, block);
+ more_work_is_plausible = RunOnce(context_, block);
if (state_->should_quit)
break;
@@ -232,6 +231,11 @@ void MessagePumpForUI::RunWithDispatcher(Delegate* delegate,
state_ = previous_state;
}
+bool MessagePumpForUI::RunOnce(GMainContext* context, bool block) {
+ // g_main_context_iteration returns true if events have been dispatched.
+ return g_main_context_iteration(context, block);
+}
+
// Return the timeout we want passed to poll.
int MessagePumpForUI::HandlePrepare() {
// We know we have work, but we haven't called HandleDispatch yet. Don't let
@@ -332,19 +336,21 @@ void MessagePumpForUI::ScheduleDelayedWork(const Time& delayed_work_time) {
ScheduleWork();
}
-// static
-void MessagePumpForUI::EventDispatcher(GdkEvent* event, gpointer data) {
- MessagePumpForUI* message_pump = reinterpret_cast<MessagePumpForUI*>(data);
-
- message_pump->WillProcessEvent(event);
- if (message_pump->state_ && // state_ may be null during tests.
- message_pump->state_->dispatcher) {
- if (!message_pump->state_->dispatcher->Dispatch(event))
- message_pump->state_->should_quit = true;
+void MessagePumpForUI::DispatchEvents(GdkEvent* event) {
+ WillProcessEvent(event);
+ if (state_ && state_->dispatcher) { // state_ may be null during tests.
+ if (!state_->dispatcher->Dispatch(event))
+ state_->should_quit = true;
} else {
gtk_main_do_event(event);
}
- message_pump->DidProcessEvent(event);
+ DidProcessEvent(event);
+}
+
+// static
+void MessagePumpForUI::EventDispatcher(GdkEvent* event, gpointer data) {
+ MessagePumpForUI* message_pump = reinterpret_cast<MessagePumpForUI*>(data);
+ message_pump->DispatchEvents(event);
}
} // namespace base