diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-09-08 17:07:22 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-09-08 17:07:22 +0200 |
commit | b145d957e3809fd6c2d814c34c58234ade983bb0 (patch) | |
tree | 3e8842c72afe0045645ad32a0b3a9ab708c575ee /include/GlobalHotkeysX11.hpp | |
parent | 3d5e8baa5f66547f1250950b10bd4108e30af423 (diff) |
More
Diffstat (limited to 'include/GlobalHotkeysX11.hpp')
-rw-r--r-- | include/GlobalHotkeysX11.hpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/GlobalHotkeysX11.hpp b/include/GlobalHotkeysX11.hpp new file mode 100644 index 0000000..427e9f0 --- /dev/null +++ b/include/GlobalHotkeysX11.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include "GlobalHotkeys.hpp" +#include <unordered_map> +#include <X11/Xlib.h> + +namespace gsr { + class GlobalHotkeysX11 : public GlobalHotkeys { + public: + GlobalHotkeysX11(); + GlobalHotkeysX11(const GlobalHotkeysX11&) = delete; + GlobalHotkeysX11& operator=(const GlobalHotkeysX11&) = delete; + ~GlobalHotkeysX11() override; + + 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; + private: + void call_hotkey_callback(Hotkey hotkey) const; + private: + struct HotkeyData { + Hotkey hotkey; + GlobalHotkeyCallback callback; + }; + + Display *dpy = nullptr; + XEvent xev; + std::unordered_map<std::string, HotkeyData> bound_keys_by_id; + }; +}
\ No newline at end of file |