mirror of
https://git.allpurposem.at/mat/WiggleWobble.git
synced 2025-12-23 13:01:28 +01:00
feat: unregister windows upon closing
This commit is contained in:
parent
fd86b84cdf
commit
d78fda606f
15
src/main.cpp
15
src/main.cpp
@ -1,6 +1,7 @@
|
||||
#include "globals.hpp"
|
||||
|
||||
#include <GLES3/gl32.h>
|
||||
#include <any>
|
||||
#include <cmath>
|
||||
#include <hyprgraphics/color/Color.hpp>
|
||||
// version.hpp will be generated by meson
|
||||
@ -285,12 +286,16 @@ class CRenderWobblyWindowPassElement final: public IPassElement {
|
||||
PHLWINDOWREF m_pWindow;
|
||||
};
|
||||
|
||||
// TODO: unregister on close
|
||||
void registerWindow(PHLWINDOW pWindow) {
|
||||
g_windowPositions[pWindow] = pWindow->m_realPosition->value();
|
||||
}
|
||||
|
||||
void unregisterWindow(PHLWINDOW pWindow) {
|
||||
g_windowPositions.erase(PHLWINDOWREF {pWindow});
|
||||
}
|
||||
|
||||
static SP<HOOK_CALLBACK_FN> g_openWindow = nullptr;
|
||||
static SP<HOOK_CALLBACK_FN> g_closeWindow = nullptr;
|
||||
inline CFunctionHook* g_pRenderWindowHook = nullptr;
|
||||
|
||||
typedef void (*origRenderWindow)(
|
||||
@ -518,6 +523,14 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
||||
}
|
||||
);
|
||||
|
||||
g_closeWindow = HyprlandAPI::registerCallbackDynamic(
|
||||
PHANDLE,
|
||||
"closeWindow",
|
||||
[](void* self, SCallbackInfo& info, std::any data) {
|
||||
unregisterWindow(std::any_cast<PHLWINDOW>(data));
|
||||
}
|
||||
);
|
||||
|
||||
static const auto METHODS = HyprlandAPI::findFunctionsByName(PHANDLE, "renderWindow");
|
||||
g_pRenderWindowHook =
|
||||
HyprlandAPI::createFunctionHook(handle, METHODS[0].address, (void*)&hkRenderWindow);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user