Merge pull request #1721 from herlev/sort-workspaces-by-number
This commit is contained in:
commit
d01fda6fae
|
@ -152,6 +152,7 @@ class WorkspaceManager : public AModule {
|
||||||
|
|
||||||
bool sort_by_name_ = true;
|
bool sort_by_name_ = true;
|
||||||
bool sort_by_coordinates_ = true;
|
bool sort_by_coordinates_ = true;
|
||||||
|
bool sort_by_number_ = false;
|
||||||
bool all_outputs_ = false;
|
bool all_outputs_ = false;
|
||||||
bool active_only_ = false;
|
bool active_only_ = false;
|
||||||
bool creation_delayed_ = false;
|
bool creation_delayed_ = false;
|
||||||
|
|
|
@ -33,6 +33,11 @@ Addressed by *wlr/workspaces*
|
||||||
Note that if both *sort-by-name* and *sort-by-coordinates* are true sort by name will be first.
|
Note that if both *sort-by-name* and *sort-by-coordinates* are true sort by name will be first.
|
||||||
If both are false - sort by id will be performed.
|
If both are false - sort by id will be performed.
|
||||||
|
|
||||||
|
*sort-by-number*: ++
|
||||||
|
typeof: bool ++
|
||||||
|
default: false ++
|
||||||
|
If set to true, workspace names will be sorted numerically. Takes presedence over any other sort-by option.
|
||||||
|
|
||||||
*all-outputs*: ++
|
*all-outputs*: ++
|
||||||
typeof: bool ++
|
typeof: bool ++
|
||||||
default: false ++
|
default: false ++
|
||||||
|
@ -75,7 +80,8 @@ Additional to workspace name matching, the following *format-icons* can be set.
|
||||||
"5": "",
|
"5": "",
|
||||||
"focused": "",
|
"focused": "",
|
||||||
"default": ""
|
"default": ""
|
||||||
}
|
},
|
||||||
|
"sort-by-number": true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,11 @@ WorkspaceManager::WorkspaceManager(const std::string &id, const waybar::Bar &bar
|
||||||
sort_by_coordinates_ = config_sort_by_coordinates.asBool();
|
sort_by_coordinates_ = config_sort_by_coordinates.asBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto config_sort_by_number = config_["sort-by-number"];
|
||||||
|
if (config_sort_by_number.isBool()) {
|
||||||
|
sort_by_number_ = config_sort_by_number.asBool();
|
||||||
|
}
|
||||||
|
|
||||||
auto config_all_outputs = config_["all-outputs"];
|
auto config_all_outputs = config_["all-outputs"];
|
||||||
if (config_all_outputs.isBool()) {
|
if (config_all_outputs.isBool()) {
|
||||||
all_outputs_ = config_all_outputs.asBool();
|
all_outputs_ = config_all_outputs.asBool();
|
||||||
|
@ -61,6 +66,12 @@ auto WorkspaceManager::workspace_comparator() const
|
||||||
auto is_name_less = lhs->get_name() < rhs->get_name();
|
auto is_name_less = lhs->get_name() < rhs->get_name();
|
||||||
auto is_name_eq = lhs->get_name() == rhs->get_name();
|
auto is_name_eq = lhs->get_name() == rhs->get_name();
|
||||||
auto is_coords_less = lhs->get_coords() < rhs->get_coords();
|
auto is_coords_less = lhs->get_coords() < rhs->get_coords();
|
||||||
|
auto is_number_less = std::stoi(lhs->get_name()) < std::stoi(rhs->get_name());
|
||||||
|
|
||||||
|
if (sort_by_number_) {
|
||||||
|
return is_number_less;
|
||||||
|
}
|
||||||
|
|
||||||
if (sort_by_name_) {
|
if (sort_by_name_) {
|
||||||
if (sort_by_coordinates_) {
|
if (sort_by_coordinates_) {
|
||||||
return is_name_eq ? is_coords_less : is_name_less;
|
return is_name_eq ? is_coords_less : is_name_less;
|
||||||
|
|
Loading…
Reference in New Issue