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

Unified Diff: base/message_pump_gtk.cc

Issue 7250001: Refactor the glib message-pump, and use it as the base for a gtk message pump and an X message pump. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: media.gyp update Created 9 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/message_pump_gtk.h ('k') | base/message_pump_x.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_pump_gtk.cc
diff --git a/base/message_pump_gtk.cc b/base/message_pump_gtk.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f5ed0426a0924ea268846d1c1b2730eb6a68c154
--- /dev/null
+++ b/base/message_pump_gtk.cc
@@ -0,0 +1,52 @@
+// Copyright (c) 2011 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.
+
+#include "base/message_pump_gtk.h"
+
+#include <gtk/gtk.h>
+
+namespace base {
+
+MessagePumpGtk::MessagePumpGtk() : MessagePumpGlib() {
+ gdk_event_handler_set(&EventDispatcher, this, NULL);
+}
+
+MessagePumpGtk::~MessagePumpGtk() {
+ gdk_event_handler_set(reinterpret_cast<GdkEventFunc>(gtk_main_do_event),
+ this, NULL);
+}
+
+void MessagePumpGtk::DispatchEvents(GdkEvent* event) {
+ WillProcessEvent(event);
+
+ MessagePumpDispatcher* dispatcher = GetDispatcher();
+ if (!dispatcher)
+ gtk_main_do_event(event);
+ else if (!dispatcher->Dispatch(event))
+ Quit();
+
+ DidProcessEvent(event);
+}
+
+bool MessagePumpGtk::RunOnce(GMainContext* context, bool block) {
+ // g_main_context_iteration returns true if events have been dispatched.
+ return g_main_context_iteration(context, block);
+}
+
+void MessagePumpGtk::WillProcessEvent(GdkEvent* event) {
+ FOR_EACH_OBSERVER(MessagePumpObserver, observers(), WillProcessEvent(event));
+}
+
+void MessagePumpGtk::DidProcessEvent(GdkEvent* event) {
+ FOR_EACH_OBSERVER(MessagePumpObserver, observers(), DidProcessEvent(event));
+}
+
+// static
+void MessagePumpGtk::EventDispatcher(GdkEvent* event, gpointer data) {
+ MessagePumpGtk* message_pump = reinterpret_cast<MessagePumpGtk*>(data);
+ message_pump->DispatchEvents(event);
+}
+
+} // namespace base
+
« no previous file with comments | « base/message_pump_gtk.h ('k') | base/message_pump_x.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698