diff --git a/hyprpm.toml b/hyprpm.toml index cd87e12..cad415f 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -9,7 +9,8 @@ output = "hyprfocus.so" commit_pins = [ ["1c460e98f870676b15871fe4e5bfeb1a32a3d6d8", "2af0c1e87e3cdcef3c8f9c7def918982312d0b75"], ["c5e28ebcfe00a510922779b2c568cfa52a317445", "c5e28ebcfe00a510922779b2c568cfa52a317445"], - ["0c513ba91bd73106be99e35b1a020d24e5ae874a", "e44b956dd4b7507489219bd2b02a3886d547b7e2"] + ["0c513ba91bd73106be99e35b1a020d24e5ae874a", "e44b956dd4b7507489219bd2b02a3886d547b7e2"], + ["cba1ade848feac44b2eda677503900639581c3f4", "49dbe19e08f963e01ac4ba17b42719956d390ec7"], ] build = [ "make all" diff --git a/src/Flash.cpp b/src/Flash.cpp index 0f0a76d..e4b14a8 100644 --- a/src/Flash.cpp +++ b/src/Flash.cpp @@ -26,7 +26,7 @@ void CFlash::setup(HANDLE pHandle, std::string animationName) { // hyprfocus_log(LOG, "Active opacity: {}", g_fActiveOpacity); } -void CFlash::onWindowFocus(CWindow *pWindow, HANDLE pHandle) { +void CFlash::onWindowFocus(PHLWINDOW pWindow, HANDLE pHandle) { hyprfocus_log(LOG, "Flash onWindowFocus start"); IFocusAnimation::onWindowFocus(pWindow, pHandle); diff --git a/src/Flash.hpp b/src/Flash.hpp index 791ae2c..22723ea 100644 --- a/src/Flash.hpp +++ b/src/Flash.hpp @@ -2,7 +2,7 @@ class CFlash : public IFocusAnimation { public: - void onWindowFocus(CWindow *pWindow, HANDLE pHandle) override; + void onWindowFocus(PHLWINDOW pWindow, HANDLE pHandle) override; void init(HANDLE pHandle, std::string animationName) override; void setup(HANDLE pHandle, std::string animationName) override; }; diff --git a/src/IFocusAnimation.cpp b/src/IFocusAnimation.cpp index bc7847e..706bcb8 100644 --- a/src/IFocusAnimation.cpp +++ b/src/IFocusAnimation.cpp @@ -37,7 +37,7 @@ void IFocusAnimation::setup(HANDLE pHandle, std::string animationName) { // hyprfocus_log(LOG, "Setting up focus animation: {}", animationName); } -void IFocusAnimation::onWindowFocus(CWindow *pWindow, HANDLE pHandle) { +void IFocusAnimation::onWindowFocus(PHLWINDOW pWindow, HANDLE pHandle) { hyprfocus_log(LOG, "Base callback for animation: {}", m_szAnimationName); static const auto *inBezier = (Hyprlang::STRING const *)(HyprlandAPI::getConfigValue( diff --git a/src/IFocusAnimation.hpp b/src/IFocusAnimation.hpp index 6d0dbac..c8a7295 100644 --- a/src/IFocusAnimation.hpp +++ b/src/IFocusAnimation.hpp @@ -7,7 +7,7 @@ class IFocusAnimation { public: - virtual void onWindowFocus(CWindow *pWindow, HANDLE pHandle); + virtual void onWindowFocus(PHLWINDOW pWindow, HANDLE pHandle); virtual void init(HANDLE pHandle, std::string animationName); virtual void setup(HANDLE pHandle, std::string animationName); diff --git a/src/Shrink.cpp b/src/Shrink.cpp index 8d7e9cd..fb027fe 100644 --- a/src/Shrink.cpp +++ b/src/Shrink.cpp @@ -20,7 +20,7 @@ void CShrink::setup(HANDLE pHandle, std::string animationName) { // hyprfocus_log(LOG, "Shrink percentage: {}", g_fShrinkPercentage); } -void CShrink::onWindowFocus(CWindow *pWindow, HANDLE pHandle) { +void CShrink::onWindowFocus(PHLWINDOW pWindow, HANDLE pHandle) { std::string currentAnimStyle = pWindow->m_vRealSize.getConfig()->internalStyle; hyprfocus_log(LOG, "Current animation style: {}", currentAnimStyle); diff --git a/src/Shrink.hpp b/src/Shrink.hpp index 15553a0..c2f3f02 100644 --- a/src/Shrink.hpp +++ b/src/Shrink.hpp @@ -2,7 +2,7 @@ class CShrink : public IFocusAnimation { public: - void onWindowFocus(CWindow *pWindow, HANDLE pHandle) override; + void onWindowFocus(PHLWINDOW pWindow, HANDLE pHandle) override; void init(HANDLE pHandle, std::string animationName) override; void setup(HANDLE pHandle, std::string animationName) override; diff --git a/src/main.cpp b/src/main.cpp index 97fac24..8bd7d4f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,6 @@ #include "Log.hpp" -#define WLR_USE_UNSTABLE +#include +#include #include "Globals.hpp" #include @@ -13,13 +14,13 @@ #include "Flash.hpp" #include "Shrink.hpp" -CWindow *g_pPreviouslyFocusedWindow = nullptr; +PHLWINDOW g_pPreviouslyFocusedWindow = nullptr; bool g_bMouseWasPressed = false; bool g_bWorkspaceChanged = false; std::unordered_map> g_mAnimations; -static bool OnSameWorkspace(CWindow *pWindow1, CWindow *pWindow2) { +static bool OnSameWorkspace(PHLWINDOW pWindow1, PHLWINDOW pWindow2) { if (pWindow1 == pWindow2) { return true; } else if (pWindow1 == nullptr || pWindow2 == nullptr) { @@ -31,7 +32,7 @@ static bool OnSameWorkspace(CWindow *pWindow1, CWindow *pWindow2) { } } -void flashWindow(CWindow *pWindow) { +void flashWindow(PHLWINDOW pWindow) { // static const Hyprlang::STRING *focusAnimation = nullptr; // if (g_bMouseWasPressed == true) { // hyprfocus_log(LOG, "Mouse was pressed"); @@ -85,7 +86,7 @@ void flashCurrentWindow(std::string) { static void onActiveWindowChange(void *self, std::any data) { try { hyprfocus_log(LOG, "Active window changed"); - auto *const PWINDOW = std::any_cast(data); + auto const PWINDOW = std::any_cast(data); static auto *const PHYPRFOCUSENABLED = (Hyprlang::INT *const *)HyprlandAPI::getConfigValue( PHANDLE, "plugin:hyprfocus:enabled") @@ -141,11 +142,11 @@ static void onActiveWindowChange(void *self, std::any data) { static void onMouseButton(void *self, std::any data) { try { - auto *const PWLRMOUSEBUTTONEVENT = - std::any_cast(data); + auto const PWLRMOUSEBUTTONEVENT = + std::any_cast(data); hyprfocus_log(LOG, "Mouse button state: {}", - (int)PWLRMOUSEBUTTONEVENT->state); - g_bMouseWasPressed = (int)PWLRMOUSEBUTTONEVENT->state == 1; + (int)PWLRMOUSEBUTTONEVENT.state); + g_bMouseWasPressed = (int)PWLRMOUSEBUTTONEVENT.state == 1; } catch (std::bad_any_cast &e) { hyprfocus_log(ERR, "Cast Error: {}", e.what()); @@ -188,14 +189,14 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { hyprfocus_log(LOG, "Reloaded config"); // Register callbacks - HyprlandAPI::registerCallbackDynamic( + static auto P1 = HyprlandAPI::registerCallbackDynamic( PHANDLE, "activeWindow", [&](void *self, SCallbackInfo &info, std::any data) { onActiveWindowChange(self, data); }); hyprfocus_log(LOG, "Registered active window change callback"); - HyprlandAPI::registerCallbackDynamic( + static auto P2 = HyprlandAPI::registerCallbackDynamic( PHANDLE, "mouseButton", [&](void *self, SCallbackInfo &info, std::any data) { onMouseButton(self, data);