aboutsummaryrefslogtreecommitdiff
path: root/include/GlobalHotkeys.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/GlobalHotkeys.hpp')
-rw-r--r--include/GlobalHotkeys.hpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/include/GlobalHotkeys.hpp b/include/GlobalHotkeys.hpp
index 662113e..2927fa7 100644
--- a/include/GlobalHotkeys.hpp
+++ b/include/GlobalHotkeys.hpp
@@ -4,10 +4,25 @@
#include <functional>
#include <string>
+namespace mgl {
+ class Event;
+}
+
namespace gsr {
+ enum HotkeyModifier : uint32_t {
+ HOTKEY_MOD_LSHIFT = 1 << 0,
+ HOTKEY_MOD_RSHIFT = 1 << 1,
+ HOTKEY_MOD_LCTRL = 1 << 2,
+ HOTKEY_MOD_RCTRL = 1 << 3,
+ HOTKEY_MOD_LALT = 1 << 4,
+ HOTKEY_MOD_RALT = 1 << 5,
+ HOTKEY_MOD_LSUPER = 1 << 6,
+ HOTKEY_MOD_RSUPER = 1 << 7
+ };
+
struct Hotkey {
- uint64_t key = 0;
- uint32_t modifiers = 0;
+ uint32_t key = 0; // X11 keysym
+ uint32_t modifiers = 0; // HotkeyModifier
};
using GlobalHotkeyCallback = std::function<void(const std::string &id)>;
@@ -24,5 +39,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