output-layout: fix wlroots display handling (#3718)

This commit is contained in:
Alessio Molinari 2023-11-12 14:14:05 +01:00 committed by GitHub
parent 91cbe93cf8
commit 1bfd4a2bff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 10 deletions

View file

@ -2792,4 +2792,4 @@ void CCompositor::setPreferredScaleForSurface(wlr_surface* pSurface, double scal
void CCompositor::setPreferredTransformForSurface(wlr_surface* pSurface, wl_output_transform transform) { void CCompositor::setPreferredTransformForSurface(wlr_surface* pSurface, wl_output_transform transform) {
wlr_surface_set_preferred_buffer_transform(pSurface, transform); wlr_surface_set_preferred_buffer_transform(pSurface, transform);
} }

View file

@ -22,10 +22,13 @@ void Events::listener_change(wl_listener* listener, void* data) {
if (!CONFIG) if (!CONFIG)
return; return;
for (auto& m : g_pCompositor->m_vMonitors) { for (auto& m : g_pCompositor->m_vRealMonitors) {
if (!m->output) if (!m->output)
continue; continue;
if (g_pCompositor->m_pUnsafeOutput == m.get())
continue;
const auto CONFIGHEAD = wlr_output_configuration_head_v1_create(CONFIG, m->output); const auto CONFIGHEAD = wlr_output_configuration_head_v1_create(CONFIG, m->output);
CBox BOX; CBox BOX;
@ -195,7 +198,7 @@ void Events::listener_monitorDestroy(void* owner, void* data) {
Debug::log(LOG, "Destroy called for monitor {}", pMonitor->output->name); Debug::log(LOG, "Destroy called for monitor {}", pMonitor->output->name);
pMonitor->onDisconnect(); pMonitor->onDisconnect(true);
pMonitor->output = nullptr; pMonitor->output = nullptr;
pMonitor->m_bRenderingInitPassed = false; pMonitor->m_bRenderingInitPassed = false;

View file

@ -188,7 +188,7 @@ void CMonitor::onConnect(bool noRule) {
g_pCompositor->scheduleFrameForMonitor(this); g_pCompositor->scheduleFrameForMonitor(this);
} }
void CMonitor::onDisconnect() { void CMonitor::onDisconnect(bool destroy) {
if (renderTimer) { if (renderTimer) {
wl_event_source_remove(renderTimer); wl_event_source_remove(renderTimer);
@ -276,7 +276,8 @@ void CMonitor::onDisconnect() {
activeWorkspace = -1; 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); wlr_output_enable(output, false);
@ -298,7 +299,6 @@ void CMonitor::onDisconnect() {
g_pHyprRenderer->m_pMostHzMonitor = pMonitorMostHz; g_pHyprRenderer->m_pMostHzMonitor = pMonitorMostHz;
} }
std::erase_if(g_pCompositor->m_vMonitors, [&](std::shared_ptr<CMonitor>& el) { return el.get() == this; }); 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() { Vector2D CMonitor::middle() {
return vecPosition + vecSize / 2.f; return vecPosition + vecSize / 2.f;
} }

View file

@ -110,7 +110,7 @@ class CMonitor {
// methods // methods
void onConnect(bool noRule); void onConnect(bool noRule);
void onDisconnect(); void onDisconnect(bool destroy = false);
void addDamage(const pixman_region32_t* rg); void addDamage(const pixman_region32_t* rg);
void addDamage(const CRegion* rg); void addDamage(const CRegion* rg);
void addDamage(const CBox* box); void addDamage(const CBox* box);

View file

@ -2,6 +2,7 @@
#include "../Compositor.hpp" #include "../Compositor.hpp"
#include "linux-dmabuf-unstable-v1-protocol.h" #include "linux-dmabuf-unstable-v1-protocol.h"
#include "../helpers/Region.hpp" #include "../helpers/Region.hpp"
#include <algorithm>
CHyprRenderer::CHyprRenderer() { CHyprRenderer::CHyprRenderer() {
const auto ENV = getenv("WLR_DRM_NO_ATOMIC"); const auto ENV = getenv("WLR_DRM_NO_ATOMIC");
@ -1287,13 +1288,22 @@ void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool
break; break;
} }
if (!test) if (!test) {
g_pConfigManager->m_bWantsMonitorReload = true; // for monitor keywords 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) if (ok)
wlr_output_configuration_v1_send_succeeded(config); wlr_output_configuration_v1_send_succeeded(config);
else else
wlr_output_configuration_v1_send_failed(config); wlr_output_configuration_v1_send_failed(config);
wlr_output_configuration_v1_destroy(config); wlr_output_configuration_v1_destroy(config);
Debug::log(LOG, "OutputMgr Applied/Tested."); 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 it's disabled, disable and ignore
if (pMonitorRule->disabled) { if (pMonitorRule->disabled) {
if (pMonitor->m_bEnabled) if (pMonitor->m_bEnabled)
pMonitor->onDisconnect(); pMonitor->onDisconnect();