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;
|
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-04-20 15:14:54 +02:00
|
|
|
CFractionalScaleAddon(SP<CWpFractionalScaleV1> resource_, wlr_surface* surf_);
|
|
|
|
|
|
|
|
void setScale(const float& scale);
|
|
|
|
void onSurfaceDestroy();
|
|
|
|
|
|
|
|
bool good();
|
2023-01-20 19:44:30 +01:00
|
|
|
|
2024-04-20 15:14:54 +02:00
|
|
|
wlr_surface* surf();
|
2023-01-20 19:44:30 +01:00
|
|
|
|
2024-04-20 15:14:54 +02:00
|
|
|
bool operator==(const wl_resource* other) const {
|
|
|
|
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;
|
|
|
|
float scale = 1.F;
|
|
|
|
wlr_surface* surface = nullptr;
|
|
|
|
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
|
|
|
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*);
|
2023-01-20 19:44:30 +01:00
|
|
|
|
|
|
|
private:
|
2024-04-20 15:14:54 +02:00
|
|
|
void registerSurface(wlr_surface*);
|
|
|
|
|
|
|
|
std::unordered_map<wlr_surface*, SSurfaceListener> m_mSurfaceDestroyListeners;
|
2023-01-20 19:44:30 +01:00
|
|
|
|
2024-04-20 15:14:54 +02:00
|
|
|
std::unordered_map<wlr_surface*, float> m_mSurfaceScales;
|
|
|
|
std::unordered_map<wlr_surface*, UP<CFractionalScaleAddon>> m_mAddons;
|
|
|
|
std::vector<UP<CWpFractionalScaleManagerV1>> m_vManagers;
|
|
|
|
};
|
2023-01-20 19:44:30 +01:00
|
|
|
|
2024-04-20 15:14:54 +02:00
|
|
|
namespace PROTO {
|
|
|
|
inline UP<CFractionalScaleProtocol> fractional;
|
2023-01-20 19:44:30 +01:00
|
|
|
};
|