diff options
author | Simon Ser <contact@emersion.fr> | 2023-02-28 12:58:52 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-04-14 18:34:54 +0200 |
commit | 4118c493499fc03fd2c77a061b4905cd7523d67c (patch) | |
tree | 8aaee873da0c9fc2dcbf2857ef6dfab097cdcf32 | |
parent | Use output_match_name_or_id() in apply_output_config_to_outputs() (diff) | |
download | sway-4118c493499fc03fd2c77a061b4905cd7523d67c.tar.gz sway-4118c493499fc03fd2c77a061b4905cd7523d67c.tar.zst sway-4118c493499fc03fd2c77a061b4905cd7523d67c.zip |
Use output_match_name_or_id() in workspace functions
-rw-r--r-- | sway/tree/workspace.c | 25 |
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) { | |||
176 | static bool workspace_valid_on_output(const char *output_name, | 176 | static bool workspace_valid_on_output(const char *output_name, |
177 | const char *ws_name) { | 177 | const char *ws_name) { |
178 | struct workspace_config *wsc = workspace_find_config(ws_name); | 178 | struct workspace_config *wsc = workspace_find_config(ws_name); |
179 | char identifier[128]; | ||
180 | struct sway_output *output = output_by_name_or_id(output_name); | 179 | struct sway_output *output = output_by_name_or_id(output_name); |
181 | if (!output) { | 180 | if (!output) { |
182 | return false; | 181 | return false; |
183 | } | 182 | } |
184 | output_name = output->wlr_output->name; | ||
185 | output_get_identifier(identifier, sizeof(identifier), output); | ||
186 | |||
187 | if (!wsc) { | 183 | if (!wsc) { |
188 | return true; | 184 | return true; |
189 | } | 185 | } |
190 | 186 | ||
191 | for (int i = 0; i < wsc->outputs->length; i++) { | 187 | for (int i = 0; i < wsc->outputs->length; i++) { |
192 | if (strcmp(wsc->outputs->items[i], "*") == 0 || | 188 | if (output_match_name_or_id(output, wsc->outputs->items[i])) { |
193 | strcmp(wsc->outputs->items[i], output_name) == 0 || | ||
194 | strcmp(wsc->outputs->items[i], identifier) == 0) { | ||
195 | return true; | 189 | return true; |
196 | } | 190 | } |
197 | } | 191 | } |
@@ -286,13 +280,10 @@ char *workspace_next_name(const char *output_name) { | |||
286 | // assignments primarily, falling back to bindings and numbers. | 280 | // assignments primarily, falling back to bindings and numbers. |
287 | struct sway_mode *mode = config->current_mode; | 281 | struct sway_mode *mode = config->current_mode; |
288 | 282 | ||
289 | char identifier[128]; | ||
290 | struct sway_output *output = output_by_name_or_id(output_name); | 283 | struct sway_output *output = output_by_name_or_id(output_name); |
291 | if (!output) { | 284 | if (!output) { |
292 | return NULL; | 285 | return NULL; |
293 | } | 286 | } |
294 | output_name = output->wlr_output->name; | ||
295 | output_get_identifier(identifier, sizeof(identifier), output); | ||
296 | 287 | ||
297 | int order = INT_MAX; | 288 | int order = INT_MAX; |
298 | char *target = NULL; | 289 | char *target = NULL; |
@@ -312,9 +303,7 @@ char *workspace_next_name(const char *output_name) { | |||
312 | } | 303 | } |
313 | bool found = false; | 304 | bool found = false; |
314 | for (int j = 0; j < wsc->outputs->length; ++j) { | 305 | for (int j = 0; j < wsc->outputs->length; ++j) { |
315 | if (strcmp(wsc->outputs->items[j], "*") == 0 || | 306 | if (output_match_name_or_id(output, wsc->outputs->items[j])) { |
316 | strcmp(wsc->outputs->items[j], output_name) == 0 || | ||
317 | strcmp(wsc->outputs->items[j], identifier) == 0) { | ||
318 | found = true; | 307 | found = true; |
319 | free(target); | 308 | free(target); |
320 | target = strdup(wsc->workspace); | 309 | target = strdup(wsc->workspace); |
@@ -654,15 +643,9 @@ void workspace_output_add_priority(struct sway_workspace *workspace, | |||
654 | 643 | ||
655 | struct sway_output *workspace_output_get_highest_available( | 644 | struct sway_output *workspace_output_get_highest_available( |
656 | struct sway_workspace *ws, struct sway_output *exclude) { | 645 | struct sway_workspace *ws, struct sway_output *exclude) { |
657 | char exclude_id[128] = {'\0'}; | ||
658 | if (exclude) { | ||
659 | output_get_identifier(exclude_id, sizeof(exclude_id), exclude); | ||
660 | } | ||
661 | |||
662 | for (int i = 0; i < ws->output_priority->length; i++) { | 646 | for (int i = 0; i < ws->output_priority->length; i++) { |
663 | char *name = ws->output_priority->items[i]; | 647 | const char *name = ws->output_priority->items[i]; |
664 | if (exclude && (strcmp(name, exclude->wlr_output->name) == 0 | 648 | if (exclude && output_match_name_or_id(exclude, name)) { |
665 | || strcmp(name, exclude_id) == 0)) { | ||
666 | continue; | 649 | continue; |
667 | } | 650 | } |
668 | 651 | ||