From 3b9b5346b830554aa7470ccf1202a7f3be72d1b4 Mon Sep 17 00:00:00 2001 From: Ikalco <73481042+ikalco@users.noreply.github.com> Date: Tue, 30 Jul 2024 16:33:56 -0500 Subject: protocols: Move globalshortcuts impl (#7102) * move global shortcuts to hyprwayland-scanner * remove wayland-scanner from deps * fix the thing --- src/protocols/GlobalShortcuts.hpp | 51 ++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 28 deletions(-) (limited to 'src/protocols/GlobalShortcuts.hpp') diff --git a/src/protocols/GlobalShortcuts.hpp b/src/protocols/GlobalShortcuts.hpp index 7e512021..14f6ee0b 100644 --- a/src/protocols/GlobalShortcuts.hpp +++ b/src/protocols/GlobalShortcuts.hpp @@ -1,48 +1,43 @@ #pragma once #include "../defines.hpp" -#include "hyprland-global-shortcuts-v1-protocol.h" +#include "hyprland-global-shortcuts-v1.hpp" +#include "../protocols/WaylandProtocol.hpp" #include struct SShortcut { - wl_resource* resource; - std::string id, description, appid; - uint32_t shortcut = 0; + SP resource; + std::string id, description, appid; + uint32_t shortcut = 0; }; -struct SShortcutClient { - wl_client* client = nullptr; - std::vector> shortcuts; -}; +class CShortcutClient { + public: + CShortcutClient(SP resource); + + bool good(); + + private: + SP resource; + std::vector> shortcuts; -class CGlobalShortcutsProtocolManager; -struct CGlobalShortcutsProtocolManagerDestroyWrapper { - wl_listener listener; - CGlobalShortcutsProtocolManager* parent = nullptr; + friend class CGlobalShortcutsProtocol; }; -class CGlobalShortcutsProtocolManager { +class CGlobalShortcutsProtocol : IWaylandProtocol { public: - CGlobalShortcutsProtocolManager(); - ~CGlobalShortcutsProtocolManager(); + CGlobalShortcutsProtocol(const wl_interface* iface, const int& ver, const std::string& name); void bindManager(wl_client* client, void* data, uint32_t version, uint32_t id); - void displayDestroy(); + void destroyResource(CShortcutClient* client); - 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); - + bool isTaken(std::string id, std::string app_id); std::vector getAllShortcuts(); - CGlobalShortcutsProtocolManagerDestroyWrapper m_liDisplayDestroy; - private: - std::vector> m_vClients; - - SShortcutClient* clientFromWlClient(wl_client* client); + std::vector> m_vClients; +}; - wl_global* m_pGlobal = nullptr; +namespace PROTO { + inline UP globalShortcuts; }; -- cgit v1.2.3