2024-04-19 23:16:35 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include "WaylandProtocol.hpp"
|
2024-04-20 14:25:29 +02:00
|
|
|
#include "tearing-control-v1.hpp"
|
2024-04-19 23:16:35 +02:00
|
|
|
|
|
|
|
class CWindow;
|
|
|
|
class CTearingControlProtocol;
|
|
|
|
|
|
|
|
class CTearingControl {
|
|
|
|
public:
|
2024-04-20 14:25:29 +02:00
|
|
|
CTearingControl(SP<CWpTearingControlV1> resource_, wlr_surface* surf_);
|
2024-04-19 23:16:35 +02:00
|
|
|
|
2024-04-20 14:25:29 +02:00
|
|
|
void onHint(wpTearingControlV1PresentationHint hint_);
|
2024-04-19 23:16:35 +02:00
|
|
|
|
|
|
|
bool good();
|
|
|
|
|
|
|
|
bool operator==(const wl_resource* other) const {
|
|
|
|
return other == resource->resource();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const CTearingControl* other) const {
|
|
|
|
return other->resource == resource;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2024-04-20 14:25:29 +02:00
|
|
|
void updateWindow();
|
2024-04-19 23:16:35 +02:00
|
|
|
|
2024-04-20 14:25:29 +02:00
|
|
|
SP<CWpTearingControlV1> resource;
|
|
|
|
CWindow* pWindow = nullptr;
|
|
|
|
wpTearingControlV1PresentationHint hint = PRESENTATION_HINT_VSYNC;
|
2024-04-19 23:16:35 +02:00
|
|
|
|
|
|
|
friend class CTearingControlProtocol;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CTearingControlProtocol : public IWaylandProtocol {
|
|
|
|
public:
|
|
|
|
CTearingControlProtocol(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 onControllerDestroy(CTearingControl* control);
|
|
|
|
void onGetController(wl_client* client, wl_resource* resource, uint32_t id, wlr_surface* surf);
|
|
|
|
|
|
|
|
private:
|
2024-04-20 14:25:29 +02:00
|
|
|
void onWindowDestroy(CWindow* pWindow);
|
2024-04-19 23:16:35 +02:00
|
|
|
|
2024-04-20 14:25:29 +02:00
|
|
|
std::vector<UP<CWpTearingControlManagerV1>> m_vManagers;
|
|
|
|
std::vector<UP<CTearingControl>> m_vTearingControllers;
|
2024-04-19 23:16:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace PROTO {
|
|
|
|
inline UP<CTearingControlProtocol> tearing;
|
|
|
|
};
|