diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/GlobalHotkeys.hpp | 6 | ||||
-rw-r--r-- | include/GlobalHotkeysX11.hpp | 5 | ||||
-rw-r--r-- | include/Overlay.hpp | 3 |
3 files changed, 12 insertions, 2 deletions
diff --git a/include/GlobalHotkeys.hpp b/include/GlobalHotkeys.hpp index 662113e..27fca07 100644 --- a/include/GlobalHotkeys.hpp +++ b/include/GlobalHotkeys.hpp @@ -4,6 +4,10 @@ #include <functional> #include <string> +namespace mgl { + class Event; +} + namespace gsr { struct Hotkey { uint64_t key = 0; @@ -24,5 +28,7 @@ namespace gsr { virtual void unbind_all_keys() {} virtual bool bind_action(const std::string &id, GlobalHotkeyCallback callback) { (void)id; (void)callback; return false; }; virtual void poll_events() = 0; + // Returns true if the event wasn't consumed (if the event didn't match a key that has been bound) + virtual bool on_event(mgl::Event &event) { (void)event; return true; } }; }
\ No newline at end of file diff --git a/include/GlobalHotkeysX11.hpp b/include/GlobalHotkeysX11.hpp index 427e9f0..610399a 100644 --- a/include/GlobalHotkeysX11.hpp +++ b/include/GlobalHotkeysX11.hpp @@ -12,12 +12,15 @@ namespace gsr { GlobalHotkeysX11& operator=(const GlobalHotkeysX11&) = delete; ~GlobalHotkeysX11() override; + // Hotkey key is a KeySym (XK_z for example) and modifiers is a bitmask of X11 modifier masks (for example ShiftMask | Mod1Mask) bool bind_key_press(Hotkey hotkey, const std::string &id, GlobalHotkeyCallback callback) override; void unbind_key_press(const std::string &id) override; void unbind_all_keys() override; void poll_events() override; + bool on_event(mgl::Event &event) override; private: - void call_hotkey_callback(Hotkey hotkey) const; + // Returns true if a key bind has been registered for the hotkey + bool call_hotkey_callback(Hotkey hotkey) const; private: struct HotkeyData { Hotkey hotkey; diff --git a/include/Overlay.hpp b/include/Overlay.hpp index e6b65e3..bf49a42 100644 --- a/include/Overlay.hpp +++ b/include/Overlay.hpp @@ -18,6 +18,7 @@ namespace gsr { class DropdownButton; + class GlobalHotkeys; enum class RecordingStatus { NONE, @@ -40,7 +41,7 @@ namespace gsr { Overlay& operator=(const Overlay&) = delete; ~Overlay(); - void handle_events(); + void handle_events(gsr::GlobalHotkeys *global_hotkeys); void on_event(mgl::Event &event); // Returns false if not visible bool draw(); |