summaryrefslogtreecommitdiff
path: root/src/protocols/GlobalShortcuts.hpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2023-04-09 13:48:20 +0100
committerGitHub <noreply@github.com>2023-04-09 13:48:20 +0100
commit046ad79d11dbccc90ade48d63aaa340655d999fb (patch)
tree7ffb5ae0d0abd09cba72e42be5a27585531090e4 /src/protocols/GlobalShortcuts.hpp
parente4e653ada6fc729efad3f6a0d49cf72b94c43b6c (diff)
GlobalShortcuts protocol impl (#1886)
Implements the `hyprland-global-shortcuts-v1` protocol --------- Co-authored-by: Mihai Fufezan <fufexan@protonmail.com>
Diffstat (limited to 'src/protocols/GlobalShortcuts.hpp')
-rw-r--r--src/protocols/GlobalShortcuts.hpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/protocols/GlobalShortcuts.hpp b/src/protocols/GlobalShortcuts.hpp
new file mode 100644
index 00000000..07c484c6
--- /dev/null
+++ b/src/protocols/GlobalShortcuts.hpp
@@ -0,0 +1,39 @@
+#pragma once
+#include "../defines.hpp"
+#include "hyprland-global-shortcuts-v1-protocol.h"
+#include <vector>
+
+struct SShortcut {
+ wl_resource* resource;
+ std::string id, description, appid;
+ uint32_t shortcut = 0;
+};
+
+struct SShortcutClient {
+ wl_client* client = nullptr;
+ std::vector<std::unique_ptr<SShortcut>> shortcuts;
+};
+
+class CGlobalShortcutsProtocolManager {
+ public:
+ CGlobalShortcutsProtocolManager();
+ void bindManager(wl_client* client, void* data, uint32_t version, uint32_t id);
+ void displayDestroy();
+
+ void registerShortcut(wl_client* client, wl_resource* resource, uint32_t shortcut, const char* id, const char* app_id, const char* description,
+ const char* trigger_description);
+ void destroyShortcut(wl_resource* resource);
+
+ bool globalShortcutExists(std::string appid, std::string trigger);
+ void sendGlobalShortcutEvent(std::string appid, std::string trigger, bool pressed);
+
+ std::vector<SShortcut> getAllShortcuts();
+
+ private:
+ std::vector<std::unique_ptr<SShortcutClient>> m_vClients;
+
+ SShortcutClient* clientFromWlClient(wl_client* client);
+
+ wl_global* m_pGlobal = nullptr;
+ wl_listener m_liDisplayDestroy;
+}; \ No newline at end of file