1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_X11_H_
6 #define CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_X11_H_
11 #include "chrome/browser/extensions/global_shortcut_listener.h"
12 #include "ui/events/platform/platform_event_dispatcher.h"
14 namespace extensions {
16 // X11-specific implementation of the GlobalShortcutListener class that
17 // listens for global shortcuts. Handles basic keyboard intercepting and
18 // forwards its output to the base class for processing.
19 class GlobalShortcutListenerX11 : public GlobalShortcutListener,
20 public ui::PlatformEventDispatcher {
22 GlobalShortcutListenerX11();
23 virtual ~GlobalShortcutListenerX11();
25 // ui::PlatformEventDispatcher implementation.
26 virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE;
27 virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE;
30 // GlobalShortcutListener implementation.
31 virtual void StartListening() OVERRIDE;
32 virtual void StopListening() OVERRIDE;
33 virtual bool RegisterAcceleratorImpl(
34 const ui::Accelerator& accelerator) OVERRIDE;
35 virtual void UnregisterAcceleratorImpl(
36 const ui::Accelerator& accelerator) OVERRIDE;
38 // Invoked when a global shortcut is pressed.
39 void OnXKeyPressEvent(::XEvent* x_event);
41 // Whether this object is listening for global shortcuts.
44 // The x11 default display and the native root window.
45 ::Display* x_display_;
46 ::Window x_root_window_;
48 // A set of registered accelerators.
49 typedef std::set<ui::Accelerator> RegisteredHotKeys;
50 RegisteredHotKeys registered_hot_keys_;
52 DISALLOW_COPY_AND_ASSIGN(GlobalShortcutListenerX11);
55 } // namespace extensions
57 #endif // CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_X11_H_