#pragma once #include #include #include "WaylandProtocol.hpp" #include "fractional-scale-v1.hpp" class CFractionalScaleProtocol; class CWLSurfaceResource; class CFractionalScaleAddon { public: CFractionalScaleAddon(SP resource_, SP surf_); void setScale(const float& scale); void onSurfaceDestroy(); bool good(); SP 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; WP surface; bool surfaceGone = false; friend class CFractionalScaleProtocol; }; 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 onSurfaceDestroy(SP surf); void sendScale(SP surf, const float& scale); private: void removeAddon(CFractionalScaleAddon*); void onManagerResourceDestroy(wl_resource* res); void onGetFractionalScale(CWpFractionalScaleManagerV1* pMgr, uint32_t id, SP surface); // std::unordered_map, float> m_mSurfaceScales; std::unordered_map, UP> m_mAddons; std::vector> m_vManagers; friend class CFractionalScaleAddon; }; namespace PROTO { inline UP fractional; };