diff --git a/src/core/LockSurface.cpp b/src/core/LockSurface.cpp index 706f844..755b253 100644 --- a/src/core/LockSurface.cpp +++ b/src/core/LockSurface.cpp @@ -16,10 +16,12 @@ static const ext_session_lock_surface_v1_listener lockListener = { static void handlePreferredScale(void* data, wp_fractional_scale_v1* wp_fractional_scale_v1, uint32_t scale) { const auto PSURF = (CSessionLockSurface*)data; + const bool SAMESCALE = PSURF->fractionalScale == scale / 120.0; PSURF->fractionalScale = scale / 120.0; + Debug::log(LOG, "Got fractional scale: {}", PSURF->fractionalScale); - if (PSURF->readyForFrame) + if (!SAMESCALE && PSURF->readyForFrame) PSURF->onScaleUpdate(); } @@ -55,10 +57,9 @@ CSessionLockSurface::CSessionLockSurface(COutput* output) : output(output) { } const auto PFRACTIONALSCALING = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:fractional_scaling"); - const auto ENABLE_FSV1 = **PFRACTIONALSCALING == 1 || - /* auto */ (**PFRACTIONALSCALING == 2 && (g_pHyprlock->m_sCurrentDesktop == "Hyprland" || g_pHyprlock->m_sCurrentDesktop == "niri")); - const auto PFRACTIONALMGR = g_pHyprlock->getFractionalMgr(); - const auto PVIEWPORTER = g_pHyprlock->getViewporter(); + const auto ENABLE_FSV1 = **PFRACTIONALSCALING == 1 || /* auto enable */ (**PFRACTIONALSCALING == 2); + const auto PFRACTIONALMGR = g_pHyprlock->getFractionalMgr(); + const auto PVIEWPORTER = g_pHyprlock->getViewporter(); if (ENABLE_FSV1 && PFRACTIONALMGR && PVIEWPORTER) { fractional = wp_fractional_scale_manager_v1_get_fractional_scale(PFRACTIONALMGR, surface); @@ -87,9 +88,12 @@ void CSessionLockSurface::configure(const Vector2D& size_, uint32_t serial_) { Debug::log(LOG, "configure with serial {}", serial_); const bool SAMESERIAL = serial == serial_; + const bool SAMESIZE = logicalSize == size_; + const bool SAMESCALE = appliedScale == fractionalScale; - serial = serial_; - logicalSize = size_; + serial = serial_; + logicalSize = size_; + appliedScale = fractionalScale; if (fractional) { size = (size_ * fractionalScale).floor(); @@ -127,6 +131,11 @@ void CSessionLockSurface::configure(const Vector2D& size_, uint32_t serial_) { } } + if (readyForFrame && !(SAMESIZE && SAMESCALE)) { + g_pRenderer->removeWidgetsFor(this); + Debug::log(LOG, "Reloading widgets"); + } + readyForFrame = true; render(); diff --git a/src/core/LockSurface.hpp b/src/core/LockSurface.hpp index 046b971..16a8294 100644 --- a/src/core/LockSurface.hpp +++ b/src/core/LockSurface.hpp @@ -34,6 +34,7 @@ class CSessionLockSurface { wl_egl_window* eglWindow = nullptr; Vector2D size; Vector2D logicalSize; + float appliedScale; EGLSurface eglSurface = nullptr; wp_fractional_scale_v1* fractional = nullptr; wp_viewport* viewport = nullptr;