diff --git a/example/hyprland.conf b/example/hyprland.conf index 3030bd37d..1bccaa2a2 100644 --- a/example/hyprland.conf +++ b/example/hyprland.conf @@ -323,9 +323,9 @@ windowrule { match:class = ^$ match:title = ^$ match:xwayland = true - match:floating = true + match:float = true match:fullscreen = false - match:pinned = false + match:pin = false no_focus = true } diff --git a/hyprtester/plugin/src/main.cpp b/hyprtester/plugin/src/main.cpp index 1d0b68dcc..0a5d9a545 100644 --- a/hyprtester/plugin/src/main.cpp +++ b/hyprtester/plugin/src/main.cpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #undef private @@ -245,6 +247,27 @@ static SDispatchResult keybind(std::string in) { return {}; } +static Desktop::Rule::CWindowRuleEffectContainer::storageType ruleIDX = 0; + +// +static SDispatchResult addRule(std::string in) { + ruleIDX = Desktop::Rule::windowEffects()->registerEffect("plugin_rule"); + return {}; +} + +static SDispatchResult checkRule(std::string in) { + if (!g_pCompositor->m_lastWindow) + return {.success = false, .error = "No window"}; + + if (!g_pCompositor->m_lastWindow->m_ruleApplicator->m_otherProps.props.contains(ruleIDX)) + return {.success = false, .error = "No rule"}; + + if (g_pCompositor->m_lastWindow->m_ruleApplicator->m_otherProps.props[ruleIDX]->effect != "effect") + return {.success = false, .error = "Effect isn't \"effect\""}; + + return {}; +} + APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { PHANDLE = handle; @@ -255,6 +278,8 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:gesture", ::simulateGesture); HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:scroll", ::scroll); HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:keybind", ::keybind); + HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:add_rule", ::addRule); + HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:check_rule", ::checkRule); // init mouse g_mouse = CTestMouse::create(false); diff --git a/hyprtester/src/tests/main/window.cpp b/hyprtester/src/tests/main/window.cpp index b17282f18..5cabb4b2b 100644 --- a/hyprtester/src/tests/main/window.cpp +++ b/hyprtester/src/tests/main/window.cpp @@ -350,6 +350,33 @@ static bool test() { EXPECT_CONTAINS(str, "10"); } + OK(getFromSocket("/reload")); + Tests::killAllWindows(); + + OK(getFromSocket("/dispatch plugin:test:add_rule")); + OK(getFromSocket("/reload")); + + OK(getFromSocket("/keyword windowrule match:class plugin_kitty, plugin_rule effect")); + + if (!spawnKitty("plugin_kitty")) + return false; + + OK(getFromSocket("/dispatch plugin:test:check_rule")); + + OK(getFromSocket("/reload")); + Tests::killAllWindows(); + + OK(getFromSocket("/dispatch plugin:test:add_rule")); + OK(getFromSocket("/reload")); + + OK(getFromSocket("/keyword windowrule[test-plugin-rule]:match:class plugin_kitty")); + OK(getFromSocket("/keyword windowrule[test-plugin-rule]:plugin_rule effect")); + + if (!spawnKitty("plugin_kitty")) + return false; + + OK(getFromSocket("/dispatch plugin:test:check_rule")); + NLog::log("{}Reloading config", Colors::YELLOW); OK(getFromSocket("/reload")); diff --git a/hyprtester/test.conf b/hyprtester/test.conf index cff32f77d..ac28bc5a6 100644 --- a/hyprtester/test.conf +++ b/hyprtester/test.conf @@ -332,9 +332,9 @@ windowrule { match:class = ^$ match:title = ^$ match:xwayland = true - match:floating = true + match:float = true match:fullscreen = false - match:pinned = false + match:pin = false no_focus = true } @@ -344,8 +344,8 @@ workspace = n[s:window] f[1], gapsout:0, gapsin:0 windowrule { name = smart-gaps-1 - match:floating = false - match:on_workspace = n[s:window] w[tv1] + match:float = false + match:workspace = n[s:window] w[tv1] border_size = 0 rounding = 0 @@ -353,8 +353,8 @@ windowrule { windowrule { name = smart-gaps-2 - match:floating = false - match:on_workspace = n[s:window] f[1] + match:float = false + match:workspace = n[s:window] f[1] border_size = 0 rounding = 0