fix monitor reload crash

This commit is contained in:
vaxerski 2022-04-21 18:11:28 +02:00
parent 7c36dd6e6c
commit 5fa916e6f2
3 changed files with 27 additions and 1 deletions

View file

@ -139,6 +139,13 @@ void Events::listener_monitorFrame(void* owner, void* data) {
g_pConfigManager->performMonitorReload();
}
if (PMONITOR->needsFrameSkip) {
PMONITOR->needsFrameSkip = false;
wlr_output_schedule_frame(PMONITOR->output);
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID);
return;
}
timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);

View file

@ -25,6 +25,7 @@ struct SMonitor {
wlr_output* output = nullptr;
float refreshRate = 60;
wlr_output_damage* damage = nullptr;
bool needsFrameSkip = false;
// Double-linked list because we need to have constant mem addresses for signals
// We have to store pointers and use raw new/delete because they might be moved between them
@ -33,6 +34,7 @@ struct SMonitor {
DYNLISTENER(monitorFrame);
DYNLISTENER(monitorDestroy);
DYNLISTENER(monitorMode);
// hack: a group = workspaces on a monitor.
// I don't really care lol :P

View file

@ -494,6 +494,8 @@ DAMAGETRACKINGMODES CHyprRenderer::damageTrackingModeFromStr(const std::string&
void CHyprRenderer::applyMonitorRule(SMonitor* pMonitor, SMonitorRule* pMonitorRule, bool force) {
Debug::log(LOG, "Applying monitor rule for %s", pMonitor->szName.c_str());
// Check if the rule isn't already applied
if (!force && DELTALESSTHAN(pMonitor->vecSize.x, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(pMonitor->vecSize.y, pMonitorRule->resolution.y, 1) && DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1) && pMonitor->scale == pMonitorRule->scale) {
Debug::log(LOG, "Not applying a new rule to %s because it's already applied!", pMonitor->szName.c_str());
@ -563,4 +565,19 @@ void CHyprRenderer::applyMonitorRule(SMonitor* pMonitor, SMonitorRule* pMonitorR
Debug::log(ERR, "Couldn't commit output named %s", pMonitor->output->name);
return;
}
}
wlr_output_layout_add(g_pCompositor->m_sWLROutputLayout, pMonitor->output, (int)pMonitorRule->offset.x, (int)pMonitorRule->offset.y);
//wlr_output_damage_add_whole(pMonitor->damage);
wlr_output_enable(pMonitor->output, true);
// updato wlroots
Events::listener_change(nullptr, nullptr);
// updato us
arrangeLayersForMonitor(pMonitor->ID);
// frame skip
pMonitor->needsFrameSkip = true;
}