protocols: refactor class member vars (a-m) (#10265)
This commit is contained in:
parent
46ac115bd1
commit
adbae0f74d
58 changed files with 1566 additions and 1561 deletions
|
|
@ -8,16 +8,16 @@
|
|||
#include "../helpers/Monitor.hpp"
|
||||
#include "../helpers/MiscFunctions.hpp"
|
||||
|
||||
CHyprlandCTMControlResource::CHyprlandCTMControlResource(SP<CHyprlandCtmControlManagerV1> resource_) : resource(resource_) {
|
||||
CHyprlandCTMControlResource::CHyprlandCTMControlResource(SP<CHyprlandCtmControlManagerV1> resource_) : m_resource(resource_) {
|
||||
if UNLIKELY (!good())
|
||||
return;
|
||||
|
||||
resource->setDestroy([this](CHyprlandCtmControlManagerV1* pMgr) { PROTO::ctm->destroyResource(this); });
|
||||
resource->setOnDestroy([this](CHyprlandCtmControlManagerV1* pMgr) { PROTO::ctm->destroyResource(this); });
|
||||
m_resource->setDestroy([this](CHyprlandCtmControlManagerV1* pMgr) { PROTO::ctm->destroyResource(this); });
|
||||
m_resource->setOnDestroy([this](CHyprlandCtmControlManagerV1* pMgr) { PROTO::ctm->destroyResource(this); });
|
||||
|
||||
resource->setSetCtmForOutput([this](CHyprlandCtmControlManagerV1* r, wl_resource* output, wl_fixed_t mat0, wl_fixed_t mat1, wl_fixed_t mat2, wl_fixed_t mat3, wl_fixed_t mat4,
|
||||
wl_fixed_t mat5, wl_fixed_t mat6, wl_fixed_t mat7, wl_fixed_t mat8) {
|
||||
if (blocked)
|
||||
m_resource->setSetCtmForOutput([this](CHyprlandCtmControlManagerV1* r, wl_resource* output, wl_fixed_t mat0, wl_fixed_t mat1, wl_fixed_t mat2, wl_fixed_t mat3, wl_fixed_t mat4,
|
||||
wl_fixed_t mat5, wl_fixed_t mat6, wl_fixed_t mat7, wl_fixed_t mat8) {
|
||||
if (m_blocked)
|
||||
return;
|
||||
|
||||
const auto OUTPUTRESOURCE = CWLOutputResource::fromResource(output);
|
||||
|
|
@ -35,42 +35,42 @@ CHyprlandCTMControlResource::CHyprlandCTMControlResource(SP<CHyprlandCtmControlM
|
|||
|
||||
for (auto& el : MAT) {
|
||||
if (el < 0.F) {
|
||||
resource->error(HYPRLAND_CTM_CONTROL_MANAGER_V1_ERROR_INVALID_MATRIX, "a matrix component was < 0");
|
||||
m_resource->error(HYPRLAND_CTM_CONTROL_MANAGER_V1_ERROR_INVALID_MATRIX, "a matrix component was < 0");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ctms[PMONITOR->m_name] = MAT;
|
||||
m_ctms[PMONITOR->m_name] = MAT;
|
||||
|
||||
LOGM(LOG, "CTM set for output {}: {}", PMONITOR->m_name, ctms.at(PMONITOR->m_name).toString());
|
||||
LOGM(LOG, "CTM set for output {}: {}", PMONITOR->m_name, m_ctms.at(PMONITOR->m_name).toString());
|
||||
});
|
||||
|
||||
resource->setCommit([this](CHyprlandCtmControlManagerV1* r) {
|
||||
if (blocked)
|
||||
m_resource->setCommit([this](CHyprlandCtmControlManagerV1* r) {
|
||||
if (m_blocked)
|
||||
return;
|
||||
|
||||
LOGM(LOG, "Committing ctms to outputs");
|
||||
|
||||
for (auto& m : g_pCompositor->m_monitors) {
|
||||
if (!ctms.contains(m->m_name)) {
|
||||
if (!m_ctms.contains(m->m_name)) {
|
||||
PROTO::ctm->setCTM(m, Mat3x3::identity());
|
||||
continue;
|
||||
}
|
||||
|
||||
PROTO::ctm->setCTM(m, ctms.at(m->m_name));
|
||||
PROTO::ctm->setCTM(m, m_ctms.at(m->m_name));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void CHyprlandCTMControlResource::block() {
|
||||
blocked = true;
|
||||
m_blocked = true;
|
||||
|
||||
if (resource->version() >= 2)
|
||||
resource->sendBlocked();
|
||||
if (m_resource->version() >= 2)
|
||||
m_resource->sendBlocked();
|
||||
}
|
||||
|
||||
CHyprlandCTMControlResource::~CHyprlandCTMControlResource() {
|
||||
if (blocked)
|
||||
if (m_blocked)
|
||||
return;
|
||||
|
||||
for (auto& m : g_pCompositor->m_monitors) {
|
||||
|
|
@ -79,7 +79,7 @@ CHyprlandCTMControlResource::~CHyprlandCTMControlResource() {
|
|||
}
|
||||
|
||||
bool CHyprlandCTMControlResource::good() {
|
||||
return resource->resource();
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
||||
CHyprlandCTMControlProtocol::CHyprlandCTMControlProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
|
|
@ -87,24 +87,24 @@ CHyprlandCTMControlProtocol::CHyprlandCTMControlProtocol(const wl_interface* ifa
|
|||
}
|
||||
|
||||
void CHyprlandCTMControlProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CHyprlandCTMControlResource>(makeShared<CHyprlandCtmControlManagerV1>(client, ver, id)));
|
||||
const auto RESOURCE = m_managers.emplace_back(makeShared<CHyprlandCTMControlResource>(makeShared<CHyprlandCtmControlManagerV1>(client, ver, id)));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
wl_client_post_no_memory(client);
|
||||
m_vManagers.pop_back();
|
||||
m_managers.pop_back();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_pManager)
|
||||
if (m_manager)
|
||||
RESOURCE->block();
|
||||
else
|
||||
m_pManager = RESOURCE;
|
||||
m_manager = RESOURCE;
|
||||
|
||||
LOGM(LOG, "New CTM Manager at 0x{:x}", (uintptr_t)RESOURCE.get());
|
||||
}
|
||||
|
||||
void CHyprlandCTMControlProtocol::destroyResource(CHyprlandCTMControlResource* res) {
|
||||
std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == res; });
|
||||
std::erase_if(m_managers, [&](const auto& other) { return other.get() == res; });
|
||||
}
|
||||
|
||||
bool CHyprlandCTMControlProtocol::isCTMAnimationEnabled() {
|
||||
|
|
@ -129,12 +129,12 @@ void CHyprlandCTMControlProtocol::setCTM(PHLMONITOR monitor, const Mat3x3& ctm)
|
|||
return;
|
||||
}
|
||||
|
||||
std::erase_if(m_mCTMDatas, [](const auto& el) { return !el.first; });
|
||||
std::erase_if(m_ctmDatas, [](const auto& el) { return !el.first; });
|
||||
|
||||
if (!m_mCTMDatas.contains(monitor))
|
||||
m_mCTMDatas[monitor] = makeUnique<SCTMData>();
|
||||
if (!m_ctmDatas.contains(monitor))
|
||||
m_ctmDatas[monitor] = makeUnique<SCTMData>();
|
||||
|
||||
auto& data = m_mCTMDatas.at(monitor);
|
||||
auto& data = m_ctmDatas.at(monitor);
|
||||
|
||||
data->ctmFrom = data->ctmTo;
|
||||
data->ctmTo = ctm;
|
||||
|
|
@ -145,9 +145,9 @@ void CHyprlandCTMControlProtocol::setCTM(PHLMONITOR monitor, const Mat3x3& ctm)
|
|||
monitor->setCTM(data->ctmFrom);
|
||||
|
||||
data->progress->setUpdateCallback([monitor = PHLMONITORREF{monitor}, this](auto) {
|
||||
if (!monitor || !m_mCTMDatas.contains(monitor))
|
||||
if (!monitor || !m_ctmDatas.contains(monitor))
|
||||
return;
|
||||
auto& data = m_mCTMDatas.at(monitor);
|
||||
auto& data = m_ctmDatas.at(monitor);
|
||||
const auto from = data->ctmFrom.getMatrix();
|
||||
const auto to = data->ctmTo.getMatrix();
|
||||
const auto PROGRESS = data->progress->getPercent();
|
||||
|
|
@ -163,12 +163,12 @@ void CHyprlandCTMControlProtocol::setCTM(PHLMONITOR monitor, const Mat3x3& ctm)
|
|||
});
|
||||
|
||||
data->progress->setCallbackOnEnd([monitor = PHLMONITORREF{monitor}, this](auto) {
|
||||
if (!monitor || !m_mCTMDatas.contains(monitor)) {
|
||||
if (!monitor || !m_ctmDatas.contains(monitor)) {
|
||||
if (monitor)
|
||||
monitor->setCTM(Mat3x3::identity());
|
||||
return;
|
||||
}
|
||||
auto& data = m_mCTMDatas.at(monitor);
|
||||
auto& data = m_ctmDatas.at(monitor);
|
||||
monitor->setCTM(data->ctmTo);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue