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