create workspace now respects selected output again
This commit is contained in:
parent
582ed32c9e
commit
7fce5f1063
2 changed files with 7 additions and 6 deletions
|
@ -23,7 +23,7 @@ public:
|
|||
if (selectedOutput != nullptr)
|
||||
cmd << "focus output " << selectedOutput->node.name << " , ";
|
||||
|
||||
cmd << "workspace " << createNewWorkspaceId({});
|
||||
cmd << "workspace " << createNewWorkspaceId({}, selectedOutput);
|
||||
auto resp = SwayTreeModel::sway.sendIPC(swaymsg(0, cmd.str()));
|
||||
std::cout << resp.msg << "\n";
|
||||
QApplication::quit();
|
||||
|
|
|
@ -32,7 +32,7 @@ protected:
|
|||
return containerIds;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string createNewWorkspaceId(const std::set<const SwayTreeNode *> &allowedContainers) const {
|
||||
[[nodiscard]] std::string createNewWorkspaceId(const std::set<const SwayTreeNode *> &allowedContainers, const SwayTreeNode* preferredOutput = nullptr) const {
|
||||
std::set<std::string> candidates;
|
||||
|
||||
for (auto *con: allowedContainers) {
|
||||
|
@ -40,14 +40,14 @@ protected:
|
|||
if (workspace == nullptr)
|
||||
continue;
|
||||
|
||||
if (allowedContainers.contains(workspace)) {
|
||||
if (allowedContainers.contains(workspace) && (preferredOutput == nullptr || preferredOutput == workspace->findOutput())) {
|
||||
candidates.insert(workspace->node.name);
|
||||
continue;
|
||||
}
|
||||
|
||||
auto containers = workspace->accumulateContainers();
|
||||
if (std::all_of(containers.begin(), containers.end(), [allowedContainers](const SwayTreeNode *container) {
|
||||
return allowedContainers.contains(container);
|
||||
if (std::all_of(containers.begin(), containers.end(), [allowedContainers, preferredOutput](const SwayTreeNode *container) {
|
||||
return allowedContainers.contains(container) && (preferredOutput == nullptr || preferredOutput == container->findOutput());
|
||||
})) {
|
||||
candidates.insert(workspace->node.name);
|
||||
}
|
||||
|
@ -63,7 +63,8 @@ protected:
|
|||
do {
|
||||
newWorkspace++;
|
||||
workspaceNode = getModel()->getRoot()->findWorkspaceByName(std::to_string(newWorkspace));
|
||||
} while (workspaceNode != nullptr && workspaceNode->childCount() != 0);
|
||||
} while (workspaceNode != nullptr && workspaceNode->childCount() != 0
|
||||
&& (preferredOutput != nullptr && preferredOutput == workspaceNode->findOutput()));
|
||||
|
||||
return std::to_string(newWorkspace);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue