summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--base/base.gypi15
-rw-r--r--base/message_loop.cc14
-rw-r--r--base/message_loop.h16
-rw-r--r--base/message_pump_glib.cc76
-rw-r--r--base/message_pump_glib.h89
-rw-r--r--base/message_pump_glib_x_dispatch.h46
-rw-r--r--base/message_pump_gtk.cc52
-rw-r--r--base/message_pump_gtk.h74
-rw-r--r--base/message_pump_x.cc (renamed from base/message_pump_glib_x.cc)68
-rw-r--r--base/message_pump_x.h (renamed from base/message_pump_glib_x.h)69
-rw-r--r--chrome/browser/chromeos/system_key_event_listener.cc15
-rw-r--r--chrome/browser/chromeos/system_key_event_listener.h19
-rw-r--r--chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.cc13
-rw-r--r--chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h11
-rw-r--r--chrome/browser/ui/views/tabs/dragged_tab_controller.cc5
-rw-r--r--chrome/browser/ui/views/tabs/dragged_tab_controller.h2
-rw-r--r--media/media.gyp1
-rw-r--r--ui/views/focus/accelerator_handler.h5
-rw-r--r--views/controls/menu/menu_controller.cc22
-rw-r--r--views/controls/menu/menu_controller.h7
-rw-r--r--views/controls/menu/nested_dispatcher_gtk.cc25
-rw-r--r--views/controls/menu/nested_dispatcher_gtk.h9
-rw-r--r--views/focus/accelerator_handler.h7
-rw-r--r--views/focus/accelerator_handler_touch.cc16
-rw-r--r--views/views.gyp3
-rw-r--r--views/widget/native_widget_gtk.cc2
26 files changed, 381 insertions, 300 deletions
diff --git a/base/base.gypi b/base/base.gypi
index dac1bd2..41ea923 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -368,9 +368,15 @@
'sources!': [
'atomicops_internals_x86_gcc.cc',
'message_pump_glib.cc',
- 'message_pump_glib_x.cc',
+ 'message_pump_gtk.cc',
+ 'message_pump_x.cc',
],
}],
+ [ 'touchui==0', {
+ 'sources!' : [ 'message_pump_x.cc', ],
+ }, {
+ 'sources!' : [ 'message_pump_gtk.cc', ],
+ }],
[ 'OS != "linux"', {
'sources!': [
# Not automatically excluded by the *linux.cc rules.
@@ -571,9 +577,10 @@
'md5.h',
'message_pump_glib.cc',
'message_pump_glib.h',
- 'message_pump_glib_x.cc',
- 'message_pump_glib_x.h',
- 'message_pump_glib_x_dispatch.h',
+ 'message_pump_gtk.cc',
+ 'message_pump_gtk.h',
+ 'message_pump_x.cc',
+ 'message_pump_x.h',
'message_pump_libevent.cc',
'message_pump_libevent.h',
'message_pump_mac.h',
diff --git a/base/message_loop.cc b/base/message_loop.cc
index b0526f4..e45c0d7 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -25,14 +25,16 @@
#if defined(OS_POSIX)
#include "base/message_pump_libevent.h"
#endif
+
#if defined(OS_POSIX) && !defined(OS_MACOSX)
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
-#include "base/message_pump_glib.h"
-#endif
#if defined(TOUCH_UI)
-#include "base/message_pump_glib_x.h"
-#endif
+#include "base/message_pump_x.h"
+#else
+#include "base/message_pump_gtk.h"
+#endif // defined(TOUCH_UI)
+#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
using base::TimeDelta;
using base::TimeTicks;
@@ -176,7 +178,7 @@ MessageLoop::MessageLoop(Type type)
#define MESSAGE_PUMP_UI base::MessagePumpMac::Create()
#define MESSAGE_PUMP_IO new base::MessagePumpLibevent()
#elif defined(TOUCH_UI)
-#define MESSAGE_PUMP_UI new base::MessagePumpGlibX()
+#define MESSAGE_PUMP_UI new base::MessagePumpX()
#define MESSAGE_PUMP_IO new base::MessagePumpLibevent()
#elif defined(OS_NACL)
// Currently NaCl doesn't have a UI or an IO MessageLoop.
@@ -184,7 +186,7 @@ MessageLoop::MessageLoop(Type type)
#define MESSAGE_PUMP_UI NULL
#define MESSAGE_PUMP_IO NULL
#elif defined(OS_POSIX) // POSIX but not MACOSX.
-#define MESSAGE_PUMP_UI new base::MessagePumpForUI()
+#define MESSAGE_PUMP_UI new base::MessagePumpGtk()
#define MESSAGE_PUMP_IO new base::MessagePumpLibevent()
#else
#error Not implemented
diff --git a/base/message_loop.h b/base/message_loop.h
index 9a03d6b..8fd9cbc 100644
--- a/base/message_loop.h
+++ b/base/message_loop.h
@@ -27,12 +27,13 @@
#elif defined(OS_POSIX)
#include "base/message_pump_libevent.h"
#if !defined(OS_MACOSX)
-#include "base/message_pump_glib.h"
-typedef struct _XDisplay Display;
+#if defined(TOUCH_UI)
+#include "base/message_pump_x.h"
+#else
+#include "base/message_pump_gtk.h"
#endif
+typedef struct _XDisplay Display;
#endif
-#if defined(TOUCH_UI)
-#include "base/message_pump_glib_x_dispatch.h"
#endif
namespace base {
@@ -80,12 +81,9 @@ class BASE_API MessageLoop : public base::MessagePump::Delegate {
#if defined(OS_WIN)
typedef base::MessagePumpWin::Dispatcher Dispatcher;
typedef base::MessagePumpForUI::Observer Observer;
-#elif defined(TOUCH_UI)
- typedef base::MessagePumpGlibXDispatcher Dispatcher;
- typedef base::MessagePumpXObserver Observer;
#elif !defined(OS_MACOSX)
- typedef base::MessagePumpForUI::Dispatcher Dispatcher;
- typedef base::MessagePumpForUI::Observer Observer;
+ typedef base::MessagePumpDispatcher Dispatcher;
+ typedef base::MessagePumpObserver Observer;
#endif
// A MessageLoop has a particular type, which indicates the set of
diff --git a/base/message_pump_glib.cc b/base/message_pump_glib.cc
index 721fedb6..20fc8ea9 100644
--- a/base/message_pump_glib.cc
+++ b/base/message_pump_glib.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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.
@@ -7,7 +7,6 @@
#include <fcntl.h>
#include <math.h>
-#include <gtk/gtk.h>
#include <glib.h>
#include "base/eintr_wrapper.h"
@@ -85,7 +84,7 @@ int GetTimeIntervalMilliseconds(const base::TimeTicks& from) {
// loop, around event handling.
struct WorkSource : public GSource {
- base::MessagePumpForUI* pump;
+ base::MessagePumpGlib* pump;
};
gboolean WorkSourcePrepare(GSource* source,
@@ -124,9 +123,9 @@ GSourceFuncs WorkSourceFuncs = {
namespace base {
-struct MessagePumpForUI::RunState {
+struct MessagePumpGlib::RunState {
Delegate* delegate;
- Dispatcher* dispatcher;
+ MessagePumpDispatcher* dispatcher;
// Used to flag that the current Run() invocation should return ASAP.
bool should_quit;
@@ -140,7 +139,7 @@ struct MessagePumpForUI::RunState {
bool has_work;
};
-MessagePumpForUI::MessagePumpForUI()
+MessagePumpGlib::MessagePumpGlib()
: state_(NULL),
context_(g_main_context_default()),
wakeup_gpollfd_(new GPollFD) {
@@ -160,26 +159,23 @@ MessagePumpForUI::MessagePumpForUI()
// This is needed to allow Run calls inside Dispatch.
g_source_set_can_recurse(work_source_, TRUE);
g_source_attach(work_source_, context_);
- gdk_event_handler_set(&EventDispatcher, this, NULL);
}
-MessagePumpForUI::~MessagePumpForUI() {
- gdk_event_handler_set(reinterpret_cast<GdkEventFunc>(gtk_main_do_event),
- this, NULL);
+MessagePumpGlib::~MessagePumpGlib() {
g_source_destroy(work_source_);
g_source_unref(work_source_);
close(wakeup_pipe_read_);
close(wakeup_pipe_write_);
}
-void MessagePumpForUI::RunWithDispatcher(Delegate* delegate,
- Dispatcher* dispatcher) {
+void MessagePumpGlib::RunWithDispatcher(Delegate* delegate,
+ MessagePumpDispatcher* dispatcher) {
#ifndef NDEBUG
- // Make sure we only run this on one thread. GTK only has one message pump
+ // Make sure we only run this on one thread. X/GTK only has one message pump
// so we can only have one UI loop per process.
static base::PlatformThreadId thread_id = base::PlatformThread::CurrentId();
DCHECK(thread_id == base::PlatformThread::CurrentId()) <<
- "Running MessagePumpForUI on two different threads; "
+ "Running MessagePumpGlib on two different threads; "
"this is unsupported by GLib!";
#endif
@@ -231,13 +227,8 @@ 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() {
+int MessagePumpGlib::HandlePrepare() {
// We know we have work, but we haven't called HandleDispatch yet. Don't let
// the pump block so that we can do some processing.
if (state_ && // state_ may be null during tests.
@@ -249,7 +240,7 @@ int MessagePumpForUI::HandlePrepare() {
return GetTimeIntervalMilliseconds(delayed_work_time_);
}
-bool MessagePumpForUI::HandleCheck() {
+bool MessagePumpGlib::HandleCheck() {
if (!state_) // state_ may be null during tests.
return false;
@@ -279,11 +270,11 @@ bool MessagePumpForUI::HandleCheck() {
return false;
}
-void MessagePumpForUI::HandleDispatch() {
+void MessagePumpGlib::HandleDispatch() {
state_->has_work = false;
if (state_->delegate->DoWork()) {
// NOTE: on Windows at this point we would call ScheduleWork (see
- // MessagePumpForUI::HandleWorkMessage in message_pump_win.cc). But here,
+ // MessagePumpGlib::HandleWorkMessage in message_pump_win.cc). But here,
// instead of posting a message on the wakeup pipe, we can avoid the
// syscalls and just signal that we have more work.
state_->has_work = true;
@@ -295,30 +286,19 @@ void MessagePumpForUI::HandleDispatch() {
state_->delegate->DoDelayedWork(&delayed_work_time_);
}
-void MessagePumpForUI::AddObserver(Observer* observer) {
+void MessagePumpGlib::AddObserver(MessagePumpObserver* observer) {
observers_.AddObserver(observer);
}
-void MessagePumpForUI::RemoveObserver(Observer* observer) {
+void MessagePumpGlib::RemoveObserver(MessagePumpObserver* observer) {
observers_.RemoveObserver(observer);
}
-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);
- }
- DidProcessEvent(event);
-}
-
-void MessagePumpForUI::Run(Delegate* delegate) {
+void MessagePumpGlib::Run(Delegate* delegate) {
RunWithDispatcher(delegate, NULL);
}
-void MessagePumpForUI::Quit() {
+void MessagePumpGlib::Quit() {
if (state_) {
state_->should_quit = true;
} else {
@@ -326,7 +306,7 @@ void MessagePumpForUI::Quit() {
}
}
-void MessagePumpForUI::ScheduleWork() {
+void MessagePumpGlib::ScheduleWork() {
// This can be called on any thread, so we don't want to touch any state
// variables as we would then need locks all over. This ensures that if
// we are sleeping in a poll that we will wake up.
@@ -336,29 +316,15 @@ void MessagePumpForUI::ScheduleWork() {
}
}
-void MessagePumpForUI::ScheduleDelayedWork(const TimeTicks& delayed_work_time) {
+void MessagePumpGlib::ScheduleDelayedWork(const TimeTicks& delayed_work_time) {
// We need to wake up the loop in case the poll timeout needs to be
// adjusted. This will cause us to try to do work, but that's ok.
delayed_work_time_ = delayed_work_time;
ScheduleWork();
}
-MessagePumpForUI::Dispatcher* MessagePumpForUI::GetDispatcher() {
+MessagePumpDispatcher* MessagePumpGlib::GetDispatcher() {
return state_ ? state_->dispatcher : NULL;
}
-void MessagePumpForUI::WillProcessEvent(GdkEvent* event) {
- FOR_EACH_OBSERVER(Observer, observers_, WillProcessEvent(event));
-}
-
-void MessagePumpForUI::DidProcessEvent(GdkEvent* event) {
- FOR_EACH_OBSERVER(Observer, observers_, DidProcessEvent(event));
-}
-
-// static
-void MessagePumpForUI::EventDispatcher(GdkEvent* event, gpointer data) {
- MessagePumpForUI* message_pump = reinterpret_cast<MessagePumpForUI*>(data);
- message_pump->DispatchEvents(event);
-}
-
} // namespace base
diff --git a/base/message_pump_glib.h b/base/message_pump_glib.h
index 32d0d8f..36d75cd 100644
--- a/base/message_pump_glib.h
+++ b/base/message_pump_glib.h
@@ -11,56 +11,40 @@
#include "base/observer_list.h"
#include "base/time.h"
-typedef union _GdkEvent GdkEvent;
typedef struct _GMainContext GMainContext;
typedef struct _GPollFD GPollFD;
typedef struct _GSource GSource;
namespace base {
-// This class implements a MessagePump needed for TYPE_UI MessageLoops on
-// OS_LINUX platforms using GLib.
-class MessagePumpForUI : public MessagePump {
+// MessagePumpObserver is notified prior to an event being dispatched. As
+// Observers are notified of every change, they have to be FAST! The platform
+// specific implementation of the class is in message_pump_gtk/message_pump_x.
+class MessagePumpObserver;
+
+// MessagePumpDispatcher is used during a nested invocation of Run to dispatch
+// events. If Run is invoked with a non-NULL MessagePumpDispatcher, MessageLoop
+// does not dispatch events (or invoke gtk_main_do_event), rather every event is
+// passed to Dispatcher's Dispatch method for dispatch. It is up to the
+// Dispatcher to dispatch, or not, the event. The platform specific
+// implementation of the class is in message_pump_gtk/message_pump_x.
+class MessagePumpDispatcher;
+
+// This class implements a base MessagePump needed for TYPE_UI MessageLoops on
+// platforms using GLib.
+class MessagePumpGlib : public MessagePump {
public:
- // Observer is notified prior to a GdkEvent event being dispatched. As
- // Observers are notified of every change, they have to be FAST!
- class Observer {
- public:
- virtual ~Observer() {}
-
- // 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;
- };
-
- // Dispatcher is used during a nested invocation of Run to dispatch events.
- // If Run is invoked with a non-NULL Dispatcher, MessageLoop does not
- // dispatch events (or invoke gtk_main_do_event), rather every event is
- // passed to Dispatcher's Dispatch method for dispatch. It is up to the
- // Dispatcher to dispatch, or not, the event.
- //
- // The nested loop is exited by either posting a quit, or returning false
- // from Dispatch.
- class Dispatcher {
- public:
- virtual ~Dispatcher() {}
- // 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;
- };
-
- MessagePumpForUI();
- virtual ~MessagePumpForUI();
-
- // Like MessagePump::Run, but GdkEvent objects are routed through dispatcher.
- virtual void RunWithDispatcher(Delegate* delegate, Dispatcher* dispatcher);
+ MessagePumpGlib();
+ virtual ~MessagePumpGlib();
+
+ // Like MessagePump::Run, but events are routed through dispatcher.
+ virtual void RunWithDispatcher(Delegate* delegate,
+ MessagePumpDispatcher* dispatcher);
// Run a single iteration of the mainloop. A return value of true indicates
// that an event was handled. |block| indicates if it should wait if no event
// is ready for processing.
- virtual bool RunOnce(GMainContext* context, bool block);
+ virtual bool RunOnce(GMainContext* context, bool block) = 0;
// Internal methods used for processing the pump callbacks. They are
// public for simplicity but should not be used directly. HandlePrepare
@@ -73,15 +57,11 @@ class MessagePumpForUI : public MessagePump {
void HandleDispatch();
// Adds an Observer, which will start receiving notifications immediately.
- void AddObserver(Observer* observer);
+ void AddObserver(MessagePumpObserver* observer);
// Removes an Observer. It is safe to call this method while an Observer is
// receiving a notification callback.
- void RemoveObserver(Observer* observer);
-
- // Dispatch an available GdkEvent. Essentially this allows a subclass to do
- // some task before/after calling the default handler (EventDispatcher).
- virtual void DispatchEvents(GdkEvent* event);
+ void RemoveObserver(MessagePumpObserver* observer);
// Overridden from MessagePump:
virtual void Run(Delegate* delegate);
@@ -91,26 +71,15 @@ class MessagePumpForUI : public MessagePump {
protected:
// Returns the dispatcher for the current run state (|state_->dispatcher|).
- Dispatcher* GetDispatcher();
+ MessagePumpDispatcher* GetDispatcher();
- ObserverList<Observer>& observers() { return observers_; }
+ ObserverList<MessagePumpObserver>& observers() { return observers_; }
private:
// We may make recursive calls to Run, so we save state that needs to be
// separate between them in this structure type.
struct RunState;
- // 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);
-
RunState* state_;
// This is a GLib structure that we can add event sources to. We use the
@@ -135,9 +104,9 @@ class MessagePumpForUI : public MessagePump {
scoped_ptr<GPollFD> wakeup_gpollfd_;
// List of observers.
- ObserverList<Observer> observers_;
+ ObserverList<MessagePumpObserver> observers_;
- DISALLOW_COPY_AND_ASSIGN(MessagePumpForUI);
+ DISALLOW_COPY_AND_ASSIGN(MessagePumpGlib);
};
} // namespace base
diff --git a/base/message_pump_glib_x_dispatch.h b/base/message_pump_glib_x_dispatch.h
deleted file mode 100644
index 9a2358a..0000000
--- a/base/message_pump_glib_x_dispatch.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// 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_GLIB_X_DISPATCH_H
-#define BASE_MESSAGE_PUMP_GLIB_X_DISPATCH_H
-
-#include "base/base_api.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:
- enum DispatchStatus {
- EVENT_IGNORED, // The event was not processed.
- EVENT_PROCESSED, // The event has been processed.
- EVENT_QUIT // The event was processed and the message-loop should
- // terminate.
- };
-
- // Dispatches the event. EVENT_IGNORED is returned if the event was ignored
- // (i.e. not processed). EVENT_PROCESSED is returned if the event was
- // processed. The nested loop exits immediately if EVENT_QUIT is returned.
- virtual DispatchStatus DispatchX(XEvent* xevent) = 0;
-};
-
-class BASE_API MessagePumpXObserver : public MessagePumpForUI::Observer {
- public:
- // This method is called before processing an XEvent. If the method returns
- // true, it indicates the event has already been handled, so the event is not
- // processed any farther. If the method returns false, the event dispatching
- // proceeds as normal.
- virtual bool WillProcessXEvent(XEvent* xevent);
-};
-
-} // namespace base
-
-#endif // BASE_MESSAGE_PUMP_GLIB_X_DISPATCH_H
diff --git a/base/message_pump_gtk.cc b/base/message_pump_gtk.cc
new file mode 100644
index 0000000..f5ed042
--- /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
+
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_
diff --git a/base/message_pump_glib_x.cc b/base/message_pump_x.cc
index 430d937..a50e182 100644
--- a/base/message_pump_glib_x.cc
+++ b/base/message_pump_x.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/message_pump_glib_x.h"
+#include "base/message_pump_x.h"
#include <gdk/gdkx.h>
#if defined(HAVE_XINPUT2)
@@ -11,7 +11,7 @@
#include <X11/Xlib.h>
#endif
-#include "base/message_pump_glib_x_dispatch.h"
+#include "base/basictypes.h"
namespace {
@@ -25,7 +25,7 @@ gboolean PlaceholderDispatch(GSource* source,
namespace base {
-MessagePumpGlibX::MessagePumpGlibX() : base::MessagePumpForUI(),
+MessagePumpX::MessagePumpX() : MessagePumpGlib(),
#if defined(HAVE_XINPUT2)
xiopcode_(-1),
#endif
@@ -42,15 +42,13 @@ MessagePumpGlibX::MessagePumpGlibX() : base::MessagePumpForUI(),
InitializeEventsToCapture();
}
-MessagePumpGlibX::~MessagePumpGlibX() {
+MessagePumpX::~MessagePumpX() {
gdk_window_remove_filter(NULL, &GdkEventFilter, this);
-
- // It is not necessary to reset the GDK event handler using
- // gdk_event_handler_set since it's done in the destructor for
- // MessagePumpForUI.
+ gdk_event_handler_set(reinterpret_cast<GdkEventFunc>(gtk_main_do_event),
+ this, NULL);
}
-bool MessagePumpGlibX::ShouldCaptureXEvent(XEvent* xev) {
+bool MessagePumpX::ShouldCaptureXEvent(XEvent* xev) {
return capture_x_events_[xev->type]
#if defined(HAVE_XINPUT2)
&& (xev->type != GenericEvent || xev->xcookie.extension == xiopcode_)
@@ -59,7 +57,7 @@ bool MessagePumpGlibX::ShouldCaptureXEvent(XEvent* xev) {
}
-bool MessagePumpGlibX::ProcessXEvent(XEvent* xev) {
+bool MessagePumpX::ProcessXEvent(XEvent* xev) {
bool should_quit = false;
#if defined(HAVE_XINPUT2)
@@ -70,15 +68,14 @@ bool MessagePumpGlibX::ProcessXEvent(XEvent* xev) {
}
#endif
- if (!WillProcessXEvent(xev)) {
- MessagePumpGlibXDispatcher::DispatchStatus status =
- static_cast<MessagePumpGlibXDispatcher*>
- (GetDispatcher())->DispatchX(xev);
+ if (WillProcessXEvent(xev) == MessagePumpObserver::EVENT_CONTINUE) {
+ MessagePumpDispatcher::DispatchStatus status =
+ GetDispatcher()->Dispatch(xev);
- if (status == MessagePumpGlibXDispatcher::EVENT_QUIT) {
+ if (status == MessagePumpDispatcher::EVENT_QUIT) {
should_quit = true;
Quit();
- } else if (status == MessagePumpGlibXDispatcher::EVENT_IGNORED) {
+ } else if (status == MessagePumpDispatcher::EVENT_IGNORED) {
VLOG(1) << "Event (" << xev->type << ") not handled.";
}
}
@@ -92,10 +89,10 @@ bool MessagePumpGlibX::ProcessXEvent(XEvent* xev) {
return should_quit;
}
-bool MessagePumpGlibX::RunOnce(GMainContext* context, bool block) {
+bool MessagePumpX::RunOnce(GMainContext* context, bool block) {
GdkDisplay* gdisp = gdk_display_get_default();
if (!gdisp || !GetDispatcher())
- return MessagePumpForUI::RunOnce(context, block);
+ return g_main_context_iteration(context, block);
Display* display = GDK_DISPLAY_XDISPLAY(gdisp);
@@ -137,10 +134,10 @@ bool MessagePumpGlibX::RunOnce(GMainContext* context, bool block) {
return retvalue;
}
-GdkFilterReturn MessagePumpGlibX::GdkEventFilter(GdkXEvent* gxevent,
- GdkEvent* gevent,
- gpointer data) {
- MessagePumpGlibX* pump = static_cast<MessagePumpGlibX*>(data);
+GdkFilterReturn MessagePumpX::GdkEventFilter(GdkXEvent* gxevent,
+ GdkEvent* gevent,
+ gpointer data) {
+ MessagePumpX* pump = static_cast<MessagePumpX*>(data);
XEvent* xev = static_cast<XEvent*>(gxevent);
if (pump->ShouldCaptureXEvent(xev) && pump->GetDispatcher()) {
@@ -151,20 +148,18 @@ GdkFilterReturn MessagePumpGlibX::GdkEventFilter(GdkXEvent* gxevent,
return GDK_FILTER_CONTINUE;
}
-bool MessagePumpGlibX::WillProcessXEvent(XEvent* xevent) {
- ObserverListBase<Observer>::Iterator it(observers());
- Observer* obs;
+bool MessagePumpX::WillProcessXEvent(XEvent* xevent) {
+ ObserverListBase<MessagePumpObserver>::Iterator it(observers());
+ MessagePumpObserver* obs;
while ((obs = it.GetNext()) != NULL) {
- MessagePumpXObserver* xobs =
- static_cast<MessagePumpXObserver*>(obs);
- if (xobs->WillProcessXEvent(xevent))
+ if (obs->WillProcessXEvent(xevent))
return true;
}
return false;
}
-void MessagePumpGlibX::EventDispatcherX(GdkEvent* event, gpointer data) {
- MessagePumpGlibX* pump_x = reinterpret_cast<MessagePumpGlibX*>(data);
+void MessagePumpX::EventDispatcherX(GdkEvent* event, gpointer data) {
+ MessagePumpX* pump_x = reinterpret_cast<MessagePumpX*>(data);
if (!pump_x->gdksource_) {
pump_x->gdksource_ = g_main_current_source();
@@ -177,10 +172,10 @@ void MessagePumpGlibX::EventDispatcherX(GdkEvent* event, gpointer data) {
}
}
- pump_x->DispatchEvents(event);
+ gtk_main_do_event(event);
}
-void MessagePumpGlibX::InitializeEventsToCapture(void) {
+void MessagePumpX::InitializeEventsToCapture(void) {
// TODO(sad): Decide which events we want to capture and update the tables
// accordingly.
capture_x_events_[KeyPress] = true;
@@ -204,7 +199,7 @@ void MessagePumpGlibX::InitializeEventsToCapture(void) {
}
#if defined(HAVE_XINPUT2)
-void MessagePumpGlibX::InitializeXInput2(void) {
+void MessagePumpX::InitializeXInput2(void) {
GdkDisplay* display = gdk_display_get_default();
if (!display)
return;
@@ -227,8 +222,11 @@ void MessagePumpGlibX::InitializeXInput2(void) {
}
#endif // HAVE_XINPUT2
-bool MessagePumpXObserver::WillProcessXEvent(XEvent* xev) {
- return false;
+MessagePumpObserver::EventStatus
+ MessagePumpObserver::WillProcessXEvent(XEvent* xev) {
+ return EVENT_CONTINUE;
}
+COMPILE_ASSERT(XLASTEvent >= LASTEvent, XLASTEvent_too_small);
+
} // namespace base
diff --git a/base/message_pump_glib_x.h b/base/message_pump_x.h
index ed29e6a..f7f271c 100644
--- a/base/message_pump_glib_x.h
+++ b/base/message_pump_x.h
@@ -2,8 +2,8 @@
// 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
+#ifndef BASE_MESSAGE_PUMP_X_H
+#define BASE_MESSAGE_PUMP_X_H
#include "base/message_pump.h"
#include "base/message_pump_glib.h"
@@ -12,23 +12,63 @@
#include <glib.h>
#include <gtk/gtk.h>
-#include <X11/X.h>
typedef union _XEvent XEvent;
namespace base {
-class MessagePumpGlibX : public MessagePumpForUI {
+// The documentation for this class is in message_pump_glib.h
+class BASE_API MessagePumpObserver {
public:
- MessagePumpGlibX();
- virtual ~MessagePumpGlibX();
+ enum EventStatus {
+ EVENT_CONTINUE, // The event should be dispatched as normal.
+ EVENT_HANDLED // The event should not be processed any farther.
+ };
+
+ // This method is called before processing an XEvent. If the method returns
+ // EVENT_HANDLED, it indicates the event has already been handled, so the
+ // event is not processed any farther. If the method returns EVENT_CONTINUE,
+ // the event dispatching proceeds as normal.
+ virtual EventStatus WillProcessXEvent(XEvent* xevent);
+
+ 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 EVENT_QUIT
+// from Dispatch.
+class MessagePumpDispatcher {
+ public:
+ enum DispatchStatus {
+ EVENT_IGNORED, // The event was not processed.
+ EVENT_PROCESSED, // The event has been processed.
+ EVENT_QUIT // The event was processed and the message-loop should
+ // terminate.
+ };
+
+ // Dispatches the event. EVENT_IGNORED is returned if the event was ignored
+ // (i.e. not processed). EVENT_PROCESSED is returned if the event was
+ // processed. The nested loop exits immediately if EVENT_QUIT is returned.
+ virtual DispatchStatus Dispatch(XEvent* xevent) = 0;
+
+ protected:
+ virtual ~MessagePumpDispatcher() {}
+};
+
+// This class implements a message-pump for dispatching X events.
+class MessagePumpX : public MessagePumpGlib {
+ public:
+ MessagePumpX();
+ virtual ~MessagePumpX();
// 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_; }
- // Overridden from MessagePumpForUI:
- virtual bool RunOnce(GMainContext* context, bool block);
+ // Overridden from MessagePumpGlib:
+ virtual bool RunOnce(GMainContext* context, bool block) OVERRIDE;
private:
// Some XEvent's can't be directly read from X event queue and will go
@@ -83,15 +123,22 @@ class MessagePumpGlibX : public MessagePumpForUI {
#define GDK_EVENT_LAST 37
#endif
+// Ideally we would #include X.h for LASTEvent, but it brings in a lot of stupid
+// stuff (like Time, CurrentTime etc.) that messes up a lot of things. So define
+// XLASTEvent here to a large enough value so that it works.
+#define XLASTEvent 40
+
// 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<XLASTEvent> capture_x_events_;
std::bitset<GDK_EVENT_LAST> capture_gdk_events_;
- DISALLOW_COPY_AND_ASSIGN(MessagePumpGlibX);
+ DISALLOW_COPY_AND_ASSIGN(MessagePumpX);
};
+typedef MessagePumpX MessagePumpForUI;
+
} // namespace base
-#endif // BASE_MESSAGE_PUMP_GLIB_X_H
+#endif // BASE_MESSAGE_PUMP_X_H
diff --git a/chrome/browser/chromeos/system_key_event_listener.cc b/chrome/browser/chromeos/system_key_event_listener.cc
index 00991b8..af70d12 100644
--- a/chrome/browser/chromeos/system_key_event_listener.cc
+++ b/chrome/browser/chromeos/system_key_event_listener.cc
@@ -14,7 +14,7 @@
#include "third_party/cros/chromeos_wm_ipc_enums.h"
#if defined(TOUCH_UI)
-#include "base/message_pump_glib_x_dispatch.h"
+#include "base/message_pump_x.h"
#endif
namespace chromeos {
@@ -99,6 +99,12 @@ void SystemKeyEventListener::ProcessWmMessage(const WmIpc::Message& message,
}
}
+#if defined(TOUCH_UI)
+base::MessagePumpObserver::EventStatus
+ SystemKeyEventListener::WillProcessXEvent(XEvent* xevent) {
+ return ProcessedXEvent(xevent) ? EVENT_HANDLED : EVENT_CONTINUE;
+}
+#else // defined(TOUCH_UI)
// static
GdkFilterReturn SystemKeyEventListener::GdkEventFilter(GdkXEvent* gxevent,
GdkEvent* gevent,
@@ -106,9 +112,10 @@ GdkFilterReturn SystemKeyEventListener::GdkEventFilter(GdkXEvent* gxevent,
SystemKeyEventListener* listener = static_cast<SystemKeyEventListener*>(data);
XEvent* xevent = static_cast<XEvent*>(gxevent);
- return listener->WillProcessXEvent(xevent) ? GDK_FILTER_REMOVE
- : GDK_FILTER_CONTINUE;
+ return listener->ProcessedXEvent(xevent) ? GDK_FILTER_REMOVE
+ : GDK_FILTER_CONTINUE;
}
+#endif // defined(TOUCH_UI)
void SystemKeyEventListener::GrabKey(int32 key, uint32 mask) {
uint32 num_lock_mask = Mod2Mask;
@@ -160,7 +167,7 @@ void SystemKeyEventListener::OnVolumeUp() {
BrightnessBubble::GetInstance()->HideBubble();
}
-bool SystemKeyEventListener::WillProcessXEvent(XEvent* xevent) {
+bool SystemKeyEventListener::ProcessedXEvent(XEvent* xevent) {
if (xevent->type == KeyPress) {
int32 keycode = xevent->xkey.keycode;
if (keycode) {
diff --git a/chrome/browser/chromeos/system_key_event_listener.h b/chrome/browser/chromeos/system_key_event_listener.h
index 7ba32d5..51e668d 100644
--- a/chrome/browser/chromeos/system_key_event_listener.h
+++ b/chrome/browser/chromeos/system_key_event_listener.h
@@ -44,6 +44,10 @@ class SystemKeyEventListener : public WmMessageListener::Observer,
SystemKeyEventListener();
virtual ~SystemKeyEventListener();
+#if defined(TOUCH_UI)
+ // MessageLoopForUI::Observer overrides.
+ virtual EventStatus WillProcessXEvent(XEvent* xevent) OVERRIDE;
+#else
// This event filter intercepts events before they reach GDK, allowing us to
// check for system level keyboard events regardless of which window has
// focus.
@@ -51,6 +55,11 @@ class SystemKeyEventListener : public WmMessageListener::Observer,
GdkEvent* gevent,
gpointer data);
+ // MessageLoopForUI::Observer overrides.
+ virtual void WillProcessEvent(GdkEvent* event) OVERRIDE {}
+ virtual void DidProcessEvent(GdkEvent* event) OVERRIDE {}
+#endif
+
// Tell X we are interested in the specified key/mask combination.
// Capslock and Numlock are always ignored.
void GrabKey(int32 key, uint32 mask);
@@ -59,14 +68,8 @@ class SystemKeyEventListener : public WmMessageListener::Observer,
void OnVolumeDown();
void OnVolumeUp();
- // MessageLoopForUI::Observer overrides.
- virtual void WillProcessEvent(GdkEvent* event) OVERRIDE {}
- virtual void DidProcessEvent(GdkEvent* event) OVERRIDE {}
- virtual bool WillProcessXEvent(XEvent* xevent)
-#if defined(TOUCH_UI)
- OVERRIDE
-#endif
- ;
+ // Returns true if the event was processed, false otherwise.
+ virtual bool ProcessedXEvent(XEvent* xevent);
int32 key_volume_mute_;
int32 key_volume_down_;
diff --git a/chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.cc b/chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.cc
index d5968b4..22b89fe 100644
--- a/chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.cc
+++ b/chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.cc
@@ -96,6 +96,12 @@ void XInputHierarchyChangedEventListener::Stop() {
xiopcode_ = -1;
}
+#if defined(TOUCH_UI)
+base::MessagePumpObserver::EventStatus
+ XInputHierarchyChangedEventListener::WillProcessXEvent(XEvent* xevent) {
+ return ProcessedXEvent(xevent) ? EVENT_HANDLED : EVENT_CONTINUE;
+}
+#else // defined(TOUCH_UI)
// static
GdkFilterReturn XInputHierarchyChangedEventListener::GdkEventFilter(
GdkXEvent* gxevent, GdkEvent* gevent, gpointer data) {
@@ -103,11 +109,12 @@ GdkFilterReturn XInputHierarchyChangedEventListener::GdkEventFilter(
static_cast<XInputHierarchyChangedEventListener*>(data);
XEvent* xevent = static_cast<XEvent*>(gxevent);
- return listener->WillProcessXEvent(xevent) ? GDK_FILTER_REMOVE
- : GDK_FILTER_CONTINUE;
+ return listener->ProcessedXEvent(xevent) ? GDK_FILTER_REMOVE
+ : GDK_FILTER_CONTINUE;
}
+#endif // defined(TOUCH_UI)
-bool XInputHierarchyChangedEventListener::WillProcessXEvent(XEvent* xevent) {
+bool XInputHierarchyChangedEventListener::ProcessedXEvent(XEvent* xevent) {
if ((xevent->xcookie.type != GenericEvent) ||
(xevent->xcookie.extension != xiopcode_)) {
return false;
diff --git a/chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h b/chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h
index 7c37ac3..0cb4fad 100644
--- a/chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h
+++ b/chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h
@@ -36,6 +36,10 @@ class XInputHierarchyChangedEventListener : public MessageLoopForUI::Observer {
XInputHierarchyChangedEventListener();
virtual ~XInputHierarchyChangedEventListener();
+#if defined(TOUCH_UI)
+ // MessageLoopForUI::Observer overrides.
+ virtual EventStatus WillProcessXEvent(XEvent* xevent) OVERRIDE;
+#else
// When TOUCH_UI is not defined, WillProcessXEvent() will not be called
// automatically. We have to call the function manually by adding the Gdk
// event filter.
@@ -46,11 +50,10 @@ class XInputHierarchyChangedEventListener : public MessageLoopForUI::Observer {
// MessageLoopForUI::Observer overrides.
virtual void WillProcessEvent(GdkEvent* event) OVERRIDE {}
virtual void DidProcessEvent(GdkEvent* event) OVERRIDE {}
- virtual bool WillProcessXEvent(XEvent* xevent)
-#if defined(TOUCH_UI)
- OVERRIDE
#endif
- ;
+
+ // Returns true if the event was processed, false otherwise.
+ virtual bool ProcessedXEvent(XEvent* xevent);
bool stopped_;
int xiopcode_;
diff --git a/chrome/browser/ui/views/tabs/dragged_tab_controller.cc b/chrome/browser/ui/views/tabs/dragged_tab_controller.cc
index 298b2fc..31d6ec9 100644
--- a/chrome/browser/ui/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/ui/views/tabs/dragged_tab_controller.cc
@@ -531,6 +531,11 @@ void DraggedTabController::DidProcessMessage(const MSG& msg) {
if (msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE)
EndDrag(true);
}
+#elif defined(TOUCH_UI)
+base::MessagePumpObserver::EventStatus
+ DraggedTabController::WillProcessXEvent(XEvent* xevent) {
+ return EVENT_CONTINUE;
+}
#elif defined(TOOLKIT_USES_GTK)
void DraggedTabController::WillProcessEvent(GdkEvent* event) {
}
diff --git a/chrome/browser/ui/views/tabs/dragged_tab_controller.h b/chrome/browser/ui/views/tabs/dragged_tab_controller.h
index 9023a2b..c2d8bda 100644
--- a/chrome/browser/ui/views/tabs/dragged_tab_controller.h
+++ b/chrome/browser/ui/views/tabs/dragged_tab_controller.h
@@ -160,6 +160,8 @@ class DraggedTabController : public TabContentsDelegate,
#if defined(OS_WIN)
virtual void WillProcessMessage(const MSG& msg) OVERRIDE;
virtual void DidProcessMessage(const MSG& msg) OVERRIDE;
+#elif defined(TOUCH_UI)
+ virtual EventStatus WillProcessXEvent(XEvent* xevent) OVERRIDE;
#elif defined(TOOLKIT_USES_GTK)
virtual void WillProcessEvent(GdkEvent* event) OVERRIDE;
virtual void DidProcessEvent(GdkEvent* event) OVERRIDE;
diff --git a/media/media.gyp b/media/media.gyp
index 87f9077..1bac8c0 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -675,6 +675,7 @@
'type': 'executable',
'dependencies': [
'media',
+ '../base/base.gyp:base',
'../third_party/ffmpeg/ffmpeg.gyp:ffmpeg',
'../third_party/openmax/openmax.gyp:il',
],
diff --git a/ui/views/focus/accelerator_handler.h b/ui/views/focus/accelerator_handler.h
index c241d0e..9887eb6 100644
--- a/ui/views/focus/accelerator_handler.h
+++ b/ui/views/focus/accelerator_handler.h
@@ -50,11 +50,10 @@ class AcceleratorHandler : public MessageLoopForUI::Dispatcher {
// focus manager
#if defined(OS_WIN)
virtual bool Dispatch(const MSG& msg);
+#elif defined(TOUCH_UI)
+ virtual MesasgePumpDispatcher::DispatchStatus Dispatch(XEvent* xev);
#else
virtual bool Dispatch(GdkEvent* event);
-#if defined(TOUCH_UI)
- virtual MessagePumpGlibXDispatcher::DispatchStatus Dispatch(XEvent* xev);
-#endif
#endif
private:
diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc
index c1e8d2a..84544f1 100644
--- a/views/controls/menu/menu_controller.cc
+++ b/views/controls/menu/menu_controller.cc
@@ -858,7 +858,16 @@ bool MenuController::Dispatch(const MSG& msg) {
DispatchMessage(&msg);
return exit_type_ == EXIT_NONE;
}
+#elif defined(TOUCH_UI)
+base::MessagePumpDispatcher::DispatchStatus
+ MenuController::Dispatch(XEvent* xev) {
+ if (!DispatchXEvent(xev))
+ return EVENT_IGNORED;
+ return exit_type_ != EXIT_NONE ?
+ base::MessagePumpDispatcher::EVENT_QUIT :
+ base::MessagePumpDispatcher::EVENT_PROCESSED;
+}
#else
bool MenuController::Dispatch(GdkEvent* event) {
if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) {
@@ -897,19 +906,6 @@ bool MenuController::Dispatch(GdkEvent* event) {
gtk_main_do_event(event);
return exit_type_ == EXIT_NONE;
}
-
-#if defined(TOUCH_UI)
-base::MessagePumpGlibXDispatcher::DispatchStatus
- MenuController::DispatchX(XEvent* xev) {
- if (!DispatchXEvent(xev))
- return EVENT_IGNORED;
-
- return exit_type_ != EXIT_NONE ?
- base::MessagePumpGlibXDispatcher::EVENT_QUIT :
- base::MessagePumpGlibXDispatcher::EVENT_PROCESSED;
-}
-#endif
-
#endif
bool MenuController::OnKeyDown(int key_code
diff --git a/views/controls/menu/menu_controller.h b/views/controls/menu/menu_controller.h
index cc89808..7721a6e 100644
--- a/views/controls/menu/menu_controller.h
+++ b/views/controls/menu/menu_controller.h
@@ -207,15 +207,12 @@ class MenuController : public MessageLoopForUI::Dispatcher {
// Dispatcher method. This returns true if the menu was canceled, or
// if the message is such that the menu should be closed.
virtual bool Dispatch(const MSG& msg);
-
+#elif defined(TOUCH_UI)
+ virtual base::MessagePumpDispatcher::DispatchStatus Dispatch(XEvent* xevent);
#else
virtual bool Dispatch(GdkEvent* event);
#endif
-#if defined(TOUCH_UI)
- virtual MessagePumpGlibXDispatcher::DispatchStatus DispatchX(XEvent* xevent);
-#endif
-
// Key processing. The return value of this is returned from Dispatch.
// In other words, if this returns false (which happens if escape was
// pressed, or a matching mnemonic was found) the message loop returns.
diff --git a/views/controls/menu/nested_dispatcher_gtk.cc b/views/controls/menu/nested_dispatcher_gtk.cc
index 9cdc1a6..383447c 100644
--- a/views/controls/menu/nested_dispatcher_gtk.cc
+++ b/views/controls/menu/nested_dispatcher_gtk.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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.
@@ -32,24 +32,15 @@ void NestedDispatcherGtk::CreatorDestroyed() {
creator_ = NULL;
}
-bool NestedDispatcherGtk::Dispatch(GdkEvent* event) {
- if (creator_ != NULL) {
#if defined(TOUCH_UI)
- return static_cast<base::MessagePumpForUI::Dispatcher*>
- (creator_)->Dispatch(event);
-#else
- return creator_->Dispatch(event);
-#endif
- } else {
- return false;
- }
+base::MessagePumpDispatcher::DispatchStatus
+ NestedDispatcherGtk::Dispatch(XEvent* xevent) {
+ return creator_->Dispatch(xevent);
}
-
-#if defined(TOUCH_UI)
-base::MessagePumpGlibXDispatcher::DispatchStatus
- NestedDispatcherGtk::DispatchX(XEvent* xevent) {
- return creator_->DispatchX(xevent);
+#else
+bool NestedDispatcherGtk::Dispatch(GdkEvent* event) {
+ return creator_ && creator_->Dispatch(event);
}
-#endif
+#endif // defined(TOUCH_UI)
} // namespace views
diff --git a/views/controls/menu/nested_dispatcher_gtk.h b/views/controls/menu/nested_dispatcher_gtk.h
index 342ea26..0520b4d 100644
--- a/views/controls/menu/nested_dispatcher_gtk.h
+++ b/views/controls/menu/nested_dispatcher_gtk.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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.
@@ -37,12 +37,11 @@ class NestedDispatcherGtk : public MessageLoopForUI::Dispatcher {
private:
virtual ~NestedDispatcherGtk() {}
+#if defined(TOUCH_UI)
+ virtual base::MessagePumpDispatcher::DispatchStatus Dispatch(XEvent* xevent);
+#else
// Overriden from MessageLoopForUI::Dispatcher:
virtual bool Dispatch(GdkEvent* event);
-
-#if defined(TOUCH_UI)
- virtual base::MessagePumpGlibXDispatcher::DispatchStatus
- DispatchX(XEvent* xevent);
#endif
// Creator of the nested loop.
diff --git a/views/focus/accelerator_handler.h b/views/focus/accelerator_handler.h
index b10b587..44b411f 100644
--- a/views/focus/accelerator_handler.h
+++ b/views/focus/accelerator_handler.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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.
@@ -41,11 +41,10 @@ class AcceleratorHandler : public MessageLoopForUI::Dispatcher {
// focus manager
#if defined(OS_WIN)
virtual bool Dispatch(const MSG& msg);
+#elif defined(TOUCH_UI)
+ virtual base::MessagePumpDispatcher::DispatchStatus Dispatch(XEvent* xev);
#else
virtual bool Dispatch(GdkEvent* event);
-#if defined(TOUCH_UI)
- virtual MessagePumpGlibXDispatcher::DispatchStatus DispatchX(XEvent* xev);
-#endif
#endif
private:
diff --git a/views/focus/accelerator_handler_touch.cc b/views/focus/accelerator_handler_touch.cc
index 3ffbd6a..f5ccd31 100644
--- a/views/focus/accelerator_handler_touch.cc
+++ b/views/focus/accelerator_handler_touch.cc
@@ -177,16 +177,18 @@ void SetTouchDeviceList(std::vector<unsigned int>& devices) {
AcceleratorHandler::AcceleratorHandler() {}
+#if defined(TOUCH_UI)
+base::MessagePumpDispatcher::DispatchStatus
+ AcceleratorHandler::Dispatch(XEvent* xev) {
+ return DispatchXEvent(xev) ?
+ base::MessagePumpDispatcher::EVENT_PROCESSED :
+ base::MessagePumpDispatcher::EVENT_IGNORED;
+}
+#else
bool AcceleratorHandler::Dispatch(GdkEvent* event) {
gtk_main_do_event(event);
return true;
}
-
-base::MessagePumpGlibXDispatcher::DispatchStatus
- AcceleratorHandler::DispatchX(XEvent* xev) {
- return DispatchXEvent(xev) ?
- base::MessagePumpGlibXDispatcher::EVENT_PROCESSED :
- base::MessagePumpGlibXDispatcher::EVENT_IGNORED;
-}
+#endif
} // namespace views
diff --git a/views/views.gyp b/views/views.gyp
index 67f7974..5d099ba 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -523,6 +523,9 @@
'../base/allocator/allocator.gyp:allocator',
],
}],
+ [ 'touchui==1', {
+ 'sources!': [ 'focus/accelerator_handler_gtk_unittest.cc' ],
+ }],
],
},
],
diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc
index 6ecf284..8d6e7fe 100644
--- a/views/widget/native_widget_gtk.cc
+++ b/views/widget/native_widget_gtk.cc
@@ -1632,7 +1632,7 @@ void NativeWidgetGtk::OnMap(GtkWidget* widget) {
// a workaround for a bug that X Expose event does not trigger
// Gdk's expose signal. This happens when you try to open views menu
// while a virtual keyboard gets kicked in or out. This seems to be
- // a bug in message_pump_glib_x.cc as we do get X Expose event but
+ // a bug in message_pump_x.cc as we do get X Expose event but
// it doesn't trigger gtk's expose signal. We're not going to fix this
// as we're removing gtk and migrating to new compositor.
gdk_window_process_all_updates();