diff options
-rw-r--r-- | sway/tree/workspace.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index ed24b4fd..4f1c4a64 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -113,7 +113,10 @@ struct sway_workspace *workspace_create(struct sway_output *output, // Add output priorities for (int i = 0; i < wsc->outputs->length; ++i) { - list_add(ws->output_priority, strdup(wsc->outputs->items[i])); + char *name = wsc->outputs->items[i]; + if (strcmp(name, "*") != 0) { + list_add(ws->output_priority, strdup(name)); + } } } } @@ -183,6 +186,10 @@ static bool workspace_valid_on_output(const char *output_name, struct workspace_config *wsc = workspace_find_config(ws_name); char identifier[128]; struct sway_output *output = output_by_name(output_name); + if (!output) { + output = output_by_identifier(output_name); + output_name = output->wlr_output->name; + } output_get_identifier(identifier, sizeof(identifier), output); if (!wsc) { @@ -190,7 +197,8 @@ static bool workspace_valid_on_output(const char *output_name, } for (int i = 0; i < wsc->outputs->length; i++) { - if (strcmp(wsc->outputs->items[i], output_name) == 0 || + if (strcmp(wsc->outputs->items[i], "*") == 0 || + strcmp(wsc->outputs->items[i], output_name) == 0 || strcmp(wsc->outputs->items[i], identifier) == 0) { return true; } @@ -286,6 +294,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(output_name); + output_get_identifier(identifier, sizeof(identifier), output); + int order = INT_MAX; char *target = NULL; for (int i = 0; i < mode->keysym_bindings->length; ++i) { @@ -304,7 +316,9 @@ 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], output_name) == 0) { + if (strcmp(wsc->outputs->items[j], "*") == 0 || + strcmp(wsc->outputs->items[j], output_name) == 0 || + strcmp(wsc->outputs->items[j], identifier) == 0) { found = true; free(target); target = strdup(wsc->workspace); @@ -525,9 +539,15 @@ 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 && strcasecmp(name, exclude->wlr_output->name) == 0) { + if (exclude && (strcmp(name, exclude->wlr_output->name) == 0 + || strcmp(name, exclude_id) == 0)) { continue; } @@ -535,6 +555,11 @@ struct sway_output *workspace_output_get_highest_available( if (output) { return output; } + + output = output_by_identifier(name); + if (output) { + return output; + } } return NULL; |