aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAlessio Molinari <[email protected]>2023-11-12 14:14:05 +0100
committerGitHub <[email protected]>2023-11-12 13:14:05 +0000
commit1bfd4a2bff5f67872b868d519fbb45b32aa72b1f (patch)
tree300257e5a9eb63b5b0c9b4c3d8c775c1b1a24f44
parent91cbe93cf875c064847c76c6501d2a22c3f0abec (diff)
downloadHyprland-1bfd4a2bff5f67872b868d519fbb45b32aa72b1f.tar.gz
Hyprland-1bfd4a2bff5f67872b868d519fbb45b32aa72b1f.zip
output-layout: fix wlroots display handling (#3718)
-rw-r--r--src/Compositor.cpp2
-rw-r--r--src/events/Monitors.cpp7
-rw-r--r--src/helpers/Monitor.cpp8
-rw-r--r--src/helpers/Monitor.hpp2
-rw-r--r--src/render/Renderer.cpp13
5 files changed, 22 insertions, 10 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 29d019c1..70a19cb5 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -2792,4 +2792,4 @@ void CCompositor::setPreferredScaleForSurface(wlr_surface* pSurface, double scal
void CCompositor::setPreferredTransformForSurface(wlr_surface* pSurface, wl_output_transform transform) {
wlr_surface_set_preferred_buffer_transform(pSurface, transform);
-} \ No newline at end of file
+}
diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp
index 9155fe87..13f3f829 100644
--- a/src/events/Monitors.cpp
+++ b/src/events/Monitors.cpp
@@ -22,10 +22,13 @@ void Events::listener_change(wl_listener* listener, void* data) {
if (!CONFIG)
return;
- for (auto& m : g_pCompositor->m_vMonitors) {
+ for (auto& m : g_pCompositor->m_vRealMonitors) {
if (!m->output)
continue;
+ if (g_pCompositor->m_pUnsafeOutput == m.get())
+ continue;
+
const auto CONFIGHEAD = wlr_output_configuration_head_v1_create(CONFIG, m->output);
CBox BOX;
@@ -195,7 +198,7 @@ void Events::listener_monitorDestroy(void* owner, void* data) {
Debug::log(LOG, "Destroy called for monitor {}", pMonitor->output->name);
- pMonitor->onDisconnect();
+ pMonitor->onDisconnect(true);
pMonitor->output = nullptr;
pMonitor->m_bRenderingInitPassed = false;
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp
index 9dbd2a3e..743c938e 100644
--- a/src/helpers/Monitor.cpp
+++ b/src/helpers/Monitor.cpp
@@ -188,7 +188,7 @@ void CMonitor::onConnect(bool noRule) {
g_pCompositor->scheduleFrameForMonitor(this);
}
-void CMonitor::onDisconnect() {
+void CMonitor::onDisconnect(bool destroy) {
if (renderTimer) {
wl_event_source_remove(renderTimer);
@@ -276,7 +276,8 @@ void CMonitor::onDisconnect() {
activeWorkspace = -1;
- wlr_output_layout_remove(g_pCompositor->m_sWLROutputLayout, output);
+ if (!destroy)
+ wlr_output_layout_remove(g_pCompositor->m_sWLROutputLayout, output);
wlr_output_enable(output, false);
@@ -298,7 +299,6 @@ void CMonitor::onDisconnect() {
g_pHyprRenderer->m_pMostHzMonitor = pMonitorMostHz;
}
-
std::erase_if(g_pCompositor->m_vMonitors, [&](std::shared_ptr<CMonitor>& el) { return el.get() == this; });
}
@@ -642,4 +642,4 @@ void CMonitor::moveTo(const Vector2D& pos) {
Vector2D CMonitor::middle() {
return vecPosition + vecSize / 2.f;
-} \ No newline at end of file
+}
diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp
index 10790b5e..2aa7e7eb 100644
--- a/src/helpers/Monitor.hpp
+++ b/src/helpers/Monitor.hpp
@@ -110,7 +110,7 @@ class CMonitor {
// methods
void onConnect(bool noRule);
- void onDisconnect();
+ void onDisconnect(bool destroy = false);
void addDamage(const pixman_region32_t* rg);
void addDamage(const CRegion* rg);
void addDamage(const CBox* box);
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 98dcf7f5..65aa7138 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -2,6 +2,7 @@
#include "../Compositor.hpp"
#include "linux-dmabuf-unstable-v1-protocol.h"
#include "../helpers/Region.hpp"
+#include <algorithm>
CHyprRenderer::CHyprRenderer() {
const auto ENV = getenv("WLR_DRM_NO_ATOMIC");
@@ -1287,13 +1288,22 @@ void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool
break;
}
- if (!test)
+ if (!test) {
g_pConfigManager->m_bWantsMonitorReload = true; // for monitor keywords
+ // if everything is disabled, performMonitorReload won't be called from renderMonitor
+ bool allDisabled = std::all_of(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(),
+ [](const auto m) { return !m->m_bEnabled || g_pCompositor->m_pUnsafeOutput == m.get(); });
+ if (allDisabled) {
+ Debug::log(LOG, "OutputMgr apply: All monitors disabled; performing monitor reload.");
+ g_pConfigManager->performMonitorReload();
+ }
+ }
if (ok)
wlr_output_configuration_v1_send_succeeded(config);
else
wlr_output_configuration_v1_send_failed(config);
+
wlr_output_configuration_v1_destroy(config);
Debug::log(LOG, "OutputMgr Applied/Tested.");
@@ -1645,7 +1655,6 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
// if it's disabled, disable and ignore
if (pMonitorRule->disabled) {
-
if (pMonitor->m_bEnabled)
pMonitor->onDisconnect();