diff --git a/chromium_src/chrome/browser/extensions/global_shortcut_listener_x11.cc b/chromium_src/chrome/browser/extensions/global_shortcut_listener_x11.cc index 556bd707a54a..5a3ad1a7a6ce 100644 --- a/chromium_src/chrome/browser/extensions/global_shortcut_listener_x11.cc +++ b/chromium_src/chrome/browser/extensions/global_shortcut_listener_x11.cc @@ -7,15 +7,10 @@ #include "content/public/browser/browser_thread.h" #include "ui/base/accelerators/accelerator.h" #include "ui/events/keycodes/keyboard_code_conversion_x.h" +#include "ui/events/platform/x11/x11_event_source.h" #include "ui/gfx/x/x11_error_tracker.h" #include "ui/gfx/x/x11_types.h" -#if defined(TOOLKIT_GTK) -#include -#else -#include "base/message_loop/message_pump_x11.h" -#endif - using content::BrowserThread; namespace { @@ -72,13 +67,8 @@ void GlobalShortcutListenerX11::StartListening() { DCHECK(!is_listening_); // Don't start twice. DCHECK(!registered_hot_keys_.empty()); // Also don't start if no hotkey is // registered. -#if defined(TOOLKIT_GTK) - gdk_window_add_filter(gdk_get_default_root_window(), - &GlobalShortcutListenerX11::OnXEventThunk, - this); -#else - base::MessagePumpX11::Current()->AddDispatcherForRootWindow(this); -#endif + + ui::X11EventSource::GetInstance()->AddPlatformEventDispatcher(this); is_listening_ = true; } @@ -88,25 +78,23 @@ void GlobalShortcutListenerX11::StopListening() { DCHECK(registered_hot_keys_.empty()); // Make sure the set is clean before // ending. -#if defined(TOOLKIT_GTK) - gdk_window_remove_filter(NULL, - &GlobalShortcutListenerX11::OnXEventThunk, - this); -#else - base::MessagePumpX11::Current()->RemoveDispatcherForRootWindow(this); -#endif + ui::X11EventSource::GetInstance()->RemovePlatformEventDispatcher(this); is_listening_ = false; } -#if !defined(TOOLKIT_GTK) -uint32_t GlobalShortcutListenerX11::Dispatch(const base::NativeEvent& event) { - if (event->type == KeyPress) - OnXKeyPressEvent(event); - - return POST_DISPATCH_NONE; +bool GlobalShortcutListenerX11::CanDispatchEvent( + const ui::PlatformEvent& event) { + return event->type == KeyPress; +} + +uint32_t GlobalShortcutListenerX11::DispatchEvent( + const ui::PlatformEvent& event) { + CHECK_EQ(KeyPress, event->type); + OnXKeyPressEvent(event); + + return ui::POST_DISPATCH_NONE; } -#endif bool GlobalShortcutListenerX11::RegisterAcceleratorImpl( const ui::Accelerator& accelerator) { @@ -154,17 +142,6 @@ void GlobalShortcutListenerX11::UnregisterAcceleratorImpl( registered_hot_keys_.erase(accelerator); } -#if defined(TOOLKIT_GTK) -GdkFilterReturn GlobalShortcutListenerX11::OnXEvent(GdkXEvent* gdk_x_event, - GdkEvent* gdk_event) { - XEvent* x_event = static_cast(gdk_x_event); - if (x_event->type == KeyPress) - OnXKeyPressEvent(x_event); - - return GDK_FILTER_CONTINUE; -} -#endif - void GlobalShortcutListenerX11::OnXKeyPressEvent(::XEvent* x_event) { DCHECK(x_event->type == KeyPress); int modifiers = 0; diff --git a/chromium_src/chrome/browser/extensions/global_shortcut_listener_x11.h b/chromium_src/chrome/browser/extensions/global_shortcut_listener_x11.h index 69ebca147439..cc21ccb7454e 100644 --- a/chromium_src/chrome/browser/extensions/global_shortcut_listener_x11.h +++ b/chromium_src/chrome/browser/extensions/global_shortcut_listener_x11.h @@ -8,33 +8,23 @@ #include #include -#include "base/message_loop/message_pump_dispatcher.h" #include "chrome/browser/extensions/global_shortcut_listener.h" - -#if defined(TOOLKIT_GTK) -#include -#include "ui/base/gtk/gtk_signal.h" -#endif // defined(TOOLKIT_GTK) +#include "ui/events/platform/platform_event_dispatcher.h" namespace extensions { // X11-specific implementation of the GlobalShortcutListener class that // listens for global shortcuts. Handles basic keyboard intercepting and // forwards its output to the base class for processing. -class GlobalShortcutListenerX11 - : -#if !defined(TOOLKIT_GTK) - public base::MessagePumpDispatcher, -#endif - public GlobalShortcutListener { +class GlobalShortcutListenerX11 : public GlobalShortcutListener, + public ui::PlatformEventDispatcher { public: GlobalShortcutListenerX11(); virtual ~GlobalShortcutListenerX11(); -#if !defined(TOOLKIT_GTK) - // base::MessagePumpDispatcher implementation. - virtual uint32_t Dispatch(const base::NativeEvent& event) OVERRIDE; -#endif + // ui::PlatformEventDispatcher implementation. + virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE; + virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE; private: // GlobalShortcutListener implementation. @@ -45,12 +35,6 @@ class GlobalShortcutListenerX11 virtual void UnregisterAcceleratorImpl( const ui::Accelerator& accelerator) OVERRIDE; -#if defined(TOOLKIT_GTK) - // Callback for XEvents of the default root window. - CHROMEG_CALLBACK_1(GlobalShortcutListenerX11, GdkFilterReturn, - OnXEvent, GdkXEvent*, GdkEvent*); -#endif - // Invoked when a global shortcut is pressed. void OnXKeyPressEvent(::XEvent* x_event);