mirror of
https://git.allpurposem.at/mat/WiggleWobble.git
synced 2025-12-23 13:01:28 +01:00
fix: don't detect windows fading out as wobbleable
This commit is contained in:
parent
8d126b2145
commit
aae62208d6
37
src/main.cpp
37
src/main.cpp
@ -4,9 +4,12 @@
|
||||
#include "wobblywindow.h"
|
||||
|
||||
#include <any>
|
||||
#include <hyprland/src/Compositor.hpp>
|
||||
#include <hyprland/src/helpers/time/Time.hpp>
|
||||
#include <hyprland/src/managers/input/InputManager.hpp>
|
||||
#include <hyprland/src/plugins/HookSystem.hpp>
|
||||
#include <hyprland/src/render/Renderer.hpp>
|
||||
#include <hyprutils/math/Vector2D.hpp>
|
||||
#include <optional>
|
||||
|
||||
// Do NOT change this function.
|
||||
@ -23,13 +26,29 @@ void registerWindow(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() {
|
||||
const auto now = Time::steadyNow();
|
||||
std::erase_if(g_wobblyWindows, [&now](auto&& wobble) {
|
||||
const bool shouldErase = wobble.second.step(now);
|
||||
std::erase_if(g_wobblyWindows, [&now](auto&& element) {
|
||||
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;
|
||||
});
|
||||
@ -68,6 +87,11 @@ void hkRenderWindow(
|
||||
return false;
|
||||
}
|
||||
|
||||
// window is closing
|
||||
if (pWindow->m_fadingOut) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// did the window move
|
||||
if (const auto pos = pWindow->m_realPosition->value(); pos != g_windowPositions[pWindow]) {
|
||||
auto&& wobble = g_wobblyWindows[pWindow];
|
||||
@ -97,9 +121,6 @@ void hkRenderWindow(
|
||||
const auto windowBox = pWindow->getFullWindowBoundingBox();
|
||||
|
||||
if (shouldWobble) {
|
||||
// HACK: this should only damage the wobbly bbox
|
||||
// g_pHyprRenderer->damageMonitor(g_pHyprOpenGL->m_renderData.pMonitor.lock());
|
||||
|
||||
PHLWINDOWREF ref {pWindow};
|
||||
|
||||
// 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(); }
|
||||
);
|
||||
|
||||
{
|
||||
static const auto METHODS = HyprlandAPI::findFunctionsByName(PHANDLE, "renderWindow");
|
||||
g_pRenderWindowHook =
|
||||
HyprlandAPI::createFunctionHook(handle, METHODS[0].address, (void*)&hkRenderWindow);
|
||||
g_pRenderWindowHook->hook();
|
||||
}
|
||||
|
||||
HyprlandAPI::reloadConfig();
|
||||
|
||||
@ -193,7 +216,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
||||
APICALL EXPORT void PLUGIN_EXIT() {
|
||||
CRenderWobblyWindowPassElement::deinitGPUObjects();
|
||||
g_pRenderWindowHook = nullptr;
|
||||
g_openWindow = nullptr;
|
||||
g_closeWindow = nullptr;
|
||||
g_openWindow = nullptr;
|
||||
g_tick = nullptr;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user