Hyprland/src/helpers/WLListener.hpp

39 lines
1 KiB
C++
Raw Normal View History

2022-03-28 22:31:39 +02:00
#pragma once
2023-08-07 13:35:19 +02:00
#include <string>
2022-03-28 22:31:39 +02:00
#include <functional>
2023-08-07 13:35:19 +02:00
#include <wayland-server.h>
2022-03-28 22:31:39 +02:00
class CHyprWLListener {
public:
2022-03-28 22:31:39 +02:00
CHyprWLListener(wl_signal*, std::function<void(void*, void*)>, void* owner);
CHyprWLListener();
~CHyprWLListener();
2023-08-07 13:35:19 +02:00
CHyprWLListener(const CHyprWLListener&) = delete;
CHyprWLListener(CHyprWLListener&&) = delete;
2022-07-26 21:41:29 +02:00
CHyprWLListener& operator=(const CHyprWLListener&) = delete;
2023-08-07 13:35:19 +02:00
CHyprWLListener& operator=(CHyprWLListener&&) = delete;
2022-07-26 21:41:29 +02:00
void initCallback(wl_signal*, std::function<void(void*, void*)>, void* owner, std::string author = "");
2022-03-28 22:31:39 +02:00
void removeCallback();
2022-03-28 22:31:39 +02:00
bool isConnected();
2022-03-28 22:31:39 +02:00
2022-07-26 21:41:29 +02:00
struct SWrapper {
wl_listener m_sListener;
2022-07-26 21:41:29 +02:00
CHyprWLListener* m_pSelf;
};
2022-03-28 22:31:39 +02:00
void emit(void*);
private:
SWrapper m_swWrapper;
2022-03-28 22:31:39 +02:00
void* m_pOwner = nullptr;
2022-03-28 22:31:39 +02:00
std::function<void(void*, void*)> m_pCallback = nullptr;
std::string m_szAuthor = "";
2022-03-28 22:31:39 +02:00
};