desktop/rules: fix empty workspace handling (#13544)
This commit is contained in:
parent
b7dfb47566
commit
4c60d9df70
2 changed files with 49 additions and 2 deletions
|
|
@ -613,6 +613,51 @@ static bool testPinnedWorkspacesValid() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool testWindowRuleWorkspaceEmpty() {
|
||||||
|
NLog::log("{}Testing windowrule workspace empty", Colors::YELLOW);
|
||||||
|
OK(getFromSocket("/reload"));
|
||||||
|
|
||||||
|
OK(getFromSocket("/keyword windowrule match:class kitty_A, workspace empty"));
|
||||||
|
OK(getFromSocket("/keyword windowrule match:class kitty_B, workspace emptyn"));
|
||||||
|
|
||||||
|
getFromSocket("/dispatch workspace 3");
|
||||||
|
|
||||||
|
if (!spawnKitty("kitty")) {
|
||||||
|
NLog::log("{}Error: failed to spawn kitty", Colors::RED);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/activewindow");
|
||||||
|
EXPECT(str.contains("workspace: 3"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!spawnKitty("kitty_A")) {
|
||||||
|
NLog::log("{}Error: failed to spawn kitty", Colors::RED);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/activewindow");
|
||||||
|
EXPECT(str.contains("workspace: 1"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
getFromSocket("/dispatch workspace 3");
|
||||||
|
if (!spawnKitty("kitty_B")) {
|
||||||
|
NLog::log("{}Error: failed to spawn kitty", Colors::RED);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/activewindow");
|
||||||
|
EXPECT(str.contains("workspace: 4"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Tests::killAllWindows();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool test() {
|
static bool test() {
|
||||||
NLog::log("{}Testing windows", Colors::GREEN);
|
NLog::log("{}Testing windows", Colors::GREEN);
|
||||||
|
|
||||||
|
|
@ -1076,6 +1121,7 @@ static bool test() {
|
||||||
testInitialFloatSize();
|
testInitialFloatSize();
|
||||||
testWindowRuleFocusOnActivate();
|
testWindowRuleFocusOnActivate();
|
||||||
testPinnedWorkspacesValid();
|
testPinnedWorkspacesValid();
|
||||||
|
testWindowRuleWorkspaceEmpty();
|
||||||
|
|
||||||
NLog::log("{}Reloading config", Colors::YELLOW);
|
NLog::log("{}Reloading config", Colors::YELLOW);
|
||||||
OK(getFromSocket("/reload"));
|
OK(getFromSocket("/reload"));
|
||||||
|
|
|
||||||
|
|
@ -1871,11 +1871,12 @@ void CWindow::mapWindow() {
|
||||||
if (WORKSPACEARGS.contains("silent"))
|
if (WORKSPACEARGS.contains("silent"))
|
||||||
workspaceSilent = true;
|
workspaceSilent = true;
|
||||||
|
|
||||||
if (WORKSPACEARGS.contains("empty") && PWORKSPACE->getWindows() <= 1) {
|
auto joined = WORKSPACEARGS.join(" ", 0, workspaceSilent ? WORKSPACEARGS.size() - 1 : 0);
|
||||||
|
if (joined.starts_with("empty") && PWORKSPACE->getWindows() == 0) {
|
||||||
requestedWorkspaceID = PWORKSPACE->m_id;
|
requestedWorkspaceID = PWORKSPACE->m_id;
|
||||||
requestedWorkspaceName = PWORKSPACE->m_name;
|
requestedWorkspaceName = PWORKSPACE->m_name;
|
||||||
} else {
|
} else {
|
||||||
auto result = getWorkspaceIDNameFromString(WORKSPACEARGS.join(" ", 0, workspaceSilent ? WORKSPACEARGS.size() - 1 : 0));
|
auto result = getWorkspaceIDNameFromString(joined);
|
||||||
requestedWorkspaceID = result.id;
|
requestedWorkspaceID = result.id;
|
||||||
requestedWorkspaceName = result.name;
|
requestedWorkspaceName = result.name;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue