deps: update wlroots

drops requirement for WLR_DRM_NO_ATOMIC provided kernel >= 6.8
This commit is contained in:
Vaxry 2024-01-27 13:58:13 +00:00
parent 12d79d6342
commit 7b3d039388
11 changed files with 93 additions and 84 deletions

View file

@ -115,7 +115,7 @@ void CCompositor::initServer() {
else else
wlr_log_init(WLR_ERROR, Debug::wlrLog); wlr_log_init(WLR_ERROR, Debug::wlrLog);
m_sWLRBackend = wlr_backend_autocreate(m_sWLDisplay, &m_sWLRSession); m_sWLRBackend = wlr_backend_autocreate(m_sWLEventLoop, &m_sWLRSession);
if (!m_sWLRBackend) { if (!m_sWLRBackend) {
Debug::log(CRIT, "m_sWLRBackend was NULL! This usually means wlroots could not find a GPU or enountered some issues."); Debug::log(CRIT, "m_sWLRBackend was NULL! This usually means wlroots could not find a GPU or enountered some issues.");
@ -239,7 +239,7 @@ void CCompositor::initServer() {
m_sWLRActivation = wlr_xdg_activation_v1_create(m_sWLDisplay); m_sWLRActivation = wlr_xdg_activation_v1_create(m_sWLDisplay);
m_sWLRHeadlessBackend = wlr_headless_backend_create(m_sWLDisplay); m_sWLRHeadlessBackend = wlr_headless_backend_create(m_sWLEventLoop);
m_sWLRSessionLockMgr = wlr_session_lock_manager_v1_create(m_sWLDisplay); m_sWLRSessionLockMgr = wlr_session_lock_manager_v1_create(m_sWLDisplay);
@ -395,8 +395,8 @@ void CCompositor::cleanup() {
for (auto& m : m_vMonitors) { for (auto& m : m_vMonitors) {
g_pHyprOpenGL->destroyMonitorResources(m.get()); g_pHyprOpenGL->destroyMonitorResources(m.get());
wlr_output_enable(m->output, false); wlr_output_state_set_enabled(&m->outputState, false);
wlr_output_commit(m->output); wlr_output_commit_state(m->output, &m->outputState);
} }
m_vMonitors.clear(); m_vMonitors.clear();
@ -2670,11 +2670,7 @@ int CCompositor::getNewSpecialID() {
} }
void CCompositor::performUserChecks() { void CCompositor::performUserChecks() {
if (g_pConfigManager->getInt("general:allow_tearing") == 1 && !envEnabled("WLR_DRM_NO_ATOMIC")) { ; // intentional
g_pHyprNotificationOverlay->addNotification("You have enabled tearing, but immediate presentations are not available on your configuration. Try adding "
"env = WLR_DRM_NO_ATOMIC,1 to your config.",
CColor(0), 15000, ICON_WARNING);
}
} }
void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorkspace) { void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorkspace) {

View file

@ -1061,7 +1061,7 @@ int CWindow::getRealBorderSize() {
} }
bool CWindow::canBeTorn() { bool CWindow::canBeTorn() {
return (m_sAdditionalConfigData.forceTearing.toUnderlying() || m_bTearingHint) && g_pHyprRenderer->m_bTearingEnvSatisfied; return (m_sAdditionalConfigData.forceTearing.toUnderlying() || m_bTearingHint);
} }
bool CWindow::shouldSendFullscreenState() { bool CWindow::shouldSendFullscreenState() {

View file

@ -2310,30 +2310,30 @@ void CConfigManager::ensureVRR(CMonitor* pMonitor) {
static auto* const PVRR = &getConfigValuePtr("misc:vrr")->intValue; static auto* const PVRR = &getConfigValuePtr("misc:vrr")->intValue;
static auto ensureVRRForDisplay = [&](CMonitor* m) -> void { static auto ensureVRRForDisplay = [&](CMonitor* m) -> void {
if (!m->output) if (!m->output || m->createdByUser)
return; return;
const auto USEVRR = m->activeMonitorRule.vrr.has_value() ? m->activeMonitorRule.vrr.value() : *PVRR; const auto USEVRR = m->activeMonitorRule.vrr.has_value() ? m->activeMonitorRule.vrr.value() : *PVRR;
if (USEVRR == 0) { if (USEVRR == 0) {
if (m->vrrActive) { if (m->vrrActive) {
wlr_output_enable_adaptive_sync(m->output, 0); wlr_output_state_set_adaptive_sync_enabled(&m->outputState, 0);
if (!wlr_output_commit(m->output)) if (!wlr_output_commit_state(m->output, &m->outputState))
Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> false", m->output->name); Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> false", m->output->name);
} }
m->vrrActive = false; m->vrrActive = false;
return; return;
} else if (USEVRR == 1) { } else if (USEVRR == 1) {
if (!m->vrrActive) { if (!m->vrrActive) {
wlr_output_enable_adaptive_sync(m->output, 1); wlr_output_state_set_adaptive_sync_enabled(&m->outputState, 1);
if (!wlr_output_test(m->output)) { if (!wlr_output_test_state(m->output, &m->outputState)) {
Debug::log(LOG, "Pending output {} does not accept VRR.", m->output->name); Debug::log(LOG, "Pending output {} does not accept VRR.", m->output->name);
wlr_output_enable_adaptive_sync(m->output, 0); wlr_output_state_set_adaptive_sync_enabled(&m->outputState, 0);
} }
if (!wlr_output_commit(m->output)) if (!wlr_output_commit_state(m->output, &m->outputState))
Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> true", m->output->name); Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> true", m->output->name);
} }
m->vrrActive = true; m->vrrActive = true;
@ -2350,20 +2350,20 @@ void CConfigManager::ensureVRR(CMonitor* pMonitor) {
const auto WORKSPACEFULL = PWORKSPACE->m_bHasFullscreenWindow && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL; const auto WORKSPACEFULL = PWORKSPACE->m_bHasFullscreenWindow && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL;
if (WORKSPACEFULL && m->output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_DISABLED) { if (WORKSPACEFULL && m->output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_DISABLED) {
wlr_output_enable_adaptive_sync(m->output, 1); wlr_output_state_set_adaptive_sync_enabled(&m->outputState, 1);
if (!wlr_output_test(m->output)) { if (!wlr_output_test_state(m->output, &m->outputState)) {
Debug::log(LOG, "Pending output {} does not accept VRR.", m->output->name); Debug::log(LOG, "Pending output {} does not accept VRR.", m->output->name);
wlr_output_enable_adaptive_sync(m->output, 0); wlr_output_state_set_adaptive_sync_enabled(&m->outputState, 0);
} }
if (!wlr_output_commit(m->output)) if (!wlr_output_commit_state(m->output, &m->outputState))
Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> true", m->output->name); Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> true", m->output->name);
} else if (!WORKSPACEFULL && m->output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED) { } else if (!WORKSPACEFULL && m->output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED) {
wlr_output_enable_adaptive_sync(m->output, 0); wlr_output_state_set_adaptive_sync_enabled(&m->outputState, 0);
if (!wlr_output_commit(m->output)) if (!wlr_output_commit_state(m->output, &m->outputState))
Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> false", m->output->name); Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> false", m->output->name);
} }
} }

View file

@ -175,11 +175,17 @@ void Events::listener_sessionActive(wl_listener* listener, void* data) {
void Events::listener_powerMgrSetMode(wl_listener* listener, void* data) { void Events::listener_powerMgrSetMode(wl_listener* listener, void* data) {
Debug::log(LOG, "PowerMgr set mode!"); Debug::log(LOG, "PowerMgr set mode!");
const auto EVENT = (wlr_output_power_v1_set_mode_event*)data; const auto EVENT = (wlr_output_power_v1_set_mode_event*)data;
const auto PMONITOR = g_pCompositor->getMonitorFromOutput(EVENT->output);
wlr_output_enable(EVENT->output, EVENT->mode == 1); if (!PMONITOR) {
Debug::log(ERR, "Invalid powerMgrSetMode output");
return;
}
if (!wlr_output_commit(EVENT->output)) wlr_output_state_set_enabled(&PMONITOR->outputState, EVENT->mode == 1);
if (!wlr_output_commit_state(EVENT->output, &PMONITOR->outputState))
Debug::log(ERR, "Couldn't set power mode"); Debug::log(ERR, "Couldn't set power mode");
} }

View file

@ -10,10 +10,12 @@ int ratHandler(void* data) {
CMonitor::CMonitor() { CMonitor::CMonitor() {
wlr_damage_ring_init(&damage); wlr_damage_ring_init(&damage);
wlr_output_state_init(&outputState);
} }
CMonitor::~CMonitor() { CMonitor::~CMonitor() {
wlr_damage_ring_finish(&damage); wlr_damage_ring_finish(&damage);
wlr_output_state_finish(&outputState);
hyprListener_monitorDestroy.removeCallback(); hyprListener_monitorDestroy.removeCallback();
hyprListener_monitorFrame.removeCallback(); hyprListener_monitorFrame.removeCallback();
@ -43,8 +45,8 @@ void CMonitor::onConnect(bool noRule) {
tearingState.canTear = wlr_backend_is_drm(output->backend); // tearing only works on drm tearingState.canTear = wlr_backend_is_drm(output->backend); // tearing only works on drm
if (m_bEnabled) { if (m_bEnabled) {
wlr_output_enable(output, 1); wlr_output_state_set_enabled(&outputState, true);
wlr_output_commit(output); wlr_output_commit_state(output, &outputState);
return; return;
} }
@ -63,8 +65,8 @@ void CMonitor::onConnect(bool noRule) {
// if it's disabled, disable and ignore // if it's disabled, disable and ignore
if (monitorRule.disabled) { if (monitorRule.disabled) {
wlr_output_set_scale(output, 1); wlr_output_state_set_scale(&outputState, 1);
wlr_output_set_transform(output, WL_OUTPUT_TRANSFORM_NORMAL); wlr_output_state_set_transform(&outputState, WL_OUTPUT_TRANSFORM_NORMAL);
auto PREFSTATE = wlr_output_preferred_mode(output); auto PREFSTATE = wlr_output_preferred_mode(output);
@ -72,9 +74,9 @@ void CMonitor::onConnect(bool noRule) {
wlr_output_mode* mode; wlr_output_mode* mode;
wl_list_for_each(mode, &output->modes, link) { wl_list_for_each(mode, &output->modes, link) {
wlr_output_set_mode(output, PREFSTATE); wlr_output_state_set_mode(&outputState, mode);
if (!wlr_output_test(output)) if (!wlr_output_test_state(output, &outputState))
continue; continue;
PREFSTATE = mode; PREFSTATE = mode;
@ -83,13 +85,13 @@ void CMonitor::onConnect(bool noRule) {
} }
if (PREFSTATE) if (PREFSTATE)
wlr_output_set_mode(output, PREFSTATE); wlr_output_state_set_mode(&outputState, PREFSTATE);
else else
Debug::log(WARN, "No mode found for disabled output {}", output->name); Debug::log(WARN, "No mode found for disabled output {}", output->name);
wlr_output_enable(output, 0); wlr_output_state_set_enabled(&outputState, 0);
if (!wlr_output_commit(output)) if (!wlr_output_commit_state(output, &outputState))
Debug::log(ERR, "Couldn't commit disabled state on output {}", output->name); Debug::log(ERR, "Couldn't commit disabled state on output {}", output->name);
m_bEnabled = false; m_bEnabled = false;
@ -130,13 +132,14 @@ void CMonitor::onConnect(bool noRule) {
m_bEnabled = true; m_bEnabled = true;
wlr_output_enable(output, 1); wlr_output_state_set_enabled(&outputState, 1);
// set mode, also applies // set mode, also applies
if (!noRule) if (!noRule)
g_pHyprRenderer->applyMonitorRule(this, &monitorRule, true); g_pHyprRenderer->applyMonitorRule(this, &monitorRule, true);
wlr_output_commit(output); if (!wlr_output_commit_state(output, &outputState))
Debug::log(WARN, "wlr_output_commit_state failed in CMonitor::onCommit");
wlr_damage_ring_set_bounds(&damage, vecTransformedSize.x, vecTransformedSize.y); wlr_damage_ring_set_bounds(&damage, vecTransformedSize.x, vecTransformedSize.y);
@ -283,9 +286,10 @@ void CMonitor::onDisconnect(bool destroy) {
if (!destroy) if (!destroy)
wlr_output_layout_remove(g_pCompositor->m_sWLROutputLayout, output); wlr_output_layout_remove(g_pCompositor->m_sWLROutputLayout, output);
wlr_output_enable(output, false); wlr_output_state_set_enabled(&outputState, false);
wlr_output_commit(output); if (!wlr_output_commit_state(output, &outputState))
Debug::log(WARN, "wlr_output_commit_state failed in CMonitor::onDisconnect");
if (g_pCompositor->m_pLastMonitor == this) if (g_pCompositor->m_pLastMonitor == this)
g_pCompositor->setActiveMonitor(BACKUPMON); g_pCompositor->setActiveMonitor(BACKUPMON);

View file

@ -63,6 +63,7 @@ class CMonitor {
bool gammaChanged = false; bool gammaChanged = false;
float xwaylandScale = 1.f; float xwaylandScale = 1.f;
std::array<float, 9> projMatrix = {0}; std::array<float, 9> projMatrix = {0};
wlr_output_state outputState = {0}; // TODO: write a wrapper for this garbage
bool dpmsStatus = true; bool dpmsStatus = true;
bool vrrActive = false; // this can be TRUE even if VRR is not active in the case that this display does not support it. bool vrrActive = false; // this can be TRUE even if VRR is not active in the case that this display does not support it.

View file

@ -1852,11 +1852,11 @@ void CKeybindManager::dpms(std::string arg) {
if (!port.empty() && m->szName != port) if (!port.empty() && m->szName != port)
continue; continue;
wlr_output_enable(m->output, enable); wlr_output_state_set_enabled(&m->outputState, enable);
m->dpmsStatus = enable; m->dpmsStatus = enable;
if (!wlr_output_commit(m->output)) { if (!wlr_output_commit_state(m->output, &m->outputState)) {
Debug::log(ERR, "Couldn't commit output {}", m->szName); Debug::log(ERR, "Couldn't commit output {}", m->szName);
} }

View file

@ -695,7 +695,8 @@ void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {
return; return;
} }
wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, e->time_msec, e->orientation, factor * e->delta, std::round(factor * e->delta_discrete), e->source); wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, e->time_msec, e->orientation, factor * e->delta, std::round(factor * e->delta_discrete), e->source,
WLR_AXIS_RELATIVE_DIRECTION_IDENTICAL);
} }
Vector2D CInputManager::getMouseCoordsInternal() { Vector2D CInputManager::getMouseCoordsInternal() {

View file

@ -9,8 +9,6 @@ extern "C" {
} }
CHyprRenderer::CHyprRenderer() { CHyprRenderer::CHyprRenderer() {
if (envEnabled("WLR_DRM_NO_ATOMIC"))
m_bTearingEnvSatisfied = true;
if (g_pCompositor->m_sWLRSession) { if (g_pCompositor->m_sWLRSession) {
wlr_device* dev; wlr_device* dev;
@ -905,9 +903,9 @@ bool CHyprRenderer::attemptDirectScanout(CMonitor* pMonitor) {
return false; return false;
// finally, we should be GTG. // finally, we should be GTG.
wlr_output_attach_buffer(pMonitor->output, &PSURFACE->buffer->base); wlr_output_state_set_buffer(&pMonitor->outputState, &PSURFACE->buffer->base);
if (!wlr_output_test(pMonitor->output)) if (!wlr_output_test_state(pMonitor->output, &pMonitor->outputState))
return false; return false;
timespec now; timespec now;
@ -915,7 +913,7 @@ bool CHyprRenderer::attemptDirectScanout(CMonitor* pMonitor) {
wlr_surface_send_frame_done(PSURFACE, &now); wlr_surface_send_frame_done(PSURFACE, &now);
wlr_presentation_surface_scanned_out_on_output(PSURFACE, pMonitor->output); wlr_presentation_surface_scanned_out_on_output(PSURFACE, pMonitor->output);
if (wlr_output_commit(pMonitor->output)) { if (wlr_output_commit_state(pMonitor->output, &pMonitor->outputState)) {
if (!m_pLastScanout) { if (!m_pLastScanout) {
m_pLastScanout = PCANDIDATE; m_pLastScanout = PCANDIDATE;
Debug::log(LOG, "Entered a direct scanout to {:x}: \"{}\"", (uintptr_t)PCANDIDATE, PCANDIDATE->m_szTitle); Debug::log(LOG, "Entered a direct scanout to {:x}: \"{}\"", (uintptr_t)PCANDIDATE, PCANDIDATE->m_szTitle);
@ -1016,14 +1014,15 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
const auto PGAMMACTRL = wlr_gamma_control_manager_v1_get_control(g_pCompositor->m_sWLRGammaCtrlMgr, pMonitor->output); const auto PGAMMACTRL = wlr_gamma_control_manager_v1_get_control(g_pCompositor->m_sWLRGammaCtrlMgr, pMonitor->output);
if (!wlr_gamma_control_v1_apply(PGAMMACTRL, &pMonitor->output->pending)) { if (!wlr_gamma_control_v1_apply(PGAMMACTRL, &pMonitor->outputState)) {
Debug::log(ERR, "Could not apply gamma control to {}", pMonitor->szName); Debug::log(ERR, "Could not apply gamma control to {}", pMonitor->szName);
return; return;
} }
if (!wlr_output_test(pMonitor->output)) { if (!wlr_output_test_state(pMonitor->output, &pMonitor->outputState)) {
Debug::log(ERR, "Output test failed for setting gamma to {}", pMonitor->szName); Debug::log(ERR, "Output test failed for setting gamma to {}", pMonitor->szName);
wlr_output_rollback(pMonitor->output); // aka rollback
wlr_gamma_control_v1_apply(nullptr, &pMonitor->outputState);
wlr_gamma_control_v1_send_failed_and_destroy(PGAMMACTRL); wlr_gamma_control_v1_send_failed_and_destroy(PGAMMACTRL);
} }
} }
@ -1238,9 +1237,9 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
EMIT_HOOK_EVENT("render", RENDER_POST); EMIT_HOOK_EVENT("render", RENDER_POST);
pMonitor->output->pending.tearing_page_flip = shouldTear; pMonitor->outputState.tearing_page_flip = shouldTear;
if (!wlr_output_commit(pMonitor->output)) { if (!wlr_output_commit_state(pMonitor->output, &pMonitor->outputState)) {
if (UNLOCK_SC) if (UNLOCK_SC)
wlr_output_lock_software_cursors(pMonitor->output, false); wlr_output_lock_software_cursors(pMonitor->output, false);
@ -1327,6 +1326,8 @@ void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool
std::string commandForCfg = ""; std::string commandForCfg = "";
const auto OUTPUT = head->state.output; const auto OUTPUT = head->state.output;
const auto PMONITOR = g_pCompositor->getMonitorFromOutput(OUTPUT);
RASSERT(PMONITOR, "nullptr monitor in outputMgrApplyTest");
commandForCfg += std::string(OUTPUT->name) + ","; commandForCfg += std::string(OUTPUT->name) + ",";
@ -1337,7 +1338,7 @@ void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool
continue; continue;
} }
wlr_output_enable(OUTPUT, head->state.enabled); wlr_output_state_set_enabled(&PMONITOR->outputState, head->state.enabled);
if (head->state.mode) if (head->state.mode)
commandForCfg += commandForCfg +=
@ -1351,10 +1352,10 @@ void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool
if (!test) { if (!test) {
g_pConfigManager->parseKeyword("monitor", commandForCfg, true); g_pConfigManager->parseKeyword("monitor", commandForCfg, true);
wlr_output_state_set_adaptive_sync_enabled(&OUTPUT->pending, head->state.adaptive_sync_enabled); wlr_output_state_set_adaptive_sync_enabled(&PMONITOR->outputState, head->state.adaptive_sync_enabled);
} }
ok = wlr_output_test(OUTPUT); ok = wlr_output_test_state(OUTPUT, &PMONITOR->outputState);
if (!ok) if (!ok)
break; break;
@ -1764,10 +1765,10 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
pMonitor->scale = DEFAULTSCALE; pMonitor->scale = DEFAULTSCALE;
} }
wlr_output_set_scale(pMonitor->output, pMonitor->scale); wlr_output_state_set_scale(&pMonitor->outputState, pMonitor->scale);
pMonitor->setScale = pMonitor->scale; pMonitor->setScale = pMonitor->scale;
wlr_output_set_transform(pMonitor->output, pMonitorRule->transform); wlr_output_state_set_transform(&pMonitor->outputState, pMonitorRule->transform);
pMonitor->transform = pMonitorRule->transform; pMonitor->transform = pMonitorRule->transform;
const auto WLRREFRESHRATE = (wlr_backend_is_wl(pMonitor->output->backend) || wlr_backend_is_x11(pMonitor->output->backend)) ? 0 : pMonitorRule->refreshRate * 1000; const auto WLRREFRESHRATE = (wlr_backend_is_wl(pMonitor->output->backend) || wlr_backend_is_x11(pMonitor->output->backend)) ? 0 : pMonitorRule->refreshRate * 1000;
@ -1782,9 +1783,9 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
// if delta of refresh rate, w and h chosen and mode is < 1 we accept it // if delta of refresh rate, w and h chosen and mode is < 1 we accept it
if (DELTALESSTHAN(mode->width, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(mode->height, pMonitorRule->resolution.y, 1) && if (DELTALESSTHAN(mode->width, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(mode->height, pMonitorRule->resolution.y, 1) &&
DELTALESSTHAN(mode->refresh / 1000.f, pMonitorRule->refreshRate, 1)) { DELTALESSTHAN(mode->refresh / 1000.f, pMonitorRule->refreshRate, 1)) {
wlr_output_set_mode(pMonitor->output, mode); wlr_output_state_set_mode(&pMonitor->outputState, mode);
if (!wlr_output_test(pMonitor->output)) { if (!wlr_output_test_state(pMonitor->output, &pMonitor->outputState)) {
Debug::log(LOG, "Monitor {}: REJECTED available mode: {}x{}@{:2f}!", pMonitor->output->name, mode->width, mode->height, mode->refresh / 1000.f); Debug::log(LOG, "Monitor {}: REJECTED available mode: {}x{}@{:2f}!", pMonitor->output->name, mode->width, mode->height, mode->refresh / 1000.f);
continue; continue;
} }
@ -1802,11 +1803,11 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
} }
if (!found) { if (!found) {
wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, WLRREFRESHRATE); wlr_output_state_set_custom_mode(&pMonitor->outputState, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, WLRREFRESHRATE);
pMonitor->vecSize = pMonitorRule->resolution; pMonitor->vecSize = pMonitorRule->resolution;
pMonitor->refreshRate = pMonitorRule->refreshRate; pMonitor->refreshRate = pMonitorRule->refreshRate;
if (!wlr_output_test(pMonitor->output)) { if (!wlr_output_test_state(pMonitor->output, &pMonitor->outputState)) {
Debug::log(ERR, "Custom resolution FAILED, falling back to preferred"); Debug::log(ERR, "Custom resolution FAILED, falling back to preferred");
const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output); const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output);
@ -1818,7 +1819,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
} }
// Preferred is valid // Preferred is valid
wlr_output_set_mode(pMonitor->output, PREFERREDMODE); wlr_output_state_set_mode(&pMonitor->outputState, PREFERREDMODE);
Debug::log(ERR, "Monitor {} got an invalid requested mode: {:X0}@{:2f}, using the preferred one instead: {}x{}@{:2f}", pMonitor->output->name, Debug::log(ERR, "Monitor {} got an invalid requested mode: {:X0}@{:2f}, using the preferred one instead: {}x{}@{:2f}", pMonitor->output->name,
pMonitorRule->resolution, (float)pMonitorRule->refreshRate, PREFERREDMODE->width, PREFERREDMODE->height, PREFERREDMODE->refresh / 1000.f); pMonitorRule->resolution, (float)pMonitorRule->refreshRate, PREFERREDMODE->width, PREFERREDMODE->height, PREFERREDMODE->refresh / 1000.f);
@ -1840,7 +1841,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
} else { } else {
auto* mode = wlr_drm_connector_add_mode(pMonitor->output, &pMonitorRule->drmMode); auto* mode = wlr_drm_connector_add_mode(pMonitor->output, &pMonitorRule->drmMode);
if (mode) { if (mode) {
wlr_output_set_mode(pMonitor->output, mode); wlr_output_state_set_mode(&pMonitor->outputState, mode);
pMonitor->customDrmMode = pMonitorRule->drmMode; pMonitor->customDrmMode = pMonitorRule->drmMode;
} else { } else {
Debug::log(ERR, "wlr_drm_connector_add_mode failed"); Debug::log(ERR, "wlr_drm_connector_add_mode failed");
@ -1848,13 +1849,13 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
} }
} }
} else { } else {
wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, WLRREFRESHRATE); wlr_output_state_set_custom_mode(&pMonitor->outputState, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, WLRREFRESHRATE);
} }
pMonitor->vecSize = pMonitorRule->resolution; pMonitor->vecSize = pMonitorRule->resolution;
pMonitor->refreshRate = pMonitorRule->refreshRate; pMonitor->refreshRate = pMonitorRule->refreshRate;
if (fail || !wlr_output_test(pMonitor->output)) { if (fail || !wlr_output_test_state(pMonitor->output, &pMonitor->outputState)) {
Debug::log(ERR, "Custom resolution FAILED, falling back to preferred"); Debug::log(ERR, "Custom resolution FAILED, falling back to preferred");
const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output); const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output);
@ -1866,7 +1867,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
} }
// Preferred is valid // Preferred is valid
wlr_output_set_mode(pMonitor->output, PREFERREDMODE); wlr_output_state_set_mode(&pMonitor->outputState, PREFERREDMODE);
Debug::log(ERR, "Monitor {} got an invalid requested mode: {:X0}@{:2f}, using the preferred one instead: {}x{}@{:2f}", pMonitor->output->name, Debug::log(ERR, "Monitor {} got an invalid requested mode: {:X0}@{:2f}, using the preferred one instead: {}x{}@{:2f}", pMonitor->output->name,
pMonitorRule->resolution, (float)pMonitorRule->refreshRate, PREFERREDMODE->width, PREFERREDMODE->height, PREFERREDMODE->refresh / 1000.f); pMonitorRule->resolution, (float)pMonitorRule->refreshRate, PREFERREDMODE->width, PREFERREDMODE->height, PREFERREDMODE->refresh / 1000.f);
@ -1890,8 +1891,8 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
if (pMonitorRule->resolution == Vector2D(-1, -1)) { if (pMonitorRule->resolution == Vector2D(-1, -1)) {
wl_list_for_each(mode, &pMonitor->output->modes, link) { wl_list_for_each(mode, &pMonitor->output->modes, link) {
if ((mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= (currentRefresh - 1000.f)) || mode->refresh > (currentRefresh + 3000.f)) { if ((mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= (currentRefresh - 1000.f)) || mode->refresh > (currentRefresh + 3000.f)) {
wlr_output_set_mode(pMonitor->output, mode); wlr_output_state_set_mode(&pMonitor->outputState, mode);
if (wlr_output_test(pMonitor->output)) { if (wlr_output_test_state(pMonitor->output, &pMonitor->outputState)) {
currentWidth = mode->width; currentWidth = mode->width;
currentHeight = mode->height; currentHeight = mode->height;
currentRefresh = mode->refresh; currentRefresh = mode->refresh;
@ -1903,8 +1904,8 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
wl_list_for_each(mode, &pMonitor->output->modes, link) { wl_list_for_each(mode, &pMonitor->output->modes, link) {
if ((mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= (currentRefresh - 1000.f)) || if ((mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= (currentRefresh - 1000.f)) ||
(mode->width > currentWidth && mode->height > currentHeight)) { (mode->width > currentWidth && mode->height > currentHeight)) {
wlr_output_set_mode(pMonitor->output, mode); wlr_output_state_set_mode(&pMonitor->outputState, mode);
if (wlr_output_test(pMonitor->output)) { if (wlr_output_test_state(pMonitor->output, &pMonitor->outputState)) {
currentWidth = mode->width; currentWidth = mode->width;
currentHeight = mode->height; currentHeight = mode->height;
currentRefresh = mode->refresh; currentRefresh = mode->refresh;
@ -1927,7 +1928,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
} }
// Preferred is valid // Preferred is valid
wlr_output_set_mode(pMonitor->output, PREFERREDMODE); wlr_output_state_set_mode(&pMonitor->outputState, PREFERREDMODE);
Debug::log(ERR, "Monitor {} got an invalid requested mode: {:X0}@{:2f}, using the preferred one instead: {}x{}@{:2f}", pMonitor->output->name, Debug::log(ERR, "Monitor {} got an invalid requested mode: {:X0}@{:2f}, using the preferred one instead: {}x{}@{:2f}", pMonitor->output->name,
pMonitorRule->resolution, (float)pMonitorRule->refreshRate, PREFERREDMODE->width, PREFERREDMODE->height, PREFERREDMODE->refresh / 1000.f); pMonitorRule->resolution, (float)pMonitorRule->refreshRate, PREFERREDMODE->width, PREFERREDMODE->height, PREFERREDMODE->refresh / 1000.f);
@ -1952,9 +1953,9 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
wlr_output_mode* mode; wlr_output_mode* mode;
wl_list_for_each(mode, &pMonitor->output->modes, link) { wl_list_for_each(mode, &pMonitor->output->modes, link) {
wlr_output_set_mode(pMonitor->output, mode); wlr_output_state_set_mode(&pMonitor->outputState, mode);
if (!wlr_output_test(pMonitor->output)) { if (!wlr_output_test_state(pMonitor->output, &pMonitor->outputState)) {
Debug::log(LOG, "Monitor {}: REJECTED available mode: {}x{}@{:2f}!", pMonitor->output->name, mode->width, mode->height, mode->refresh / 1000.f); Debug::log(LOG, "Monitor {}: REJECTED available mode: {}x{}@{:2f}!", pMonitor->output->name, mode->width, mode->height, mode->refresh / 1000.f);
continue; continue;
} }
@ -1970,7 +1971,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
} }
} else { } else {
// Preferred is valid // Preferred is valid
wlr_output_set_mode(pMonitor->output, PREFERREDMODE); wlr_output_state_set_mode(&pMonitor->outputState, PREFERREDMODE);
pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height); pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
pMonitor->refreshRate = PREFERREDMODE->refresh / 1000.f; pMonitor->refreshRate = PREFERREDMODE->refresh / 1000.f;
@ -1979,7 +1980,8 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
} }
} }
pMonitor->vrrActive = pMonitor->output->pending.adaptive_sync_enabled; // disabled here, will be tested in CConfigManager::ensureVRR() pMonitor->vrrActive = pMonitor->outputState.adaptive_sync_enabled // disabled here, will be tested in CConfigManager::ensureVRR()
|| pMonitor->createdByUser; // wayland backend doesn't allow for disabling adaptive_sync
pMonitor->vecPixelSize = pMonitor->vecSize; pMonitor->vecPixelSize = pMonitor->vecSize;
@ -1996,7 +1998,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
Vector2D logicalZero = pMonitor->vecPixelSize / scaleZero; Vector2D logicalZero = pMonitor->vecPixelSize / scaleZero;
if (logicalZero == logicalZero.round()) { if (logicalZero == logicalZero.round()) {
pMonitor->scale = scaleZero; pMonitor->scale = scaleZero;
wlr_output_set_scale(pMonitor->output, pMonitor->scale); wlr_output_state_set_scale(&pMonitor->outputState, pMonitor->scale);
} else { } else {
for (size_t i = 1; i < 90; ++i) { for (size_t i = 1; i < 90; ++i) {
double scaleUp = (searchScale + i) / 120.0; double scaleUp = (searchScale + i) / 120.0;
@ -2039,7 +2041,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
double logicalX = std::round(pMonitor->vecPixelSize.x / pMonitor->scale); double logicalX = std::round(pMonitor->vecPixelSize.x / pMonitor->scale);
logicalX += 0.1; logicalX += 0.1;
wlr_output_set_scale(pMonitor->output, pMonitor->vecPixelSize.x / logicalX); wlr_output_state_set_scale(&pMonitor->outputState, pMonitor->vecPixelSize.x / logicalX);
} }
} }
@ -2058,9 +2060,9 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
pMonitor->drmFormat = DRM_FORMAT_INVALID; pMonitor->drmFormat = DRM_FORMAT_INVALID;
for (auto& fmt : formats[(int)!pMonitorRule->enable10bit]) { for (auto& fmt : formats[(int)!pMonitorRule->enable10bit]) {
wlr_output_set_render_format(pMonitor->output, fmt.second); wlr_output_state_set_render_format(&pMonitor->outputState, fmt.second);
if (!wlr_output_test(pMonitor->output)) { if (!wlr_output_test_state(pMonitor->output, &pMonitor->outputState)) {
Debug::log(ERR, "output {} failed basic test on format {}", pMonitor->szName, fmt.first); Debug::log(ERR, "output {} failed basic test on format {}", pMonitor->szName, fmt.first);
} else { } else {
Debug::log(LOG, "output {} succeeded basic test on format {}", pMonitor->szName, fmt.first); Debug::log(LOG, "output {} succeeded basic test on format {}", pMonitor->szName, fmt.first);
@ -2074,7 +2076,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
pMonitor->enabled10bit = set10bit; pMonitor->enabled10bit = set10bit;
if (!wlr_output_commit(pMonitor->output)) { if (!wlr_output_commit_state(pMonitor->output, &pMonitor->outputState)) {
Debug::log(ERR, "Couldn't commit output named {}", pMonitor->output->name); Debug::log(ERR, "Couldn't commit output named {}", pMonitor->output->name);
} }
@ -2441,7 +2443,7 @@ bool CHyprRenderer::beginRender(CMonitor* pMonitor, CRegion& damage, eRenderMode
} }
if (!buffer) { if (!buffer) {
if (!wlr_output_configure_primary_swapchain(pMonitor->output, &pMonitor->output->pending, &pMonitor->output->swapchain)) if (!wlr_output_configure_primary_swapchain(pMonitor->output, &pMonitor->outputState, &pMonitor->output->swapchain))
return false; return false;
m_pCurrentWlrBuffer = wlr_swapchain_acquire(pMonitor->output->swapchain, &m_iLastBufferAge); m_pCurrentWlrBuffer = wlr_swapchain_acquire(pMonitor->output->swapchain, &m_iLastBufferAge);
@ -2485,7 +2487,7 @@ void CHyprRenderer::endRender() {
glFlush(); glFlush();
if (m_eRenderMode == RENDER_MODE_NORMAL) { if (m_eRenderMode == RENDER_MODE_NORMAL) {
wlr_output_state_set_buffer(&PMONITOR->output->pending, m_pCurrentWlrBuffer); wlr_output_state_set_buffer(&PMONITOR->outputState, m_pCurrentWlrBuffer);
unsetEGL(); // flush the context unsetEGL(); // flush the context
} }

View file

@ -82,7 +82,6 @@ class CHyprRenderer {
CMonitor* m_pMostHzMonitor = nullptr; CMonitor* m_pMostHzMonitor = nullptr;
bool m_bDirectScanoutBlocked = false; bool m_bDirectScanoutBlocked = false;
bool m_bSoftwareCursorsLocked = false; bool m_bSoftwareCursorsLocked = false;
bool m_bTearingEnvSatisfied = false;
DAMAGETRACKINGMODES DAMAGETRACKINGMODES
damageTrackingModeFromStr(const std::string&); damageTrackingModeFromStr(const std::string&);

@ -1 +1 @@
Subproject commit f81c3d93cd6f61b20ae784297679283438def8df Subproject commit 00b869c1a96f300a8f25da95d624524895e0ddf2