gamma-control: move to new impl

This commit is contained in:
Vaxry 2024-04-22 18:21:03 +01:00
parent dafc9ed4eb
commit 741c75d907
13 changed files with 383 additions and 48 deletions

View file

@ -1,10 +1,8 @@
#include "Monitor.hpp"
#include "MiscFunctions.hpp"
#include "../Compositor.hpp"
#include "../config/ConfigValue.hpp"
#include "../protocols/GammaControl.hpp"
int ratHandler(void* data) {
g_pHyprRenderer->renderMonitor((CMonitor*)data);
@ -26,6 +24,8 @@ CMonitor::~CMonitor() {
hyprListener_monitorNeedsFrame.removeCallback();
hyprListener_monitorCommit.removeCallback();
hyprListener_monitorBind.removeCallback();
events.destroy.emit();
}
void CMonitor::onConnect(bool noRule) {
@ -214,6 +214,10 @@ void CMonitor::onConnect(bool noRule) {
renderTimer = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, ratHandler, this);
g_pCompositor->scheduleFrameForMonitor(this);
PROTO::gamma->applyGammaToState(this);
events.connect.emit();
}
void CMonitor::onDisconnect(bool destroy) {
@ -228,6 +232,8 @@ void CMonitor::onDisconnect(bool destroy) {
Debug::log(LOG, "onDisconnect called for {}", output->name);
events.disconnect.emit();
// Cleanup everything. Move windows back, snap cursor, shit.
CMonitor* BACKUPMON = nullptr;
for (auto& m : g_pCompositor->m_vMonitors) {

View file

@ -11,6 +11,8 @@
#include "Region.hpp"
#include <optional>
#include "signal/Signal.hpp"
struct SMonitorRule {
std::string name = "";
Vector2D resolution = Vector2D(1280, 720);
@ -83,7 +85,6 @@ class CMonitor {
bool noFrameSchedule = false;
bool scheduledRecalc = false;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
bool gammaChanged = false;
float xwaylandScale = 1.f;
std::array<float, 9> projMatrix = {0};
std::optional<Vector2D> forceSize;
@ -120,6 +121,12 @@ class CMonitor {
bool frameScheduledWhileBusy = false;
} tearingState;
struct {
CSignal destroy;
CSignal connect;
CSignal disconnect;
} events;
std::array<std::vector<std::unique_ptr<SLayerSurface>>, 4> m_aLayerSurfaceLayers;
DYNLISTENER(monitorFrame);