mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-05 21:46:00 +01:00
69 lines
No EOL
2 KiB
C++
69 lines
No EOL
2 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <unordered_map>
|
|
#include "WaylandProtocol.hpp"
|
|
#include "fractional-scale-v1.hpp"
|
|
|
|
class CFractionalScaleProtocol;
|
|
|
|
class CFractionalScaleAddon {
|
|
public:
|
|
CFractionalScaleAddon(SP<CWpFractionalScaleV1> 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<CWpFractionalScaleV1> 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 onSurfaceDestroy(wlr_surface* surf);
|
|
void sendScale(wlr_surface* surf, const float& scale);
|
|
|
|
private:
|
|
void removeAddon(CFractionalScaleAddon*);
|
|
void registerSurface(wlr_surface*);
|
|
void onManagerResourceDestroy(wl_resource* res);
|
|
void onGetFractionalScale(CWpFractionalScaleManagerV1* pMgr, uint32_t id, wlr_surface* surface);
|
|
|
|
//
|
|
std::unordered_map<wlr_surface*, SSurfaceListener> m_mSurfaceDestroyListeners;
|
|
|
|
std::unordered_map<wlr_surface*, float> m_mSurfaceScales;
|
|
std::unordered_map<wlr_surface*, UP<CFractionalScaleAddon>> m_mAddons;
|
|
std::vector<UP<CWpFractionalScaleManagerV1>> m_vManagers;
|
|
|
|
friend class CFractionalScaleAddon;
|
|
};
|
|
|
|
namespace PROTO {
|
|
inline UP<CFractionalScaleProtocol> fractional;
|
|
}; |