mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-10 07:05:58 +01:00
add refreshrate or resolution preference
This commit is contained in:
parent
30d16373d0
commit
215125bd66
2 changed files with 32 additions and 15 deletions
|
@ -460,8 +460,10 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
|
||||||
|
|
||||||
if (curitem.find("pref") == 0) {
|
if (curitem.find("pref") == 0) {
|
||||||
newrule.resolution = Vector2D();
|
newrule.resolution = Vector2D();
|
||||||
} else if(curitem.find("high") == 0) {
|
} else if(curitem.find("highrr") == 0) {
|
||||||
newrule.resolution = Vector2D(-1,-1);
|
newrule.resolution = Vector2D(-1,-1);
|
||||||
|
} else if(curitem.find("highres") == 0) {
|
||||||
|
newrule.resolution = Vector2D(-1,-2);
|
||||||
} else {
|
} else {
|
||||||
newrule.resolution.x = stoi(curitem.substr(0, curitem.find_first_of('x')));
|
newrule.resolution.x = stoi(curitem.substr(0, curitem.find_first_of('x')));
|
||||||
newrule.resolution.y = stoi(curitem.substr(curitem.find_first_of('x') + 1, curitem.find_first_of('@')));
|
newrule.resolution.y = stoi(curitem.substr(curitem.find_first_of('x') + 1, curitem.find_first_of('@')));
|
||||||
|
|
|
@ -924,7 +924,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
pMonitor->vecPosition = pMonitorRule->offset;
|
pMonitor->vecPosition = pMonitorRule->offset;
|
||||||
|
|
||||||
// loop over modes and choose an appropriate one.
|
// loop over modes and choose an appropriate one.
|
||||||
if (pMonitorRule->resolution != Vector2D() && pMonitorRule->resolution != Vector2D(-1,-1)) {
|
if (pMonitorRule->resolution != Vector2D() && pMonitorRule->resolution != Vector2D(-1,-1) && pMonitorRule->resolution != Vector2D(-1,-2)) {
|
||||||
if (!wl_list_empty(&pMonitor->output->modes)) {
|
if (!wl_list_empty(&pMonitor->output->modes)) {
|
||||||
wlr_output_mode* mode;
|
wlr_output_mode* mode;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
@ -991,20 +991,35 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
float currentRefresh = 0;
|
float currentRefresh = 0;
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
wl_list_for_each(mode, &pMonitor->output->modes, link) {
|
//(-1,-1) indicates a preference to refreshrate over resolution, (-1,-2) preference to resolution
|
||||||
if(mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= currentRefresh) {
|
if(pMonitorRule->resolution == Vector2D(-1,-1)) {
|
||||||
wlr_output_set_mode(pMonitor->output, mode);
|
wl_list_for_each(mode, &pMonitor->output->modes, link) {
|
||||||
if (wlr_output_test(pMonitor->output)) {
|
if( ( mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= ( currentRefresh - 1000.f ) ) || mode->refresh > ( currentRefresh + 3000.f ) ) {
|
||||||
currentWidth = mode->width;
|
wlr_output_set_mode(pMonitor->output, mode);
|
||||||
currentHeight = mode->height;
|
if (wlr_output_test(pMonitor->output)) {
|
||||||
currentRefresh = mode->refresh;
|
currentWidth = mode->width;
|
||||||
success = true;
|
currentHeight = mode->height;
|
||||||
}
|
currentRefresh = mode->refresh;
|
||||||
}
|
success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wl_list_for_each(mode, &pMonitor->output->modes, link) {
|
||||||
|
if( ( mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= ( currentRefresh - 1000.f ) ) || ( mode->width > currentWidth && mode->height > currentHeight ) ) {
|
||||||
|
wlr_output_set_mode(pMonitor->output, mode);
|
||||||
|
if (wlr_output_test(pMonitor->output)) {
|
||||||
|
currentWidth = mode->width;
|
||||||
|
currentHeight = mode->height;
|
||||||
|
currentRefresh = mode->refresh;
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
Debug::log(LOG, "Monitor %s: REJECTED highest mode: %ix%i@%2f! Falling back to preferred.",
|
Debug::log(LOG, "Monitor %s: REJECTED mode: %ix%i@%2f! Falling back to preferred.",
|
||||||
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
|
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
|
||||||
mode->width, mode->height, mode->refresh / 1000.f);
|
mode->width, mode->height, mode->refresh / 1000.f);
|
||||||
|
|
||||||
|
@ -1027,8 +1042,8 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
|
pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Debug::log(LOG, "Monitor %s: Applying highest mode %ix%i@%imHz.",
|
Debug::log(LOG, "Monitor %s: Applying highest mode %ix%i@%2f.",
|
||||||
pMonitor->output->name, (int)currentWidth, (int)currentHeight, (int)currentRefresh,
|
pMonitor->output->name, (int)currentWidth, (int)currentHeight, (int)currentRefresh / 1000.f,
|
||||||
mode->width, mode->height, mode->refresh / 1000.f);
|
mode->width, mode->height, mode->refresh / 1000.f);
|
||||||
|
|
||||||
pMonitor->refreshRate = currentRefresh / 1000.f;
|
pMonitor->refreshRate = currentRefresh / 1000.f;
|
||||||
|
|
Loading…
Reference in a new issue