fix: don't detect windows fading out as wobbleable

This commit is contained in:
Matias 2025-07-17 10:21:14 +02:00
parent 8d126b2145
commit aae62208d6
No known key found for this signature in database
GPG Key ID: ED35A6AC65A06B69

View File

@ -4,9 +4,12 @@
#include "wobblywindow.h" #include "wobblywindow.h"
#include <any> #include <any>
#include <hyprland/src/Compositor.hpp>
#include <hyprland/src/helpers/time/Time.hpp> #include <hyprland/src/helpers/time/Time.hpp>
#include <hyprland/src/managers/input/InputManager.hpp> #include <hyprland/src/managers/input/InputManager.hpp>
#include <hyprland/src/plugins/HookSystem.hpp>
#include <hyprland/src/render/Renderer.hpp> #include <hyprland/src/render/Renderer.hpp>
#include <hyprutils/math/Vector2D.hpp>
#include <optional> #include <optional>
// Do NOT change this function. // Do NOT change this function.
@ -23,13 +26,29 @@ void registerWindow(PHLWINDOW pWindow) {
} }
void unregisterWindow(PHLWINDOW pWindow) { void unregisterWindow(PHLWINDOW pWindow) {
g_windowPositions.erase(PHLWINDOWREF {pWindow}); const auto winref = PHLWINDOWREF {pWindow};
g_windowPositions.erase(winref);
g_windowFramebuffers.erase(winref);
g_wobblyWindows.erase(winref);
} }
void tick() { void tick() {
const auto now = Time::steadyNow(); const auto now = Time::steadyNow();
std::erase_if(g_wobblyWindows, [&now](auto&& wobble) { std::erase_if(g_wobblyWindows, [&now](auto&& element) {
const bool shouldErase = wobble.second.step(now); auto&& [window, wobble] = element;
const bool shouldErase = window->m_fadingOut or wobble.step(now);
const CBox windowBox = window->getFullWindowBoundingBox();
const CBox wobbleBox = wobble.getBox();
g_pHyprRenderer->damageBox(CBox(
windowBox.x + windowBox.width * wobbleBox.x,
windowBox.y + windowBox.height * wobbleBox.y,
windowBox.width * wobbleBox.width,
windowBox.height * wobbleBox.height
));
return shouldErase; return shouldErase;
}); });
@ -68,6 +87,11 @@ void hkRenderWindow(
return false; return false;
} }
// window is closing
if (pWindow->m_fadingOut) {
return false;
}
// did the window move // did the window move
if (const auto pos = pWindow->m_realPosition->value(); pos != g_windowPositions[pWindow]) { if (const auto pos = pWindow->m_realPosition->value(); pos != g_windowPositions[pWindow]) {
auto&& wobble = g_wobblyWindows[pWindow]; auto&& wobble = g_wobblyWindows[pWindow];
@ -97,9 +121,6 @@ void hkRenderWindow(
const auto windowBox = pWindow->getFullWindowBoundingBox(); const auto windowBox = pWindow->getFullWindowBoundingBox();
if (shouldWobble) { if (shouldWobble) {
// HACK: this should only damage the wobbly bbox
// g_pHyprRenderer->damageMonitor(g_pHyprOpenGL->m_renderData.pMonitor.lock());
PHLWINDOWREF ref {pWindow}; PHLWINDOWREF ref {pWindow};
// create it if not exists // create it if not exists
@ -180,10 +201,12 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
[](void* self, SCallbackInfo& info, std::any data) { tick(); } [](void* self, SCallbackInfo& info, std::any data) { tick(); }
); );
{
static const auto METHODS = HyprlandAPI::findFunctionsByName(PHANDLE, "renderWindow"); static const auto METHODS = HyprlandAPI::findFunctionsByName(PHANDLE, "renderWindow");
g_pRenderWindowHook = g_pRenderWindowHook =
HyprlandAPI::createFunctionHook(handle, METHODS[0].address, (void*)&hkRenderWindow); HyprlandAPI::createFunctionHook(handle, METHODS[0].address, (void*)&hkRenderWindow);
g_pRenderWindowHook->hook(); g_pRenderWindowHook->hook();
}
HyprlandAPI::reloadConfig(); HyprlandAPI::reloadConfig();
@ -193,7 +216,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
APICALL EXPORT void PLUGIN_EXIT() { APICALL EXPORT void PLUGIN_EXIT() {
CRenderWobblyWindowPassElement::deinitGPUObjects(); CRenderWobblyWindowPassElement::deinitGPUObjects();
g_pRenderWindowHook = nullptr; g_pRenderWindowHook = nullptr;
g_openWindow = nullptr;
g_closeWindow = nullptr; g_closeWindow = nullptr;
g_openWindow = nullptr;
g_tick = nullptr; g_tick = nullptr;
} }