#pragma once #include #include #include "WaylandProtocol.hpp" #include "fractional-scale-v1.hpp" class CFractionalScaleProtocol; class CFractionalScaleAddon { public: CFractionalScaleAddon(SP resource_, wlr_surface* surf_); void setScale(const float& scale); void onSurfaceDestroy(); bool good(); wlr_surface* surf(); bool operator==(const wl_resource* other) const { return other == resource->resource(); } bool operator==(const CFractionalScaleAddon* other) const { return other->resource == resource; } private: SP resource; float scale = 1.F; wlr_surface* surface = nullptr; bool surfaceGone = false; friend class CFractionalScaleProtocol; }; struct SSurfaceListener { DYNLISTENER(surfaceDestroy); }; class CFractionalScaleProtocol : public IWaylandProtocol { public: CFractionalScaleProtocol(const wl_interface* iface, const int& ver, const std::string& name); virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id); void onManagerResourceDestroy(wl_resource* res); void onGetFractionalScale(CWpFractionalScaleManagerV1* pMgr, uint32_t id, wlr_surface* surface); void sendScale(wlr_surface* surf, const float& scale); void onSurfaceDestroy(wlr_surface* surf); void removeAddon(CFractionalScaleAddon*); private: void registerSurface(wlr_surface*); std::unordered_map m_mSurfaceDestroyListeners; std::unordered_map m_mSurfaceScales; std::unordered_map> m_mAddons; std::vector> m_vManagers; }; namespace PROTO { inline UP fractional; };