summaryrefslogtreecommitdiff
path: root/src/protocols/GlobalShortcuts.hpp
diff options
context:
space:
mode:
authorTom Englund <tomenglund26@gmail.com>2024-07-29 19:19:47 +0200
committerVaxry <vaxry@vaxry.net>2024-07-29 19:29:08 +0200
commit9c38b0fdbe32dc2cb81d53c9be90113d114f1cd2 (patch)
tree1e7b6c42be23f8164e5dd0742d3b131b2850cd01 /src/protocols/GlobalShortcuts.hpp
parent60b663e2765c4cdb7e14fff75c4f88bf7ae312e2 (diff)
core: add a destructor to CHyprOpenglImpl and avoid wl_container_of undefined behaviour (#7101)
* protocols: avoid undefined behaviour in C macro to safely use wl_container_of with a class the class has to be no virtual functions, no inheritance, and uniform access control (e.g all public) work around this by putting this into a destroywrapper struct. * opengl: clean memory on destruction add a destructor and free the allocated memory and close the fd
Diffstat (limited to 'src/protocols/GlobalShortcuts.hpp')
-rw-r--r--src/protocols/GlobalShortcuts.hpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/protocols/GlobalShortcuts.hpp b/src/protocols/GlobalShortcuts.hpp
index 5fd03465..7e512021 100644
--- a/src/protocols/GlobalShortcuts.hpp
+++ b/src/protocols/GlobalShortcuts.hpp
@@ -14,6 +14,12 @@ struct SShortcutClient {
std::vector<std::unique_ptr<SShortcut>> shortcuts;
};
+class CGlobalShortcutsProtocolManager;
+struct CGlobalShortcutsProtocolManagerDestroyWrapper {
+ wl_listener listener;
+ CGlobalShortcutsProtocolManager* parent = nullptr;
+};
+
class CGlobalShortcutsProtocolManager {
public:
CGlobalShortcutsProtocolManager();
@@ -31,7 +37,7 @@ class CGlobalShortcutsProtocolManager {
std::vector<SShortcut> getAllShortcuts();
- wl_listener m_liDisplayDestroy;
+ CGlobalShortcutsProtocolManagerDestroyWrapper m_liDisplayDestroy;
private:
std::vector<std::unique_ptr<SShortcutClient>> m_vClients;