From d1f7c1f7e9e6176ed9184a7c34071e1b1e911fe8 Mon Sep 17 00:00:00 2001 From: Nic Wells Date: Thu, 30 May 2024 12:30:31 +0200 Subject: [PATCH 1/4] Actually fix v0.40.0, assign callbacks and use PHLWINDOW --- src/Flash.cpp | 2 +- src/Flash.hpp | 2 +- src/IFocusAnimation.cpp | 2 +- src/IFocusAnimation.hpp | 2 +- src/Shrink.cpp | 2 +- src/Shrink.hpp | 2 +- src/main.cpp | 12 ++++++------ 7 files changed, 12 insertions(+), 12 deletions(-) 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 ffda060..c7953a2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,13 +13,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 +31,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 +85,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") @@ -184,14 +184,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); From 19540dfe3c3b471be6b05fa7f711bf922334fb55 Mon Sep 17 00:00:00 2001 From: Nic Wells Date: Thu, 30 May 2024 12:32:45 +0200 Subject: [PATCH 2/4] Update hyprpm with latest --- hyprpm.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hyprpm.toml b/hyprpm.toml index cd87e12..3222db7 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", "d1f7c1f7e9e6176ed9184a7c34071e1b1e911fe8"], ] build = [ "make all" From 49dbe19e08f963e01ac4ba17b42719956d390ec7 Mon Sep 17 00:00:00 2001 From: Nic Wells Date: Thu, 30 May 2024 13:01:57 +0200 Subject: [PATCH 3/4] Use IPointer::SButtonEvent --- src/main.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c7953a2..8ec92a2 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 @@ -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()); From aa7262d3a4564062f97b9cfdad47fd914cfb80f2 Mon Sep 17 00:00:00 2001 From: Nic Wells Date: Thu, 30 May 2024 13:02:28 +0200 Subject: [PATCH 4/4] Update hyprpm with latest --- hyprpm.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hyprpm.toml b/hyprpm.toml index 3222db7..cad415f 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -10,7 +10,7 @@ commit_pins = [ ["1c460e98f870676b15871fe4e5bfeb1a32a3d6d8", "2af0c1e87e3cdcef3c8f9c7def918982312d0b75"], ["c5e28ebcfe00a510922779b2c568cfa52a317445", "c5e28ebcfe00a510922779b2c568cfa52a317445"], ["0c513ba91bd73106be99e35b1a020d24e5ae874a", "e44b956dd4b7507489219bd2b02a3886d547b7e2"], - ["cba1ade848feac44b2eda677503900639581c3f4", "d1f7c1f7e9e6176ed9184a7c34071e1b1e911fe8"], + ["cba1ade848feac44b2eda677503900639581c3f4", "49dbe19e08f963e01ac4ba17b42719956d390ec7"], ] build = [ "make all"