aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-02-28 12:58:52 +0100
committerSimon Ser <contact@emersion.fr>2023-04-14 18:34:54 +0200
commit4118c493499fc03fd2c77a061b4905cd7523d67c (patch)
tree8aaee873da0c9fc2dcbf2857ef6dfab097cdcf32 /sway
parentfcec5817483ba279b714acf6d81f5d7a3688b092 (diff)
Use output_match_name_or_id() in workspace functions
Diffstat (limited to 'sway')
-rw-r--r--sway/tree/workspace.c25
1 files changed, 4 insertions, 21 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index ee940466..18218768 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -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;
}