From 4afeedbd567ca2114f682f14a6de26d4a8188878 Mon Sep 17 00:00:00 2001 From: Franz Berger Date: Tue, 6 Jun 2023 09:48:07 +0200 Subject: [PATCH] Fix fractional scale updates in some cases (#2447) * fix fractional scale update in moveWorkspaceToMonitor * fix fractional scale update in moveToWorkspace * Revert "fix fractional scale update in moveWorkspaceToMonitor" This reverts commit 6612197a38e6e55a730bb786ed12861830e9f40e. * Revert "fix fractional scale update in moveToWorkspace" This reverts commit 75d9795a065c0122e42d622fbeb83b18c47d4bbc. * move fractional scale code to updateSurfaceOutputs * remove duplicate check * remove superfluous setPreferredScale() --- src/Window.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/Window.cpp b/src/Window.cpp index ce3ee967..7fe83ecc 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -283,6 +283,14 @@ void CWindow::updateSurfaceOutputs() { wlr_surface_for_each_surface(m_pWLSurface.wlr(), sendLeaveIter, PLASTMONITOR->output); wlr_surface_for_each_surface(m_pWLSurface.wlr(), sendEnterIter, PNEWMONITOR->output); + + wlr_surface_for_each_surface( + m_pWLSurface.wlr(), + [](wlr_surface* surf, int x, int y, void* data) { + const auto PMONITOR = g_pCompositor->getMonitorFromID(((CWindow*)data)->m_iMonitorID); + g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(surf, PMONITOR ? PMONITOR->scale : 1.f); + }, + this); } void CWindow::moveToWorkspace(int workspaceID) { @@ -291,7 +299,6 @@ void CWindow::moveToWorkspace(int workspaceID) { m_iWorkspaceID = workspaceID; - const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID); if (PWORKSPACE) { @@ -303,20 +310,6 @@ void CWindow::moveToWorkspace(int workspaceID) { m_pSwallowed->moveToWorkspace(workspaceID); m_pSwallowed->m_iMonitorID = m_iMonitorID; } - - if (PMONITOR) - g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(m_pWLSurface.wlr(), PMONITOR->scale); - - if (!m_bIsMapped) - return; - - wlr_surface_for_each_surface( - m_pWLSurface.wlr(), - [](wlr_surface* surf, int x, int y, void* data) { - const auto PMONITOR = g_pCompositor->getMonitorFromID(((CWindow*)data)->m_iMonitorID); - g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(surf, PMONITOR ? PMONITOR->scale : 1.f); - }, - this); } CWindow* CWindow::X11TransientFor() {