config: add vrr per-display

This commit is contained in:
Vaxry 2023-08-11 17:37:52 +02:00
parent 8a7ce59ad4
commit 3f7f4207a6
4 changed files with 28 additions and 17 deletions

View file

@ -660,6 +660,9 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
} else if (ARGS[argno] == "transform") { } else if (ARGS[argno] == "transform") {
newrule.transform = (wl_output_transform)std::stoi(ARGS[argno + 1]); newrule.transform = (wl_output_transform)std::stoi(ARGS[argno + 1]);
argno++; argno++;
} else if (ARGS[argno] == "vrr") {
newrule.vrr = std::stoi(ARGS[argno + 1]);
argno++;
} else if (ARGS[argno] == "workspace") { } else if (ARGS[argno] == "workspace") {
std::string name = ""; std::string name = "";
int wsId = getWorkspaceIDFromString(ARGS[argno + 1], name); int wsId = getWorkspaceIDFromString(ARGS[argno + 1], name);
@ -2070,7 +2073,9 @@ void CConfigManager::ensureVRR(CMonitor* pMonitor) {
if (!m->output) if (!m->output)
return; return;
if (*PVRR == 0) { const auto USEVRR = m->activeMonitorRule.vrr.has_value() ? m->activeMonitorRule.vrr.value() : *PVRR;
if (USEVRR == 0) {
if (m->vrrActive) { if (m->vrrActive) {
wlr_output_enable_adaptive_sync(m->output, 0); wlr_output_enable_adaptive_sync(m->output, 0);
@ -2080,7 +2085,7 @@ void CConfigManager::ensureVRR(CMonitor* pMonitor) {
} }
m->vrrActive = false; m->vrrActive = false;
return; return;
} else if (*PVRR == 1) { } else if (USEVRR == 1) {
if (!m->vrrActive) { if (!m->vrrActive) {
wlr_output_enable_adaptive_sync(m->output, 1); wlr_output_enable_adaptive_sync(m->output, 1);
@ -2095,7 +2100,7 @@ void CConfigManager::ensureVRR(CMonitor* pMonitor) {
} }
m->vrrActive = true; m->vrrActive = true;
return; return;
} else if (*PVRR == 2) { } else if (USEVRR == 2) {
/* fullscreen */ /* fullscreen */
m->vrrActive = true; m->vrrActive = true;

View file

@ -14,6 +14,7 @@
#include <xf86drmMode.h> #include <xf86drmMode.h>
#include "../Window.hpp" #include "../Window.hpp"
#include "../helpers/WLClasses.hpp" #include "../helpers/WLClasses.hpp"
#include "../helpers/Monitor.hpp"
#include "defaultConfig.hpp" #include "defaultConfig.hpp"
#include "ConfigDataValues.hpp" #include "ConfigDataValues.hpp"
@ -35,19 +36,6 @@ struct SConfigValue {
bool set = false; // used for device configs bool set = false; // used for device configs
}; };
struct SMonitorRule {
std::string name = "";
Vector2D resolution = Vector2D(1280, 720);
Vector2D offset = Vector2D(0, 0);
float scale = 1;
float refreshRate = 60;
bool disabled = false;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
std::string mirrorOf = "";
bool enable10bit = false;
drmModeModeInfo drmMode = {};
};
struct SWorkspaceRule { struct SWorkspaceRule {
std::string monitor = ""; std::string monitor = "";
std::string workspaceString = ""; std::string workspaceString = "";

View file

@ -9,8 +9,21 @@
#include <xf86drmMode.h> #include <xf86drmMode.h>
#include "Timer.hpp" #include "Timer.hpp"
#include "Region.hpp" #include "Region.hpp"
#include <optional>
struct SMonitorRule; struct SMonitorRule {
std::string name = "";
Vector2D resolution = Vector2D(1280, 720);
Vector2D offset = Vector2D(0, 0);
float scale = 1;
float refreshRate = 60;
bool disabled = false;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
std::string mirrorOf = "";
bool enable10bit = false;
drmModeModeInfo drmMode = {};
std::optional<int> vrr;
};
class CMonitor { class CMonitor {
public: public:
@ -58,6 +71,8 @@ class CMonitor {
bool RATScheduled = false; bool RATScheduled = false;
CTimer lastPresentationTimer; CTimer lastPresentationTimer;
SMonitorRule activeMonitorRule;
// mirroring // mirroring
CMonitor* pMirrorOf = nullptr; CMonitor* pMirrorOf = nullptr;
std::vector<CMonitor*> mirrors; std::vector<CMonitor*> mirrors;

View file

@ -1568,6 +1568,8 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
Debug::log(LOG, "Applying monitor rule for %s", pMonitor->szName.c_str()); Debug::log(LOG, "Applying monitor rule for %s", pMonitor->szName.c_str());
pMonitor->activeMonitorRule = *pMonitorRule;
// if it's disabled, disable and ignore // if it's disabled, disable and ignore
if (pMonitorRule->disabled) { if (pMonitorRule->disabled) {
@ -1587,6 +1589,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
} }
// Check if the rule isn't already applied // Check if the rule isn't already applied
// TODO: clean this up lol
if (!force && DELTALESSTHAN(pMonitor->vecPixelSize.x, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(pMonitor->vecPixelSize.y, pMonitorRule->resolution.y, 1) && if (!force && DELTALESSTHAN(pMonitor->vecPixelSize.x, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(pMonitor->vecPixelSize.y, pMonitorRule->resolution.y, 1) &&
DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1) && pMonitor->scale == pMonitorRule->scale && DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1) && pMonitor->scale == pMonitorRule->scale &&
((DELTALESSTHAN(pMonitor->vecPosition.x, pMonitorRule->offset.x, 1) && DELTALESSTHAN(pMonitor->vecPosition.y, pMonitorRule->offset.y, 1)) || ((DELTALESSTHAN(pMonitor->vecPosition.x, pMonitorRule->offset.x, 1) && DELTALESSTHAN(pMonitor->vecPosition.y, pMonitorRule->offset.y, 1)) ||