Use the global_shortcut_listener_x11 from chrome36.
This fixes compilation error on Linux.
This commit is contained in:
parent
33580f66df
commit
e3eaf909a5
2 changed files with 21 additions and 60 deletions
|
@ -7,15 +7,10 @@
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "ui/base/accelerators/accelerator.h"
|
#include "ui/base/accelerators/accelerator.h"
|
||||||
#include "ui/events/keycodes/keyboard_code_conversion_x.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_error_tracker.h"
|
||||||
#include "ui/gfx/x/x11_types.h"
|
#include "ui/gfx/x/x11_types.h"
|
||||||
|
|
||||||
#if defined(TOOLKIT_GTK)
|
|
||||||
#include <gdk/gdkx.h>
|
|
||||||
#else
|
|
||||||
#include "base/message_loop/message_pump_x11.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using content::BrowserThread;
|
using content::BrowserThread;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -72,13 +67,8 @@ void GlobalShortcutListenerX11::StartListening() {
|
||||||
DCHECK(!is_listening_); // Don't start twice.
|
DCHECK(!is_listening_); // Don't start twice.
|
||||||
DCHECK(!registered_hot_keys_.empty()); // Also don't start if no hotkey is
|
DCHECK(!registered_hot_keys_.empty()); // Also don't start if no hotkey is
|
||||||
// registered.
|
// registered.
|
||||||
#if defined(TOOLKIT_GTK)
|
|
||||||
gdk_window_add_filter(gdk_get_default_root_window(),
|
ui::X11EventSource::GetInstance()->AddPlatformEventDispatcher(this);
|
||||||
&GlobalShortcutListenerX11::OnXEventThunk,
|
|
||||||
this);
|
|
||||||
#else
|
|
||||||
base::MessagePumpX11::Current()->AddDispatcherForRootWindow(this);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
is_listening_ = true;
|
is_listening_ = true;
|
||||||
}
|
}
|
||||||
|
@ -88,25 +78,23 @@ void GlobalShortcutListenerX11::StopListening() {
|
||||||
DCHECK(registered_hot_keys_.empty()); // Make sure the set is clean before
|
DCHECK(registered_hot_keys_.empty()); // Make sure the set is clean before
|
||||||
// ending.
|
// ending.
|
||||||
|
|
||||||
#if defined(TOOLKIT_GTK)
|
ui::X11EventSource::GetInstance()->RemovePlatformEventDispatcher(this);
|
||||||
gdk_window_remove_filter(NULL,
|
|
||||||
&GlobalShortcutListenerX11::OnXEventThunk,
|
|
||||||
this);
|
|
||||||
#else
|
|
||||||
base::MessagePumpX11::Current()->RemoveDispatcherForRootWindow(this);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
is_listening_ = false;
|
is_listening_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(TOOLKIT_GTK)
|
bool GlobalShortcutListenerX11::CanDispatchEvent(
|
||||||
uint32_t GlobalShortcutListenerX11::Dispatch(const base::NativeEvent& event) {
|
const ui::PlatformEvent& event) {
|
||||||
if (event->type == KeyPress)
|
return event->type == KeyPress;
|
||||||
OnXKeyPressEvent(event);
|
}
|
||||||
|
|
||||||
return POST_DISPATCH_NONE;
|
uint32_t GlobalShortcutListenerX11::DispatchEvent(
|
||||||
|
const ui::PlatformEvent& event) {
|
||||||
|
CHECK_EQ(KeyPress, event->type);
|
||||||
|
OnXKeyPressEvent(event);
|
||||||
|
|
||||||
|
return ui::POST_DISPATCH_NONE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
bool GlobalShortcutListenerX11::RegisterAcceleratorImpl(
|
bool GlobalShortcutListenerX11::RegisterAcceleratorImpl(
|
||||||
const ui::Accelerator& accelerator) {
|
const ui::Accelerator& accelerator) {
|
||||||
|
@ -154,17 +142,6 @@ void GlobalShortcutListenerX11::UnregisterAcceleratorImpl(
|
||||||
registered_hot_keys_.erase(accelerator);
|
registered_hot_keys_.erase(accelerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(TOOLKIT_GTK)
|
|
||||||
GdkFilterReturn GlobalShortcutListenerX11::OnXEvent(GdkXEvent* gdk_x_event,
|
|
||||||
GdkEvent* gdk_event) {
|
|
||||||
XEvent* x_event = static_cast<XEvent*>(gdk_x_event);
|
|
||||||
if (x_event->type == KeyPress)
|
|
||||||
OnXKeyPressEvent(x_event);
|
|
||||||
|
|
||||||
return GDK_FILTER_CONTINUE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void GlobalShortcutListenerX11::OnXKeyPressEvent(::XEvent* x_event) {
|
void GlobalShortcutListenerX11::OnXKeyPressEvent(::XEvent* x_event) {
|
||||||
DCHECK(x_event->type == KeyPress);
|
DCHECK(x_event->type == KeyPress);
|
||||||
int modifiers = 0;
|
int modifiers = 0;
|
||||||
|
|
|
@ -8,33 +8,23 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "base/message_loop/message_pump_dispatcher.h"
|
|
||||||
#include "chrome/browser/extensions/global_shortcut_listener.h"
|
#include "chrome/browser/extensions/global_shortcut_listener.h"
|
||||||
|
#include "ui/events/platform/platform_event_dispatcher.h"
|
||||||
#if defined(TOOLKIT_GTK)
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include "ui/base/gtk/gtk_signal.h"
|
|
||||||
#endif // defined(TOOLKIT_GTK)
|
|
||||||
|
|
||||||
namespace extensions {
|
namespace extensions {
|
||||||
|
|
||||||
// X11-specific implementation of the GlobalShortcutListener class that
|
// X11-specific implementation of the GlobalShortcutListener class that
|
||||||
// listens for global shortcuts. Handles basic keyboard intercepting and
|
// listens for global shortcuts. Handles basic keyboard intercepting and
|
||||||
// forwards its output to the base class for processing.
|
// forwards its output to the base class for processing.
|
||||||
class GlobalShortcutListenerX11
|
class GlobalShortcutListenerX11 : public GlobalShortcutListener,
|
||||||
:
|
public ui::PlatformEventDispatcher {
|
||||||
#if !defined(TOOLKIT_GTK)
|
|
||||||
public base::MessagePumpDispatcher,
|
|
||||||
#endif
|
|
||||||
public GlobalShortcutListener {
|
|
||||||
public:
|
public:
|
||||||
GlobalShortcutListenerX11();
|
GlobalShortcutListenerX11();
|
||||||
virtual ~GlobalShortcutListenerX11();
|
virtual ~GlobalShortcutListenerX11();
|
||||||
|
|
||||||
#if !defined(TOOLKIT_GTK)
|
// ui::PlatformEventDispatcher implementation.
|
||||||
// base::MessagePumpDispatcher implementation.
|
virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE;
|
||||||
virtual uint32_t Dispatch(const base::NativeEvent& event) OVERRIDE;
|
virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE;
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// GlobalShortcutListener implementation.
|
// GlobalShortcutListener implementation.
|
||||||
|
@ -45,12 +35,6 @@ class GlobalShortcutListenerX11
|
||||||
virtual void UnregisterAcceleratorImpl(
|
virtual void UnregisterAcceleratorImpl(
|
||||||
const ui::Accelerator& accelerator) OVERRIDE;
|
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.
|
// Invoked when a global shortcut is pressed.
|
||||||
void OnXKeyPressEvent(::XEvent* x_event);
|
void OnXKeyPressEvent(::XEvent* x_event);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue