This commit is contained in:
Vaxry 2025-11-14 17:27:02 +00:00 committed by Mihai Fufezan
parent 3841398e4a
commit a64b6f6d7b
Signed by: fufexan
SSH key fingerprint: SHA256:SdnKmEpJrDu1+2UO1QpB/Eg4HKcdDi6n+xSRqFNJVpg
4 changed files with 60 additions and 8 deletions

View file

@ -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
}

View file

@ -11,6 +11,8 @@
#include <src/managers/input/InputManager.hpp>
#include <src/managers/PointerManager.hpp>
#include <src/managers/input/trackpad/TrackpadGestures.hpp>
#include <src/desktop/rule/windowRule/WindowRuleEffectContainer.hpp>
#include <src/desktop/rule/windowRule/WindowRuleApplicator.hpp>
#include <src/Compositor.hpp>
#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);

View file

@ -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"));

View file

@ -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