mirror of
https://github.com/swaywm/sway.git
synced 2024-11-21 15:31:28 +00:00
Use output_match_name_or_id() in workspace functions
This commit is contained in:
parent
fcec581748
commit
4118c49349
|
@ -176,22 +176,16 @@ void workspace_consider_destroy(struct sway_workspace *ws) {
|
|||
static bool workspace_valid_on_output(const char *output_name,
|
||||
const char *ws_name) {
|
||||
struct workspace_config *wsc = workspace_find_config(ws_name);
|
||||
char identifier[128];
|
||||
struct sway_output *output = output_by_name_or_id(output_name);
|
||||
if (!output) {
|
||||
return false;
|
||||
}
|
||||
output_name = output->wlr_output->name;
|
||||
output_get_identifier(identifier, sizeof(identifier), output);
|
||||
|
||||
if (!wsc) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < wsc->outputs->length; i++) {
|
||||
if (strcmp(wsc->outputs->items[i], "*") == 0 ||
|
||||
strcmp(wsc->outputs->items[i], output_name) == 0 ||
|
||||
strcmp(wsc->outputs->items[i], identifier) == 0) {
|
||||
if (output_match_name_or_id(output, wsc->outputs->items[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -286,13 +280,10 @@ char *workspace_next_name(const char *output_name) {
|
|||
// assignments primarily, falling back to bindings and numbers.
|
||||
struct sway_mode *mode = config->current_mode;
|
||||
|
||||
char identifier[128];
|
||||
struct sway_output *output = output_by_name_or_id(output_name);
|
||||
if (!output) {
|
||||
return NULL;
|
||||
}
|
||||
output_name = output->wlr_output->name;
|
||||
output_get_identifier(identifier, sizeof(identifier), output);
|
||||
|
||||
int order = INT_MAX;
|
||||
char *target = NULL;
|
||||
|
@ -312,9 +303,7 @@ char *workspace_next_name(const char *output_name) {
|
|||
}
|
||||
bool found = false;
|
||||
for (int j = 0; j < wsc->outputs->length; ++j) {
|
||||
if (strcmp(wsc->outputs->items[j], "*") == 0 ||
|
||||
strcmp(wsc->outputs->items[j], output_name) == 0 ||
|
||||
strcmp(wsc->outputs->items[j], identifier) == 0) {
|
||||
if (output_match_name_or_id(output, wsc->outputs->items[j])) {
|
||||
found = true;
|
||||
free(target);
|
||||
target = strdup(wsc->workspace);
|
||||
|
@ -654,15 +643,9 @@ void workspace_output_add_priority(struct sway_workspace *workspace,
|
|||
|
||||
struct sway_output *workspace_output_get_highest_available(
|
||||
struct sway_workspace *ws, struct sway_output *exclude) {
|
||||
char exclude_id[128] = {'\0'};
|
||||
if (exclude) {
|
||||
output_get_identifier(exclude_id, sizeof(exclude_id), exclude);
|
||||
}
|
||||
|
||||
for (int i = 0; i < ws->output_priority->length; i++) {
|
||||
char *name = ws->output_priority->items[i];
|
||||
if (exclude && (strcmp(name, exclude->wlr_output->name) == 0
|
||||
|| strcmp(name, exclude_id) == 0)) {
|
||||
const char *name = ws->output_priority->items[i];
|
||||
if (exclude && output_match_name_or_id(exclude, name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue