internal: Further unsafe state improvements (#3404)

Instead of allowing Hyprland to sit in a state where there are no monitors, which various parts of the code don't like, we create a fake headless output on all monitor disconnect, and then remove it when a monitor appears
This commit is contained in:
Vaxry
2023-09-24 18:04:38 +01:00
committed by GitHub
parent 352ceb1117
commit 46d66f4bcc
5 changed files with 63 additions and 11 deletions

View File

@@ -2604,3 +2604,43 @@ void CCompositor::arrangeMonitors() {
m->xwaylandScale = 1.f;
}
}
void CCompositor::enterUnsafeState() {
if (m_bUnsafeState)
return;
Debug::log(LOG, "Entering unsafe state");
m_bUnsafeState = true;
// create a backup monitor
wlr_backend* headless = nullptr;
wlr_multi_for_each_backend(
m_sWLRBackend,
[](wlr_backend* b, void* data) {
if (wlr_backend_is_headless(b))
*((wlr_backend**)data) = b;
},
&headless);
if (!headless) {
Debug::log(WARN, "Entering an unsafe state without a headless backend");
return;
}
m_pUnsafeOutput = wlr_headless_add_output(headless, 1920, 1080);
}
void CCompositor::leaveUnsafeState() {
if (!m_bUnsafeState)
return;
Debug::log(LOG, "Leaving unsafe state");
m_bUnsafeState = false;
if (m_pUnsafeOutput)
wlr_output_destroy(m_pUnsafeOutput);
m_pUnsafeOutput = nullptr;
}