summaryrefslogtreecommitdiff
path: root/src/protocols/GlobalShortcuts.hpp
diff options
context:
space:
mode:
authorIkalco <73481042+ikalco@users.noreply.github.com>2024-07-30 16:33:56 -0500
committerGitHub <noreply@github.com>2024-07-30 23:33:56 +0200
commit3b9b5346b830554aa7470ccf1202a7f3be72d1b4 (patch)
tree6770e07783bc49414e92bd23e0041971a8b6a360 /src/protocols/GlobalShortcuts.hpp
parent8ec3dc4c09c30aab7669f99ba6359be320023fa8 (diff)
protocols: Move globalshortcuts impl (#7102)
* move global shortcuts to hyprwayland-scanner * remove wayland-scanner from deps * fix the thing
Diffstat (limited to 'src/protocols/GlobalShortcuts.hpp')
-rw-r--r--src/protocols/GlobalShortcuts.hpp51
1 files changed, 23 insertions, 28 deletions
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 <vector>
struct SShortcut {
- wl_resource* resource;
- std::string id, description, appid;
- uint32_t shortcut = 0;
+ SP<CHyprlandGlobalShortcutV1> resource;
+ std::string id, description, appid;
+ uint32_t shortcut = 0;
};
-struct SShortcutClient {
- wl_client* client = nullptr;
- std::vector<std::unique_ptr<SShortcut>> shortcuts;
-};
+class CShortcutClient {
+ public:
+ CShortcutClient(SP<CHyprlandGlobalShortcutsManagerV1> resource);
+
+ bool good();
+
+ private:
+ SP<CHyprlandGlobalShortcutsManagerV1> resource;
+ std::vector<SP<SShortcut>> 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<SShortcut> getAllShortcuts();
- CGlobalShortcutsProtocolManagerDestroyWrapper m_liDisplayDestroy;
-
private:
- std::vector<std::unique_ptr<SShortcutClient>> m_vClients;
-
- SShortcutClient* clientFromWlClient(wl_client* client);
+ std::vector<SP<CShortcutClient>> m_vClients;
+};
- wl_global* m_pGlobal = nullptr;
+namespace PROTO {
+ inline UP<CGlobalShortcutsProtocol> globalShortcuts;
};