summaryrefslogtreecommitdiffstats
path: root/base/message_pump_gtk.h
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-24 20:10:25 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-24 20:10:25 +0000
commit2047ef4d68229d47cba8bf7f2e0465ab31f8b3ce (patch)
tree86af296c2de9e5ac31c9ed79e21d9d0e4ccda8c4 /base/message_pump_gtk.h
parent86e1db9d9de1ce72ba045bd3755e7a077a1f7fd8 (diff)
downloadchromium_src-2047ef4d68229d47cba8bf7f2e0465ab31f8b3ce.zip
chromium_src-2047ef4d68229d47cba8bf7f2e0465ab31f8b3ce.tar.gz
chromium_src-2047ef4d68229d47cba8bf7f2e0465ab31f8b3ce.tar.bz2
Refactor the glib message-pump, and use it as the base for a gtk message pump and an X message pump.
The changes: * Rename MessagePumpGlibX to MessagePumpX. * Rename MessagePumpForUI to MessagePumpGlib. * Move some stuff out of MessagePumpGlib, and into MessagePumpGtk and MessagePumpX. * Rename MessagePumpForUI::Observer to MessageObserver, moved the platform-specific implementations into MessagePumpGtk and MessagePumpX. Ditto for MessagePumpForUI::Dispatcher. MessagePumpX is independent of MessagePumpGtk. At the moment, MessagePumpX does process some GDK event, but once we have a complete native_widget_x, we can take out the GDK processing and things should continue to work. BUG=none TEST=existing message-pump tests. Review URL: http://codereview.chromium.org/7250001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90418 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_pump_gtk.h')
-rw-r--r--base/message_pump_gtk.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/base/message_pump_gtk.h b/base/message_pump_gtk.h
new file mode 100644
index 0000000..72eaafa
--- /dev/null
+++ b/base/message_pump_gtk.h
@@ -0,0 +1,74 @@
+// 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.
+
+#ifndef BASE_MESSAGE_PUMP_GTK_H_
+#define BASE_MESSAGE_PUMP_GTK_H_
+#pragma once
+
+#include "base/message_pump_glib.h"
+
+typedef union _GdkEvent GdkEvent;
+
+namespace base {
+
+// The documentation for this class is in message_pump_glib.h
+class MessagePumpObserver {
+ public:
+ // This method is called before processing a message.
+ virtual void WillProcessEvent(GdkEvent* event) = 0;
+
+ // This method is called after processing a message.
+ virtual void DidProcessEvent(GdkEvent* event) = 0;
+
+ protected:
+ virtual ~MessagePumpObserver() {}
+};
+
+// The documentation for this class is in message_pump_glib.h
+//
+// The nested loop is exited by either posting a quit, or returning false
+// from Dispatch.
+class MessagePumpDispatcher {
+ public:
+ // Dispatches the event. If true is returned processing continues as
+ // normal. If false is returned, the nested loop exits immediately.
+ virtual bool Dispatch(GdkEvent* event) = 0;
+
+ protected:
+ virtual ~MessagePumpDispatcher() {}
+};
+
+// This class implements a message-pump for dispatching GTK events.
+class MessagePumpGtk : public MessagePumpGlib {
+ public:
+ MessagePumpGtk();
+ virtual ~MessagePumpGtk();
+
+ // Dispatch an available GdkEvent. Essentially this allows a subclass to do
+ // some task before/after calling the default handler (EventDispatcher).
+ void DispatchEvents(GdkEvent* event);
+
+ private:
+ // Overridden from MessagePumpGlib
+ virtual bool RunOnce(GMainContext* context, bool block) OVERRIDE;
+
+ // Invoked from EventDispatcher. Notifies all observers we're about to
+ // process an event.
+ void WillProcessEvent(GdkEvent* event);
+
+ // Invoked from EventDispatcher. Notifies all observers we processed an
+ // event.
+ void DidProcessEvent(GdkEvent* event);
+
+ // Callback prior to gdk dispatching an event.
+ static void EventDispatcher(GdkEvent* event, void* data);
+
+ DISALLOW_COPY_AND_ASSIGN(MessagePumpGtk);
+};
+
+typedef MessagePumpGtk MessagePumpForUI;
+
+} // namespace base
+
+#endif // BASE_MESSAGE_PUMP_GTK_H_