diff options
-rw-r--r-- | sway/commands.c | 2 | ||||
-rw-r--r-- | sway/container.c | 33 | ||||
-rw-r--r-- | sway/focus.c | 2 |
3 files changed, 22 insertions, 15 deletions
diff --git a/sway/commands.c b/sway/commands.c index 487b6a8e..409afce9 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -2325,7 +2325,7 @@ static struct cmd_results *cmd_workspace(int argc, char **argv) { | |||
2325 | // Handle workspace next/prev | 2325 | // Handle workspace next/prev |
2326 | swayc_t *ws = NULL; | 2326 | swayc_t *ws = NULL; |
2327 | if (argc == 2) { | 2327 | if (argc == 2) { |
2328 | if (!(ws=workspace_by_number(argv[1]))) { | 2328 | if (!(ws = workspace_by_number(argv[1]))) { |
2329 | ws = workspace_create(argv[1]); | 2329 | ws = workspace_create(argv[1]); |
2330 | } | 2330 | } |
2331 | } else if (strcasecmp(argv[0], "next") == 0) { | 2331 | } else if (strcasecmp(argv[0], "next") == 0) { |
diff --git a/sway/container.c b/sway/container.c index 20b7905b..4883a648 100644 --- a/sway/container.c +++ b/sway/container.c | |||
@@ -134,32 +134,39 @@ swayc_t *new_output(wlc_handle handle) { | |||
134 | 134 | ||
135 | // Create workspace | 135 | // Create workspace |
136 | char *ws_name = NULL; | 136 | char *ws_name = NULL; |
137 | swayc_t *ws = NULL; | ||
138 | |||
137 | if (name) { | 139 | if (name) { |
138 | for (i = 0; i < config->workspace_outputs->length; ++i) { | 140 | for (i = 0; i < config->workspace_outputs->length; ++i) { |
139 | struct workspace_output *wso = config->workspace_outputs->items[i]; | 141 | struct workspace_output *wso = config->workspace_outputs->items[i]; |
140 | if (strcasecmp(wso->output, name) == 0) { | 142 | if (strcasecmp(wso->output, name) == 0) { |
141 | sway_log(L_DEBUG, "Matched workspace to output: %s for %s", wso->workspace, wso->output); | 143 | sway_log(L_DEBUG, "Matched workspace to output: %s for %s", wso->workspace, wso->output); |
142 | // Check if any other workspaces are using this name | 144 | // Check if any other workspaces are using this name |
143 | if (workspace_by_name(wso->workspace)) { | 145 | if ((ws = workspace_by_name(wso->workspace))) { |
144 | sway_log(L_DEBUG, "But it's already taken"); | 146 | // if yes, move those to this output, because they should be here |
145 | break; | 147 | move_workspace_to(ws, output); |
148 | } else if (!ws_name) { | ||
149 | // set a workspace name in case we need to create a default one | ||
150 | ws_name = strdup(wso->workspace); | ||
146 | } | 151 | } |
147 | sway_log(L_DEBUG, "So we're going to use it"); | ||
148 | ws_name = strdup(wso->workspace); | ||
149 | break; | ||
150 | } | 152 | } |
151 | } | 153 | } |
152 | } | 154 | } |
153 | if (!ws_name) { | ||
154 | ws_name = workspace_next_name(output->name); | ||
155 | } | ||
156 | 155 | ||
157 | // create and initialize default workspace | 156 | if (output->children->length == 0) { |
158 | swayc_t *ws = new_workspace(output, ws_name); | 157 | if (!ws_name) { |
159 | ws->is_focused = true; | 158 | ws_name = workspace_next_name(output->name); |
159 | } | ||
160 | // create and initialize default workspace | ||
161 | sway_log(L_DEBUG, "Creating default workspace %s", ws_name); | ||
162 | ws = new_workspace(output, ws_name); | ||
163 | ws->is_focused = true; | ||
164 | } else { | ||
165 | sort_workspaces(output); | ||
166 | set_focused_container(output->children->items[0]); | ||
167 | } | ||
160 | 168 | ||
161 | free(ws_name); | 169 | free(ws_name); |
162 | |||
163 | return output; | 170 | return output; |
164 | } | 171 | } |
165 | 172 | ||
diff --git a/sway/focus.c b/sway/focus.c index 9db2aaa7..2219ab4a 100644 --- a/sway/focus.c +++ b/sway/focus.c | |||
@@ -110,7 +110,7 @@ bool set_focused_container(swayc_t *c) { | |||
110 | // Get workspace for c, get that workspaces current focused container. | 110 | // Get workspace for c, get that workspaces current focused container. |
111 | swayc_t *workspace = swayc_active_workspace_for(c); | 111 | swayc_t *workspace = swayc_active_workspace_for(c); |
112 | swayc_t *focused = get_focused_view(workspace); | 112 | swayc_t *focused = get_focused_view(workspace); |
113 | // if the workspace we are changing focus to has a fullscreen view return | 113 | |
114 | if (swayc_is_fullscreen(focused) && focused != c) { | 114 | if (swayc_is_fullscreen(focused) && focused != c) { |
115 | // if switching to a workspace with a fullscreen view, | 115 | // if switching to a workspace with a fullscreen view, |
116 | // focus on the fullscreen view | 116 | // focus on the fullscreen view |