summaryrefslogtreecommitdiff
path: root/src/protocols/GammaControl.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2024-07-21 13:09:54 +0200
committerGitHub <noreply@github.com>2024-07-21 13:09:54 +0200
commit016da234d0e852de3ef20eb2e89ac58d2a85f6e7 (patch)
tree496085987176551b0794fffc069877d44943e2f1 /src/protocols/GammaControl.cpp
parentf642fb97df5c69267a03452533de383ff8023570 (diff)
Core: Move to aquamarine (#6608)
Moves Hyprland from wlroots to aquamarine for the backend. --------- Signed-off-by: Vaxry <vaxry@vaxry.net> Co-authored-by: Mihai Fufezan <mihai@fufexan.net> Co-authored-by: Jan Beich <jbeich@FreeBSD.org> Co-authored-by: vaxerski <vaxerski@users.noreply.github.com> Co-authored-by: UjinT34 <41110182+UjinT34@users.noreply.github.com> Co-authored-by: Tom Englund <tomenglund26@gmail.com> Co-authored-by: Ikalco <73481042+ikalco@users.noreply.github.com> Co-authored-by: diniamo <diniamo53@gmail.com>
Diffstat (limited to 'src/protocols/GammaControl.cpp')
-rw-r--r--src/protocols/GammaControl.cpp32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/protocols/GammaControl.cpp b/src/protocols/GammaControl.cpp
index 7c3b39ce..494d9862 100644
--- a/src/protocols/GammaControl.cpp
+++ b/src/protocols/GammaControl.cpp
@@ -34,7 +34,7 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
}
}
- gammaSize = wlr_output_get_gamma_size(pMonitor->output);
+ gammaSize = pMonitor->output->getGammaSize();
if (gammaSize <= 0) {
LOGM(ERR, "Output {} doesn't support gamma", pMonitor->szName);
@@ -81,6 +81,24 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
gammaTableSet = true;
close(fd);
+
+ // 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);
+ }
+
+ 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);
+ }
+
applyToMonitor();
});
@@ -95,7 +113,7 @@ CGammaControl::~CGammaControl() {
return;
// reset the LUT if the client dies for whatever reason and doesn't unset the gamma
- wlr_output_state_set_gamma_lut(pMonitor->state.wlr(), 0, nullptr, nullptr, nullptr);
+ pMonitor->output->state->setGammaLut({});
}
bool CGammaControl::good() {
@@ -109,19 +127,15 @@ void CGammaControl::applyToMonitor() {
LOGM(LOG, "setting to monitor {}", pMonitor->szName);
if (!gammaTableSet) {
- wlr_output_state_set_gamma_lut(pMonitor->state.wlr(), 0, nullptr, nullptr, nullptr);
+ pMonitor->output->state->setGammaLut({});
return;
}
- uint16_t* red = &gammaTable.at(0);
- uint16_t* green = &gammaTable.at(gammaSize);
- uint16_t* blue = &gammaTable.at(gammaSize * 2);
-
- wlr_output_state_set_gamma_lut(pMonitor->state.wlr(), gammaSize, red, green, blue);
+ pMonitor->output->state->setGammaLut(gammaTable);
if (!pMonitor->state.test()) {
LOGM(LOG, "setting to monitor {} failed", pMonitor->szName);
- wlr_output_state_set_gamma_lut(pMonitor->state.wlr(), 0, nullptr, nullptr, nullptr);
+ pMonitor->output->state->setGammaLut({});
}
g_pHyprRenderer->damageMonitor(pMonitor);