windowrules: rewrite completely (#12269)
Reworks the window rule syntax completely --------- Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
This commit is contained in:
parent
95ee08b340
commit
c2670e9ab9
93 changed files with 3574 additions and 2255 deletions
|
|
@ -246,12 +246,15 @@ static bool test() {
|
|||
|
||||
testSwapWindow();
|
||||
|
||||
getFromSocket("/dispatch workspace 1");
|
||||
|
||||
NLog::log("{}Testing minsize/maxsize rules for tiled windows", Colors::YELLOW);
|
||||
{
|
||||
// Enable the config for testing, test max/minsize for tiled windows and centering
|
||||
OK(getFromSocket("/keyword misc:size_limits_tiled 1"));
|
||||
OK(getFromSocket("/keyword windowrule maxsize 1500 500, class:kitty_maxsize"));
|
||||
OK(getFromSocket("/keyword windowrule minsize 1200 500, class:kitty_maxsize"));
|
||||
OK(getFromSocket("/keyword windowrule[kitty-max-rule]:match:class kitty_maxsize"));
|
||||
OK(getFromSocket("/keyword windowrule[kitty-max-rule]:max_size 1500 500"));
|
||||
OK(getFromSocket("r/keyword windowrule[kitty-max-rule]:min_size 1200 500"));
|
||||
if (!spawnKitty("kitty_maxsize"))
|
||||
return false;
|
||||
|
||||
|
|
@ -297,29 +300,127 @@ static bool test() {
|
|||
EXPECT_CONTAINS(str, "floating: 1");
|
||||
EXPECT_CONTAINS(str, std::format("size: {},{}", SIZE, SIZE));
|
||||
EXPECT_NOT_CONTAINS(str, "pinned: 1");
|
||||
OK(getFromSocket("/keyword windowrule plugin:someplugin:variable, class:wr_kitty"));
|
||||
OK(getFromSocket("/keyword windowrule plugin:someplugin:variable 10, class:wr_kitty"));
|
||||
OK(getFromSocket("/keyword windowrule workspace 1, class:wr_kitty"));
|
||||
OK(getFromSocket("/keyword windowrule workspace special:magic, class:magic_kitty"));
|
||||
}
|
||||
|
||||
if (!spawnKitty("magic_kitty"))
|
||||
return false;
|
||||
EXPECT_CONTAINS(getFromSocket("/activewindow"), "special:magic");
|
||||
OK(getFromSocket("/keyword windowrule[wr-kitty-stuff]:opacity 0.5 0.5 override"));
|
||||
|
||||
{
|
||||
auto str = getFromSocket("/getprop active opacity");
|
||||
EXPECT_CONTAINS(str, "0.5");
|
||||
}
|
||||
|
||||
OK(getFromSocket("/keyword windowrule[special-magic-kitty]:match:class magic_kitty"));
|
||||
OK(getFromSocket("/keyword windowrule[special-magic-kitty]:workspace special:magic"));
|
||||
|
||||
if (!spawnKitty("magic_kitty"))
|
||||
return false;
|
||||
|
||||
{
|
||||
auto str = getFromSocket("/activewindow");
|
||||
EXPECT_CONTAINS(str, "special:magic");
|
||||
EXPECT_NOT_CONTAINS(str, "workspace: 9");
|
||||
}
|
||||
|
||||
NLog::log("{}Testing faulty rules", Colors::YELLOW);
|
||||
{
|
||||
const auto PARAM = "Invalid parameter";
|
||||
const auto RULE = "Invalid value";
|
||||
const auto NORULE = "no rules provided";
|
||||
EXPECT_CONTAINS(getFromSocket("/keyword windowrule notarule, class:wr_kitty"), RULE)
|
||||
EXPECT_CONTAINS(getFromSocket("/keyword windowrule class:wr_kitty"), NORULE)
|
||||
EXPECT_CONTAINS(getFromSocket("/keyword windowrule float, class:wr_kitty, size"), PARAM)
|
||||
EXPECT_CONTAINS(getFromSocket("/keyword windowrule float, classI:wr_kitty"), PARAM)
|
||||
EXPECT_CONTAINS(getFromSocket("/keyword windowrule workspace:, class:wr_kitty"), NORULE)
|
||||
if (auto str = getFromSocket("/monitors"); str.contains("magic)")) {
|
||||
OK(getFromSocket("/dispatch togglespecialworkspace magic"));
|
||||
}
|
||||
|
||||
Tests::killAllWindows();
|
||||
|
||||
if (!spawnKitty("tag_kitty"))
|
||||
return false;
|
||||
|
||||
{
|
||||
auto str = getFromSocket("/activewindow");
|
||||
EXPECT_CONTAINS(str, "floating: 1");
|
||||
}
|
||||
|
||||
OK(getFromSocket("/reload"));
|
||||
Tests::killAllWindows();
|
||||
|
||||
// test rules that overlap effects but don't overlap props
|
||||
OK(getFromSocket("/keyword windowrule match:class overlap_kitty, border_size 0"));
|
||||
OK(getFromSocket("/keyword windowrule match:fullscreen false, border_size 10"));
|
||||
|
||||
if (!spawnKitty("overlap_kitty"))
|
||||
return false;
|
||||
|
||||
{
|
||||
auto str = getFromSocket("/getprop active border_size");
|
||||
EXPECT_CONTAINS(str, "10");
|
||||
}
|
||||
|
||||
OK(getFromSocket("/reload"));
|
||||
Tests::killAllWindows();
|
||||
|
||||
OK(getFromSocket("/keyword general:border_size 0"));
|
||||
OK(getFromSocket("/keyword windowrule match:float true, border_size 10"));
|
||||
|
||||
if (!spawnKitty("border_kitty"))
|
||||
return false;
|
||||
|
||||
{
|
||||
auto str = getFromSocket("/getprop active border_size");
|
||||
EXPECT_CONTAINS(str, "0");
|
||||
}
|
||||
|
||||
OK(getFromSocket("/dispatch togglefloating"));
|
||||
|
||||
{
|
||||
auto str = getFromSocket("/getprop active border_size");
|
||||
EXPECT_CONTAINS(str, "10");
|
||||
}
|
||||
|
||||
OK(getFromSocket("/dispatch togglefloating"));
|
||||
|
||||
{
|
||||
auto str = getFromSocket("/getprop active border_size");
|
||||
EXPECT_CONTAINS(str, "0");
|
||||
}
|
||||
|
||||
OK(getFromSocket("/reload"));
|
||||
Tests::killAllWindows();
|
||||
|
||||
// test expression rules
|
||||
OK(getFromSocket("/keyword windowrule match:class expr_kitty, float yes, size monitor_w*0.5 monitor_h*0.5, move 20+(monitor_w*0.1) monitor_h*0.5"));
|
||||
|
||||
if (!spawnKitty("expr_kitty"))
|
||||
return false;
|
||||
|
||||
{
|
||||
auto str = getFromSocket("/activewindow");
|
||||
EXPECT_CONTAINS(str, "floating: 1");
|
||||
EXPECT_CONTAINS(str, "at: 212,540");
|
||||
EXPECT_CONTAINS(str, "size: 960,540");
|
||||
}
|
||||
|
||||
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"));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue