From 0283c498d65284478826dcd64837ce2a4bb25bde Mon Sep 17 00:00:00 2001 From: vaxerski Date: Thu, 22 Jun 2023 21:43:31 +0200 Subject: [PATCH] xwayland: fix minor force_zero_scaling bugs --- src/events/Windows.cpp | 17 +++++++++++++++++ src/layout/IHyprLayout.cpp | 13 ++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 76827ba9..5d2a4bdb 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -980,6 +980,13 @@ void Events::listener_configureX11(void* owner, void* data) { PWINDOW->m_vRealPosition.setValueAndWarp(Vector2D(E->x, E->y)); PWINDOW->m_vRealSize.setValueAndWarp(Vector2D(E->width, E->height)); + + static auto* const PXWLFORCESCALEZERO = &g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling")->intValue; + if (*PXWLFORCESCALEZERO) { + if (const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID); PMONITOR) + PWINDOW->m_vRealSize.setValueAndWarp(PWINDOW->m_vRealSize.goalv() / PMONITOR->scale); + } + PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.vec(); PWINDOW->m_vSize = PWINDOW->m_vRealSize.vec(); @@ -1019,6 +1026,8 @@ void Events::listener_unmanagedSetGeometry(void* owner, void* data) { return; } + static auto* const PXWLFORCESCALEZERO = &g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling")->intValue; + if (abs(std::floor(POS.x) - PWINDOW->m_uSurface.xwayland->x) > 2 || abs(std::floor(POS.y) - PWINDOW->m_uSurface.xwayland->y) > 2 || abs(std::floor(SIZ.x) - PWINDOW->m_uSurface.xwayland->width) > 2 || abs(std::floor(SIZ.y) - PWINDOW->m_uSurface.xwayland->height) > 2) { Debug::log(LOG, "Unmanaged window %lx requests geometry update to %i %i %i %i", PWINDOW, (int)PWINDOW->m_uSurface.xwayland->x, (int)PWINDOW->m_uSurface.xwayland->y, @@ -1030,6 +1039,14 @@ void Events::listener_unmanagedSetGeometry(void* owner, void* data) { if (abs(std::floor(SIZ.x) - PWINDOW->m_uSurface.xwayland->width) > 2 || abs(std::floor(SIZ.y) - PWINDOW->m_uSurface.xwayland->height) > 2) PWINDOW->m_vRealSize.setValueAndWarp(Vector2D(PWINDOW->m_uSurface.xwayland->width, PWINDOW->m_uSurface.xwayland->height)); + if (*PXWLFORCESCALEZERO) { + if (const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID); PMONITOR) + PWINDOW->m_vRealSize.setValueAndWarp(PWINDOW->m_vRealSize.goalv() / PMONITOR->scale); + } + + PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.goalv(); + PWINDOW->m_vSize = PWINDOW->m_vRealSize.goalv(); + PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromVector(PWINDOW->m_vRealPosition.vec() + PWINDOW->m_vRealSize.vec() / 2.f)->activeWorkspace; g_pCompositor->moveWindowToTop(PWINDOW); diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 8f256630..2e5b15a4 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -43,8 +43,8 @@ void IHyprLayout::onWindowRemoved(CWindow* pWindow) { pWindow->m_sGroupData.pNextWindow = nullptr; if (pWindow->m_sGroupData.head) { - pWindow->m_sGroupData.head = false; - curr->m_sGroupData.head = true; + pWindow->m_sGroupData.head = false; + curr->m_sGroupData.head = true; curr->m_sGroupData.locked = pWindow->m_sGroupData.locked; pWindow->m_sGroupData.locked = false; } @@ -75,7 +75,9 @@ void IHyprLayout::onWindowRemovedFloating(CWindow* pWindow) { void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) { wlr_box desiredGeometry = {0}; g_pXWaylandManager->getGeometryForWindow(pWindow, &desiredGeometry); - const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID); + const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID); + + static auto* const PXWLFORCESCALEZERO = &g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling")->intValue; if (!PMONITOR) { Debug::log(ERR, "Window %lx (%s) has an invalid monitor in onWindowCreatedFloating!!!", pWindow, pWindow->m_szTitle.c_str()); @@ -151,6 +153,11 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) { } } + if (*PXWLFORCESCALEZERO && pWindow->m_bIsX11) { + pWindow->m_vRealSize = pWindow->m_vRealSize.goalv() / PMONITOR->scale; + pWindow->m_vRealPosition = pWindow->m_vRealPosition.goalv() / PMONITOR->scale; + } + if (pWindow->m_bX11DoesntWantBorders || (pWindow->m_bIsX11 && pWindow->m_uSurface.xwayland->override_redirect)) { pWindow->m_vRealPosition.setValue(pWindow->m_vRealPosition.goalv()); pWindow->m_vRealSize.setValue(pWindow->m_vRealSize.goalv());