mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-07 07:31:53 -07:00
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:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user