enforce workspace output assignents

when creating a new output, move to that output all extant workspaces
that are assigned to that output.

(unrelated) remove comment that was no longer applicable, fix spacing in
an assignment
This commit is contained in:
Zandr Martin 2016-05-28 18:18:46 -05:00
parent a0315dc849
commit d291a29f30
3 changed files with 22 additions and 15 deletions

View File

@ -2325,7 +2325,7 @@ static struct cmd_results *cmd_workspace(int argc, char **argv) {
// Handle workspace next/prev
swayc_t *ws = NULL;
if (argc == 2) {
if (!(ws=workspace_by_number(argv[1]))) {
if (!(ws = workspace_by_number(argv[1]))) {
ws = workspace_create(argv[1]);
}
} else if (strcasecmp(argv[0], "next") == 0) {

View File

@ -134,32 +134,39 @@ swayc_t *new_output(wlc_handle handle) {
// Create workspace
char *ws_name = NULL;
swayc_t *ws = NULL;
if (name) {
for (i = 0; i < config->workspace_outputs->length; ++i) {
struct workspace_output *wso = config->workspace_outputs->items[i];
if (strcasecmp(wso->output, name) == 0) {
sway_log(L_DEBUG, "Matched workspace to output: %s for %s", wso->workspace, wso->output);
// Check if any other workspaces are using this name
if (workspace_by_name(wso->workspace)) {
sway_log(L_DEBUG, "But it's already taken");
break;
if ((ws = workspace_by_name(wso->workspace))) {
// if yes, move those to this output, because they should be here
move_workspace_to(ws, output);
} else if (!ws_name) {
// set a workspace name in case we need to create a default one
ws_name = strdup(wso->workspace);
}
sway_log(L_DEBUG, "So we're going to use it");
ws_name = strdup(wso->workspace);
break;
}
}
}
if (!ws_name) {
ws_name = workspace_next_name(output->name);
if (output->children->length == 0) {
if (!ws_name) {
ws_name = workspace_next_name(output->name);
}
// create and initialize default workspace
sway_log(L_DEBUG, "Creating default workspace %s", ws_name);
ws = new_workspace(output, ws_name);
ws->is_focused = true;
} else {
sort_workspaces(output);
set_focused_container(output->children->items[0]);
}
// create and initialize default workspace
swayc_t *ws = new_workspace(output, ws_name);
ws->is_focused = true;
free(ws_name);
return output;
}

View File

@ -110,7 +110,7 @@ bool set_focused_container(swayc_t *c) {
// Get workspace for c, get that workspaces current focused container.
swayc_t *workspace = swayc_active_workspace_for(c);
swayc_t *focused = get_focused_view(workspace);
// if the workspace we are changing focus to has a fullscreen view return
if (swayc_is_fullscreen(focused) && focused != c) {
// if switching to a workspace with a fullscreen view,
// focus on the fullscreen view