aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/commands.c60
-rw-r--r--sway/config.c1
-rw-r--r--sway/container.c19
3 files changed, 55 insertions, 25 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 5035316e..444e6159 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -410,37 +410,51 @@ static bool cmd_fullscreen(struct sway_config *config, int argc, char **argv) {
}
static bool cmd_workspace(struct sway_config *config, int argc, char **argv) {
- if (!checkarg(argc, "workspace", EXPECTED_EQUAL_TO, 1)) {
+ if (!checkarg(argc, "workspace", EXPECTED_AT_LEAST, 1)) {
return false;
}
- // Handle workspace next/prev
- if (strcmp(argv[0], "next") == 0) {
- workspace_next();
- return true;
- }
+ if (argc == 1) {
+ // Handle workspace next/prev
+ if (strcmp(argv[0], "next") == 0) {
+ workspace_next();
+ return true;
+ }
- if (strcmp(argv[0], "prev") == 0) {
- workspace_next();
- return true;
- }
+ if (strcmp(argv[0], "prev") == 0) {
+ workspace_next();
+ return true;
+ }
- // Handle workspace output_next/prev
- if (strcmp(argv[0], "next_on_output") == 0) {
- workspace_output_next();
- return true;
- }
+ // Handle workspace output_next/prev
+ if (strcmp(argv[0], "next_on_output") == 0) {
+ workspace_output_next();
+ return true;
+ }
- if (strcmp(argv[0], "prev_on_output") == 0) {
- workspace_output_prev();
- return true;
- }
+ if (strcmp(argv[0], "prev_on_output") == 0) {
+ workspace_output_prev();
+ return true;
+ }
- swayc_t *workspace = workspace_find_by_name(argv[0]);
- if (!workspace) {
- workspace = workspace_create(argv[0]);
+ swayc_t *workspace = workspace_find_by_name(argv[0]);
+ if (!workspace) {
+ workspace = workspace_create(argv[0]);
+ }
+ workspace_switch(workspace);
+ } else {
+ if (strcasecmp(argv[1], "output") == 0) {
+ if (!checkarg(argc, "workspace", EXPECTED_EQUAL_TO, 3)) {
+ return false;
+ }
+ struct workspace_output *wso = calloc(1, sizeof(struct workspace_output));
+ sway_log(L_DEBUG, "Assigning workspace %s to output %s", argv[0], argv[2]);
+ wso->workspace = strdup(argv[0]);
+ wso->output = strdup(argv[2]);
+ list_add(config->workspace_outputs, wso);
+ // TODO: Consider moving any existing workspace to that output? This might be executed sometime after config load
+ }
}
- workspace_switch(workspace);
return true;
}
diff --git a/sway/config.c b/sway/config.c
index dabbf8e5..f06d55f8 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -159,6 +159,7 @@ void config_defaults(struct sway_config *config) {
config->symbols = create_list();
config->modes = create_list();
config->cmd_queue = create_list();
+ config->workspace_outputs = create_list();
config->current_mode = malloc(sizeof(struct sway_mode));
config->current_mode->name = NULL;
config->current_mode->bindings = create_list();
diff --git a/sway/container.c b/sway/container.c
index f10fbecf..3534721d 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <stdbool.h>
#include <strings.h>
+#include "config.h"
#include "container.h"
#include "workspace.h"
#include "layout.h"
@@ -63,14 +64,28 @@ swayc_t *new_output(wlc_handle handle) {
container_map(&root_container, add_output_widths, &total_width);
//Create workspace
- char *ws_name = workspace_next_name();
+ char *ws_name = NULL;
+ if (name) {
+ int i;
+ 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);
+ ws_name = strdup(wso->workspace);
+ break;
+ }
+ }
+ }
+ if (!ws_name) {
+ ws_name = workspace_next_name();
+ }
new_workspace(output, ws_name);
free(ws_name);
return output;
}
-swayc_t *new_workspace(swayc_t * output, const char *name) {
+swayc_t *new_workspace(swayc_t *output, const char *name) {
sway_log(L_DEBUG, "Added workspace %s for output %u", name, (unsigned int)output->handle);
swayc_t *workspace = new_swayc(C_WORKSPACE);