diff options
author | emersion <contact@emersion.fr> | 2018-10-27 21:26:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-27 21:26:19 +0200 |
commit | e3a0e3322b4fd45ead0ec908eefd4cd6e41eadc1 (patch) | |
tree | 539c04a7755907648b4345e86ad9e6ffa90b7472 | |
parent | Merge pull request #3003 from Hi-Angel/master (diff) | |
parent | Use output identifier for workspace config (diff) | |
download | sway-e3a0e3322b4fd45ead0ec908eefd4cd6e41eadc1.tar.gz sway-e3a0e3322b4fd45ead0ec908eefd4cd6e41eadc1.tar.zst sway-e3a0e3322b4fd45ead0ec908eefd4cd6e41eadc1.zip |
Merge pull request #3000 from Robinhuett/workspace_address_output_by_name
Use output identifier for workspace config
-rw-r--r-- | include/sway/output.h | 2 | ||||
-rw-r--r-- | sway/desktop/output.c | 13 | ||||
-rw-r--r-- | sway/tree/workspace.c | 10 |
3 files changed, 24 insertions, 1 deletions
diff --git a/include/sway/output.h b/include/sway/output.h index 369e62ce..22cb352a 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -86,6 +86,8 @@ void output_damage_whole_container(struct sway_output *output, | |||
86 | 86 | ||
87 | struct sway_output *output_by_name(const char *name); | 87 | struct sway_output *output_by_name(const char *name); |
88 | 88 | ||
89 | struct sway_output *output_by_identifier(const char *identifier); | ||
90 | |||
89 | void output_sort_workspaces(struct sway_output *output); | 91 | void output_sort_workspaces(struct sway_output *output); |
90 | 92 | ||
91 | struct output_config *output_find_config(struct sway_output *output); | 93 | struct output_config *output_find_config(struct sway_output *output); |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index ed9300bb..4d6c0336 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -39,6 +39,19 @@ struct sway_output *output_by_name(const char *name) { | |||
39 | return NULL; | 39 | return NULL; |
40 | } | 40 | } |
41 | 41 | ||
42 | struct sway_output *output_by_identifier(const char *identifier) { | ||
43 | for (int i = 0; i < root->outputs->length; ++i) { | ||
44 | struct sway_output *output = root->outputs->items[i]; | ||
45 | char output_identifier[128]; | ||
46 | snprintf(output_identifier, sizeof(output_identifier), "%s %s %s", output->wlr_output->make, | ||
47 | output->wlr_output->model, output->wlr_output->serial); | ||
48 | if (strcasecmp(output_identifier, identifier) == 0) { | ||
49 | return output; | ||
50 | } | ||
51 | } | ||
52 | return NULL; | ||
53 | } | ||
54 | |||
42 | /** | 55 | /** |
43 | * Rotate a child's position relative to a parent. The parent size is (pw, ph), | 56 | * Rotate a child's position relative to a parent. The parent size is (pw, ph), |
44 | * the child position is (*sx, *sy) and its size is (sw, sh). | 57 | * the child position is (*sx, *sy) and its size is (sw, sh). |
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 27e9ac7a..05cda5c0 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -35,6 +35,10 @@ struct sway_output *workspace_get_initial_output(const char *name) { | |||
35 | struct workspace_config *wsc = workspace_find_config(name); | 35 | struct workspace_config *wsc = workspace_find_config(name); |
36 | if (wsc && wsc->output) { | 36 | if (wsc && wsc->output) { |
37 | struct sway_output *output = output_by_name(wsc->output); | 37 | struct sway_output *output = output_by_name(wsc->output); |
38 | if (!output) { | ||
39 | output = output_by_identifier(wsc->output); | ||
40 | } | ||
41 | |||
38 | if (output) { | 42 | if (output) { |
39 | return output; | 43 | return output; |
40 | } | 44 | } |
@@ -143,7 +147,11 @@ void workspace_consider_destroy(struct sway_workspace *ws) { | |||
143 | static bool workspace_valid_on_output(const char *output_name, | 147 | static bool workspace_valid_on_output(const char *output_name, |
144 | const char *ws_name) { | 148 | const char *ws_name) { |
145 | struct workspace_config *wsc = workspace_find_config(ws_name); | 149 | struct workspace_config *wsc = workspace_find_config(ws_name); |
146 | return !wsc || !wsc->output || strcmp(wsc->output, output_name) == 0; | 150 | char identifier[128]; |
151 | struct sway_output *output = output_by_name(output_name); | ||
152 | output_get_identifier(identifier, sizeof(identifier), output); | ||
153 | |||
154 | return !wsc || !wsc->output || strcmp(wsc->output, output_name) == 0 || strcasecmp(identifier, output_name) == 0; | ||
147 | } | 155 | } |
148 | 156 | ||
149 | static void workspace_name_from_binding(const struct sway_binding * binding, | 157 | static void workspace_name_from_binding(const struct sway_binding * binding, |