2023-01-20 19:44:30 +01:00
|
|
|
#pragma once
|
|
|
|
|
2024-04-20 15:14:54 +02:00
|
|
|
#include <memory>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include "WaylandProtocol.hpp"
|
|
|
|
#include "fractional-scale-v1.hpp"
|
2023-01-20 19:44:30 +01:00
|
|
|
|
2024-04-20 15:14:54 +02:00
|
|
|
class CFractionalScaleProtocol;
|
2024-06-08 10:07:59 +02:00
|
|
|
class CWLSurfaceResource;
|
2023-01-20 19:44:30 +01:00
|
|
|
|
2024-04-20 15:14:54 +02:00
|
|
|
class CFractionalScaleAddon {
|
2023-01-20 19:44:30 +01:00
|
|
|
public:
|
2024-06-08 10:07:59 +02:00
|
|
|
CFractionalScaleAddon(SP<CWpFractionalScaleV1> resource_, SP<CWLSurfaceResource> surf_);
|
2024-04-20 15:14:54 +02:00
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
void setScale(const float& scale);
|
|
|
|
void onSurfaceDestroy();
|
2024-04-20 15:14:54 +02:00
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
bool good();
|
2023-01-20 19:44:30 +01:00
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
SP<CWLSurfaceResource> surf();
|
2023-01-20 19:44:30 +01:00
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
bool operator==(const wl_resource* other) const {
|
2024-04-20 15:14:54 +02:00
|
|
|
return other == resource->resource();
|
|
|
|
}
|
2023-01-20 19:44:30 +01:00
|
|
|
|
2024-04-20 15:14:54 +02:00
|
|
|
bool operator==(const CFractionalScaleAddon* other) const {
|
|
|
|
return other->resource == resource;
|
|
|
|
}
|
2023-01-20 19:44:30 +01:00
|
|
|
|
2024-04-20 15:14:54 +02:00
|
|
|
private:
|
|
|
|
SP<CWpFractionalScaleV1> resource;
|
2024-06-08 10:07:59 +02:00
|
|
|
float scale = 1.F;
|
|
|
|
WP<CWLSurfaceResource> surface;
|
2024-04-20 15:14:54 +02:00
|
|
|
bool surfaceGone = false;
|
2023-01-20 19:44:30 +01:00
|
|
|
|
2024-04-20 15:14:54 +02:00
|
|
|
friend class CFractionalScaleProtocol;
|
|
|
|
};
|
2023-01-20 19:44:30 +01:00
|
|
|
|
2024-04-20 15:14:54 +02:00
|
|
|
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);
|
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
void onSurfaceDestroy(SP<CWLSurfaceResource> surf);
|
|
|
|
void sendScale(SP<CWLSurfaceResource> surf, const float& scale);
|
2023-01-20 19:44:30 +01:00
|
|
|
|
|
|
|
private:
|
2024-04-21 20:29:45 +02:00
|
|
|
void removeAddon(CFractionalScaleAddon*);
|
|
|
|
void onManagerResourceDestroy(wl_resource* res);
|
2024-06-08 10:07:59 +02:00
|
|
|
void onGetFractionalScale(CWpFractionalScaleManagerV1* pMgr, uint32_t id, SP<CWLSurfaceResource> surface);
|
2024-04-20 15:14:54 +02:00
|
|
|
|
2024-04-21 20:29:45 +02:00
|
|
|
//
|
2023-01-20 19:44:30 +01:00
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
std::unordered_map<WP<CWLSurfaceResource>, float> m_mSurfaceScales;
|
|
|
|
std::unordered_map<WP<CWLSurfaceResource>, UP<CFractionalScaleAddon>> m_mAddons;
|
|
|
|
std::vector<UP<CWpFractionalScaleManagerV1>> m_vManagers;
|
2024-04-21 20:29:45 +02:00
|
|
|
|
|
|
|
friend class CFractionalScaleAddon;
|
2024-04-20 15:14:54 +02:00
|
|
|
};
|
2023-01-20 19:44:30 +01:00
|
|
|
|
2024-04-20 15:14:54 +02:00
|
|
|
namespace PROTO {
|
|
|
|
inline UP<CFractionalScaleProtocol> fractional;
|
2024-06-08 10:07:59 +02:00
|
|
|
};
|