summaryrefslogtreecommitdiff
path: root/src/Compositor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Compositor.cpp')
-rw-r--r--src/Compositor.cpp59
1 files changed, 39 insertions, 20 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index f1ac7b2b..681cbf86 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -463,6 +463,25 @@ void CCompositor::removeLockFile() {
std::filesystem::remove(PATH);
}
+void CCompositor::prepareFallbackOutput() {
+ // 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, "Unsafe state will be ineffective, no fallback output");
+ return;
+ }
+
+ wlr_headless_add_output(headless, 1920, 1080);
+}
+
void CCompositor::startCompositor() {
initAllSignals();
@@ -514,6 +533,8 @@ void CCompositor::startCompositor() {
throwError("The backend could not start!");
}
+ prepareFallbackOutput();
+
g_pHyprRenderer->setCursorFromName("left_ptr");
#ifdef USES_SYSTEMD
@@ -2657,24 +2678,10 @@ void CCompositor::enterUnsafeState() {
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;
- }
+ if (!m_pUnsafeOutput->m_bEnabled)
+ m_pUnsafeOutput->onConnect(false);
- m_pUnsafeOutput = wlr_headless_add_output(headless, 1920, 1080);
+ m_bUnsafeState = true;
}
void CCompositor::leaveUnsafeState() {
@@ -2685,10 +2692,22 @@ void CCompositor::leaveUnsafeState() {
m_bUnsafeState = false;
- if (m_pUnsafeOutput)
- wlr_output_destroy(m_pUnsafeOutput);
+ CMonitor* pNewMonitor = nullptr;
+ for (auto& pMonitor : m_vMonitors) {
+ if (pMonitor->output != m_pUnsafeOutput->output) {
+ pNewMonitor = pMonitor.get();
+ break;
+ }
+ }
+
+ RASSERT(pNewMonitor, "Tried to leave unsafe without a monitor");
+
+ if (m_pUnsafeOutput->m_bEnabled)
+ m_pUnsafeOutput->onDisconnect();
- m_pUnsafeOutput = nullptr;
+ for (auto& m : m_vMonitors) {
+ scheduleFrameForMonitor(m.get());
+ }
}
void CCompositor::setPreferredScaleForSurface(wlr_surface* pSurface, double scale) {