diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 54c60b212..2d20df1da 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -3063,10 +3063,11 @@ void CCompositor::onNewMonitor(SP output) { for (auto const& w : g_pCompositor->m_windows) { if (w->m_monitor == PNEWMONITOR) { w->m_lastSurfaceMonitorID = MONITOR_INVALID; - w->updateSurfaceScaleTransformDetails(); } } + PNEWMONITOR->updateSurfaceScaleTransformDetails(); + g_pHyprRenderer->damageMonitor(PNEWMONITOR); PNEWMONITOR->m_frameScheduler->onFrame(); diff --git a/src/desktop/view/LayerSurface.cpp b/src/desktop/view/LayerSurface.cpp index ec7c61f27..1237efd42 100644 --- a/src/desktop/view/LayerSurface.cpp +++ b/src/desktop/view/LayerSurface.cpp @@ -219,8 +219,7 @@ void CLayerSurface::onMap() { g_pEventManager->postEvent(SHyprIPCEvent{.event = "openlayer", .data = m_namespace}); Event::bus()->m_events.layer.opened.emit(m_self.lock()); - g_pCompositor->setPreferredScaleForSurface(m_wlSurface->resource(), PMONITOR->m_scale); - g_pCompositor->setPreferredTransformForSurface(m_wlSurface->resource(), PMONITOR->m_transform); + updateSurfaceScaleTransformDetails(); } void CLayerSurface::onUnmap() { @@ -414,8 +413,7 @@ void CLayerSurface::onCommit() { g_pHyprRenderer->damageSurface(m_wlSurface->resource(), m_position.x, m_position.y); - g_pCompositor->setPreferredScaleForSurface(m_wlSurface->resource(), PMONITOR->m_scale); - g_pCompositor->setPreferredTransformForSurface(m_wlSurface->resource(), PMONITOR->m_transform); + updateSurfaceScaleTransformDetails(); } bool CLayerSurface::isFadedOut() { @@ -447,3 +445,29 @@ pid_t CLayerSurface::getPID() { return PID; } + +void CLayerSurface::updateSurfaceScaleTransformDetails() { + if (!aliveAndVisible() || g_pCompositor->m_unsafeState) + return; + + const auto PMONITOR = m_monitor.lock(); + + if (!PMONITOR) + return; + + auto surf = m_layerSurface->m_surface.lock(); + + if (!surf) + return; + + surf->breadthfirst( + [PMONITOR](SP s, const Vector2D& offset, void* d) { + const auto PSURFACE = CWLSurface::fromResource(s); + if (PSURFACE && PSURFACE->m_lastScaleFloat == PMONITOR->m_scale) + return; + + g_pCompositor->setPreferredScaleForSurface(s, PMONITOR->m_scale); + g_pCompositor->setPreferredTransformForSurface(s, PMONITOR->m_transform); + }, + nullptr); +} diff --git a/src/desktop/view/LayerSurface.hpp b/src/desktop/view/LayerSurface.hpp index a8cc7acd2..396363fe7 100644 --- a/src/desktop/view/LayerSurface.hpp +++ b/src/desktop/view/LayerSurface.hpp @@ -63,6 +63,7 @@ namespace Desktop::View { SP m_snapshotFB; pid_t getPID(); + void updateSurfaceScaleTransformDetails(); void onDestroy(); void onMap(); diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 2c1a5ca6e..1764819b4 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -58,6 +58,7 @@ using namespace Hyprutils::Utils; using namespace Hyprutils::OS; using enum NContentType::eContentType; using namespace NColorManagement; +using namespace Desktop::View; using namespace Render::GL; using namespace Monitor; @@ -1108,13 +1109,8 @@ bool CMonitor::applyMonitorRule(Config::CMonitorRule&& pMonitorRule, bool force) updateVCGTRamps(); - // Set scale for all surfaces on this monitor, needed for some clients - // but not on unsafe state to avoid crashes - if (!g_pCompositor->m_unsafeState) { - for (auto const& w : g_pCompositor->m_windows) { - w->updateSurfaceScaleTransformDetails(); - } - } + updateSurfaceScaleTransformDetails(); + // updato us g_pHyprRenderer->arrangeLayersForMonitor(m_id); @@ -1868,6 +1864,22 @@ uint8_t CMonitor::isTearingBlocked(bool full) { return reasons; } +void CMonitor::updateSurfaceScaleTransformDetails() { + if (g_pCompositor->m_unsafeState) + return; + + for (auto const& w : g_pCompositor->m_windows) { + if (w->m_monitor == m_self) + w->updateSurfaceScaleTransformDetails(); + } + + for (auto const& lsl : m_layerSurfaceLayers) { + for (auto const& ls : lsl) { + ls->updateSurfaceScaleTransformDetails(); + } + } +} + bool CMonitor::updateTearing() { m_tearingState.activelyTearing = !isTearingBlocked(); m_tearingState.nextRenderTorn = false; diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 7ec47c3f5..5c26601bb 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -323,6 +323,7 @@ class CMonitor { uint32_t isSolitaryBlocked(bool full = false); void recheckSolitary(); uint8_t isTearingBlocked(bool full = false); + void updateSurfaceScaleTransformDetails(); bool updateTearing(); uint16_t isDSBlocked(bool full = false); bool attemptDirectScanout();