summaryrefslogtreecommitdiff
path: root/src/protocols/GammaControl.cpp
diff options
context:
space:
mode:
authordavc0n <dconti.dev@gmail.com>2025-05-04 00:13:29 +0200
committerGitHub <noreply@github.com>2025-05-04 00:13:29 +0200
commitadbae0f74d951e06c575bad3c81a944027dfe413 (patch)
tree4ae313af18629596c7e98518c7c1d2c10bc260a3 /src/protocols/GammaControl.cpp
parent46ac115bd19ee3aff5c816033de0b1d55a74e33f (diff)
protocols: refactor class member vars (a-m) (#10265)
Diffstat (limited to 'src/protocols/GammaControl.cpp')
-rw-r--r--src/protocols/GammaControl.cpp122
1 files changed, 61 insertions, 61 deletions
diff --git a/src/protocols/GammaControl.cpp b/src/protocols/GammaControl.cpp
index 1309ffc5..1d5b4fd5 100644
--- a/src/protocols/GammaControl.cpp
+++ b/src/protocols/GammaControl.cpp
@@ -6,7 +6,7 @@
#include "../render/Renderer.hpp"
using namespace Hyprutils::OS;
-CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* output) : resource(resource_) {
+CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* output) : m_resource(resource_) {
if UNLIKELY (!resource_->resource())
return;
@@ -14,144 +14,144 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
if UNLIKELY (!OUTPUTRES) {
LOGM(ERR, "No output in CGammaControl");
- resource->sendFailed();
+ m_resource->sendFailed();
return;
}
- pMonitor = OUTPUTRES->m_monitor;
+ m_monitor = OUTPUTRES->m_monitor;
- if UNLIKELY (!pMonitor || !pMonitor->m_output) {
+ if UNLIKELY (!m_monitor || !m_monitor->m_output) {
LOGM(ERR, "No CMonitor");
- resource->sendFailed();
+ m_resource->sendFailed();
return;
}
- for (auto const& g : PROTO::gamma->m_vGammaControllers) {
- if UNLIKELY (g->pMonitor == pMonitor) {
- resource->sendFailed();
+ for (auto const& g : PROTO::gamma->m_gammaControllers) {
+ if UNLIKELY (g->m_monitor == m_monitor) {
+ m_resource->sendFailed();
return;
}
}
- gammaSize = pMonitor->m_output->getGammaSize();
+ m_gammaSize = m_monitor->m_output->getGammaSize();
- if UNLIKELY (gammaSize <= 0) {
- LOGM(ERR, "Output {} doesn't support gamma", pMonitor->m_name);
- resource->sendFailed();
+ if UNLIKELY (m_gammaSize <= 0) {
+ LOGM(ERR, "Output {} doesn't support gamma", m_monitor->m_name);
+ m_resource->sendFailed();
return;
}
- gammaTable.resize(gammaSize * 3);
+ m_gammaTable.resize(m_gammaSize * 3);
- resource->setDestroy([this](CZwlrGammaControlV1* gamma) { PROTO::gamma->destroyGammaControl(this); });
- resource->setOnDestroy([this](CZwlrGammaControlV1* gamma) { PROTO::gamma->destroyGammaControl(this); });
+ m_resource->setDestroy([this](CZwlrGammaControlV1* gamma) { PROTO::gamma->destroyGammaControl(this); });
+ m_resource->setOnDestroy([this](CZwlrGammaControlV1* gamma) { PROTO::gamma->destroyGammaControl(this); });
- resource->setSetGamma([this](CZwlrGammaControlV1* gamma, int32_t fd) {
+ m_resource->setSetGamma([this](CZwlrGammaControlV1* gamma, int32_t fd) {
CFileDescriptor gammaFd{fd};
- if UNLIKELY (!pMonitor) {
+ if UNLIKELY (!m_monitor) {
LOGM(ERR, "setGamma for a dead monitor");
- resource->sendFailed();
+ m_resource->sendFailed();
return;
}
- LOGM(LOG, "setGamma for {}", pMonitor->m_name);
+ LOGM(LOG, "setGamma for {}", m_monitor->m_name);
// TODO: make CFileDescriptor getflags use F_GETFL
int fdFlags = fcntl(gammaFd.get(), F_GETFL, 0);
if UNLIKELY (fdFlags < 0) {
LOGM(ERR, "Failed to get fd flags");
- resource->sendFailed();
+ m_resource->sendFailed();
return;
}
// TODO: make CFileDescriptor setflags use F_SETFL
if UNLIKELY (fcntl(gammaFd.get(), F_SETFL, fdFlags | O_NONBLOCK) < 0) {
LOGM(ERR, "Failed to set fd flags");
- resource->sendFailed();
+ m_resource->sendFailed();
return;
}
- ssize_t readBytes = pread(gammaFd.get(), gammaTable.data(), gammaTable.size() * sizeof(uint16_t), 0);
- if (readBytes < 0 || (size_t)readBytes != gammaTable.size() * sizeof(uint16_t)) {
+ ssize_t readBytes = pread(gammaFd.get(), m_gammaTable.data(), m_gammaTable.size() * sizeof(uint16_t), 0);
+ if (readBytes < 0 || (size_t)readBytes != m_gammaTable.size() * sizeof(uint16_t)) {
LOGM(ERR, "Failed to read bytes");
- if ((size_t)readBytes != gammaTable.size() * sizeof(uint16_t)) {
+ if ((size_t)readBytes != m_gammaTable.size() * sizeof(uint16_t)) {
gamma->error(ZWLR_GAMMA_CONTROL_V1_ERROR_INVALID_GAMMA, "Gamma ramps size mismatch");
return;
}
- resource->sendFailed();
+ m_resource->sendFailed();
return;
}
- gammaTableSet = true;
+ m_gammaTableSet = true;
// translate the table to AQ format
std::vector<uint16_t> red, green, blue;
- red.resize(gammaTable.size() / 3);
- green.resize(gammaTable.size() / 3);
- blue.resize(gammaTable.size() / 3);
- for (size_t i = 0; i < gammaTable.size() / 3; ++i) {
- red.at(i) = gammaTable.at(i);
- green.at(i) = gammaTable.at(gammaTable.size() / 3 + i);
- blue.at(i) = gammaTable.at((gammaTable.size() / 3) * 2 + i);
+ red.resize(m_gammaTable.size() / 3);
+ green.resize(m_gammaTable.size() / 3);
+ blue.resize(m_gammaTable.size() / 3);
+ for (size_t i = 0; i < m_gammaTable.size() / 3; ++i) {
+ red.at(i) = m_gammaTable.at(i);
+ green.at(i) = m_gammaTable.at(m_gammaTable.size() / 3 + i);
+ blue.at(i) = m_gammaTable.at((m_gammaTable.size() / 3) * 2 + i);
}
- for (size_t i = 0; i < gammaTable.size() / 3; ++i) {
- gammaTable.at(i * 3) = red.at(i);
- gammaTable.at(i * 3 + 1) = green.at(i);
- gammaTable.at(i * 3 + 2) = blue.at(i);
+ for (size_t i = 0; i < m_gammaTable.size() / 3; ++i) {
+ m_gammaTable.at(i * 3) = red.at(i);
+ m_gammaTable.at(i * 3 + 1) = green.at(i);
+ m_gammaTable.at(i * 3 + 2) = blue.at(i);
}
applyToMonitor();
});
- resource->sendGammaSize(gammaSize);
+ m_resource->sendGammaSize(m_gammaSize);
- listeners.monitorDestroy = pMonitor->m_events.destroy.registerListener([this](std::any) { this->onMonitorDestroy(); });
- listeners.monitorDisconnect = pMonitor->m_events.disconnect.registerListener([this](std::any) { this->onMonitorDestroy(); });
+ m_listeners.monitorDestroy = m_monitor->m_events.destroy.registerListener([this](std::any) { this->onMonitorDestroy(); });
+ m_listeners.monitorDisconnect = m_monitor->m_events.disconnect.registerListener([this](std::any) { this->onMonitorDestroy(); });
}
CGammaControl::~CGammaControl() {
- if (!gammaTableSet || !pMonitor || !pMonitor->m_output)
+ if (!m_gammaTableSet || !m_monitor || !m_monitor->m_output)
return;
// reset the LUT if the client dies for whatever reason and doesn't unset the gamma
- pMonitor->m_output->state->setGammaLut({});
+ m_monitor->m_output->state->setGammaLut({});
}
bool CGammaControl::good() {
- return resource->resource();
+ return m_resource->resource();
}
void CGammaControl::applyToMonitor() {
- if UNLIKELY (!pMonitor || !pMonitor->m_output)
+ if UNLIKELY (!m_monitor || !m_monitor->m_output)
return; // ??
- LOGM(LOG, "setting to monitor {}", pMonitor->m_name);
+ LOGM(LOG, "setting to monitor {}", m_monitor->m_name);
- if (!gammaTableSet) {
- pMonitor->m_output->state->setGammaLut({});
+ if (!m_gammaTableSet) {
+ m_monitor->m_output->state->setGammaLut({});
return;
}
- pMonitor->m_output->state->setGammaLut(gammaTable);
+ m_monitor->m_output->state->setGammaLut(m_gammaTable);
- if (!pMonitor->m_state.test()) {
- LOGM(LOG, "setting to monitor {} failed", pMonitor->m_name);
- pMonitor->m_output->state->setGammaLut({});
+ if (!m_monitor->m_state.test()) {
+ LOGM(LOG, "setting to monitor {} failed", m_monitor->m_name);
+ m_monitor->m_output->state->setGammaLut({});
}
- g_pHyprRenderer->damageMonitor(pMonitor.lock());
+ g_pHyprRenderer->damageMonitor(m_monitor.lock());
}
PHLMONITOR CGammaControl::getMonitor() {
- return pMonitor ? pMonitor.lock() : nullptr;
+ return m_monitor ? m_monitor.lock() : nullptr;
}
void CGammaControl::onMonitorDestroy() {
- LOGM(LOG, "Destroying gamma control for {}", pMonitor->m_name);
- resource->sendFailed();
+ LOGM(LOG, "Destroying gamma control for {}", m_monitor->m_name);
+ m_resource->sendFailed();
}
CGammaControlProtocol::CGammaControlProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
@@ -159,7 +159,7 @@ CGammaControlProtocol::CGammaControlProtocol(const wl_interface* iface, const in
}
void CGammaControlProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
- const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CZwlrGammaControlManagerV1>(client, ver, id)).get();
+ const auto RESOURCE = m_managers.emplace_back(makeUnique<CZwlrGammaControlManagerV1>(client, ver, id)).get();
RESOURCE->setOnDestroy([this](CZwlrGammaControlManagerV1* p) { this->onManagerResourceDestroy(p->resource()); });
RESOURCE->setDestroy([this](CZwlrGammaControlManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
@@ -167,26 +167,26 @@ void CGammaControlProtocol::bindManager(wl_client* client, void* data, uint32_t
}
void CGammaControlProtocol::onManagerResourceDestroy(wl_resource* res) {
- std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; });
+ std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; });
}
void CGammaControlProtocol::destroyGammaControl(CGammaControl* gamma) {
- std::erase_if(m_vGammaControllers, [&](const auto& other) { return other.get() == gamma; });
+ std::erase_if(m_gammaControllers, [&](const auto& other) { return other.get() == gamma; });
}
void CGammaControlProtocol::onGetGammaControl(CZwlrGammaControlManagerV1* pMgr, uint32_t id, wl_resource* output) {
const auto CLIENT = pMgr->client();
- const auto RESOURCE = m_vGammaControllers.emplace_back(makeUnique<CGammaControl>(makeShared<CZwlrGammaControlV1>(CLIENT, pMgr->version(), id), output)).get();
+ const auto RESOURCE = m_gammaControllers.emplace_back(makeUnique<CGammaControl>(makeShared<CZwlrGammaControlV1>(CLIENT, pMgr->version(), id), output)).get();
if UNLIKELY (!RESOURCE->good()) {
pMgr->noMemory();
- m_vGammaControllers.pop_back();
+ m_gammaControllers.pop_back();
return;
}
}
void CGammaControlProtocol::applyGammaToState(PHLMONITOR pMonitor) {
- for (auto const& g : m_vGammaControllers) {
+ for (auto const& g : m_gammaControllers) {
if (g->getMonitor() != pMonitor)
continue;