From 8453fbf4eb0af2e3265fd34a693b7d0e9167f4d2 Mon Sep 17 00:00:00 2001 From: Mike Will Date: Tue, 15 Jul 2025 16:24:40 -0400 Subject: snap: fix `border_overlap` option for monitor snapping (#10987) --- hyprtester/plugin/src/main.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'hyprtester/plugin/src/main.cpp') 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 #include +#include +#include +#include #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"}; } -- cgit v1.2.3