diff options
| author | Mike Will <myQwil@gmail.com> | 2025-07-15 16:24:40 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-15 22:24:40 +0200 |
| commit | 8453fbf4eb0af2e3265fd34a693b7d0e9167f4d2 (patch) | |
| tree | 06f0f728453228226388f1cad124f306a538c60a /hyprtester/plugin/src/main.cpp | |
| parent | e15014e031589e1df2dc29a5ce94325676796ac4 (diff) | |
snap: fix `border_overlap` option for monitor snapping (#10987)
Diffstat (limited to 'hyprtester/plugin/src/main.cpp')
| -rw-r--r-- | hyprtester/plugin/src/main.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/hyprtester/plugin/src/main.cpp b/hyprtester/plugin/src/main.cpp index 1a7136d9..17b1e02a 100644 --- a/hyprtester/plugin/src/main.cpp +++ b/hyprtester/plugin/src/main.cpp @@ -6,6 +6,9 @@ #define private public #include <src/config/ConfigManager.hpp> #include <src/config/ConfigDescriptions.hpp> +#include <src/layout/IHyprLayout.hpp> +#include <src/managers/LayoutManager.hpp> +#include <src/Compositor.hpp> #undef private #include "globals.hpp" @@ -30,10 +33,26 @@ static SDispatchResult test(std::string in) { }; } +// Trigger a snap move event for the active window +static SDispatchResult snapMove(std::string in) { + const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock(); + if (!PLASTWINDOW->m_isFloating) + return {.success = false, .error = "Window must be floating"}; + + Vector2D pos = PLASTWINDOW->m_realPosition->goal(); + Vector2D size = PLASTWINDOW->m_realSize->goal(); + + g_pLayoutManager->getCurrentLayout()->performSnap(pos, size, PLASTWINDOW, MBIND_MOVE, -1, size); + *PLASTWINDOW->m_realPosition = pos.round(); + + return {}; +} + APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { PHANDLE = handle; HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:test", ::test); + HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:snapmove", ::snapMove); return {"hyprtestplugin", "hyprtestplugin", "Vaxry", "1.0"}; } |
