From 5f4659afef5856c509d53957e62b7f6c38d39f41 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 26 May 2023 14:49:03 +0200 Subject: [PATCH] xdgshell: check and conform to rigid float sizes on commit --- src/events/Windows.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index d9230f8a..d1cb72f0 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -741,7 +741,26 @@ void Events::listener_commitWindow(void* owner, void* data) { g_pHyprRenderer->damageSurface(PWINDOW->m_pWLSurface.wlr(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y); - // Debug::log(LOG, "Window %lx committed", PWINDOW); // SPAM! + if (PWINDOW->m_bIsX11 || !PWINDOW->m_bIsFloating || PWINDOW->m_bIsFullscreen) + return; + + const auto ISRIGID = PWINDOW->m_uSurface.xdg->toplevel->current.max_height == PWINDOW->m_uSurface.xdg->toplevel->current.min_height && + PWINDOW->m_uSurface.xdg->toplevel->current.max_width == PWINDOW->m_uSurface.xdg->toplevel->current.min_width; + + if (!ISRIGID) + return; + + const Vector2D REQUESTEDSIZE = {PWINDOW->m_uSurface.xdg->toplevel->current.max_width, PWINDOW->m_uSurface.xdg->toplevel->current.max_height}; + + if (REQUESTEDSIZE == PWINDOW->m_vReportedSize || REQUESTEDSIZE.x < 5 || REQUESTEDSIZE.y < 5) + return; + + const Vector2D DELTA = PWINDOW->m_vReportedSize - REQUESTEDSIZE; + + PWINDOW->m_vRealPosition = PWINDOW->m_vRealPosition.goalv() + DELTA / 2.0; + PWINDOW->m_vRealSize = REQUESTEDSIZE; + g_pXWaylandManager->setWindowSize(PWINDOW, REQUESTEDSIZE, true); + g_pHyprRenderer->damageWindow(PWINDOW); } void Events::listener_destroyWindow(void* owner, void* data) {