From 046ad79d11dbccc90ade48d63aaa340655d999fb Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Sun, 9 Apr 2023 13:48:20 +0100 Subject: GlobalShortcuts protocol impl (#1886) Implements the `hyprland-global-shortcuts-v1` protocol --------- Co-authored-by: Mihai Fufezan --- src/protocols/GlobalShortcuts.hpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/protocols/GlobalShortcuts.hpp (limited to 'src/protocols/GlobalShortcuts.hpp') 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 + +struct SShortcut { + wl_resource* resource; + std::string id, description, appid; + uint32_t shortcut = 0; +}; + +struct SShortcutClient { + wl_client* client = nullptr; + std::vector> 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 getAllShortcuts(); + + private: + std::vector> m_vClients; + + SShortcutClient* clientFromWlClient(wl_client* client); + + wl_global* m_pGlobal = nullptr; + wl_listener m_liDisplayDestroy; +}; \ No newline at end of file -- cgit v1.2.3