Hyprland/src/protocols/WaylandProtocol.hpp

36 lines
1.3 KiB
C++
Raw Normal View History

#pragma once
#include "../defines.hpp"
#include <functional>
#define RESOURCE_OR_BAIL(resname) \
const auto resname = (CWaylandResource*)wl_resource_get_user_data(resource); \
if (!resname) \
return;
#define SP std::shared_ptr
#define UP std::unique_ptr
2024-04-21 17:29:30 +02:00
#define WP std::weak_ptr
#define PROTO NProtocols
2023-08-07 13:35:19 +02:00
class IWaylandProtocol {
public:
IWaylandProtocol(const wl_interface* iface, const int& ver, const std::string& name);
~IWaylandProtocol();
virtual void onDisplayDestroy();
2023-08-07 13:35:19 +02:00
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) = 0;
2024-04-22 19:44:25 +02:00
template <typename... Args>
void protoLog(LogLevel level, std::format_string<Args...> fmt, Args&&... args) {
Debug::log(level, std::format("[{}] ", m_szName) + std::vformat(fmt.get(), std::make_format_args(args...)));
};
private:
2024-04-22 19:44:25 +02:00
std::string m_szName;
wl_global* m_pGlobal = nullptr;
wl_listener m_liDisplayDestroy;
};