summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-13 11:32:38 -0500
committerLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-13 14:41:36 -0500
commit2c9f5eca89ac5ab1a3eaacc3b56243978098408c (patch)
treee21fbd08ec5131024b2eb9f59c4526612b77940c
parentChanged workspace name generation to try and use bindsyms when possible (diff)
downloadsway-2c9f5eca89ac5ab1a3eaacc3b56243978098408c.tar.gz
sway-2c9f5eca89ac5ab1a3eaacc3b56243978098408c.tar.zst
sway-2c9f5eca89ac5ab1a3eaacc3b56243978098408c.zip
Fixes to workspace generation
-rw-r--r--sway/main.c7
-rw-r--r--sway/workspace.c18
2 files changed, 14 insertions, 11 deletions
diff --git a/sway/main.c b/sway/main.c
index 7477b08c..b48d4b19 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -18,6 +18,9 @@ int main(int argc, char **argv) {
18 /* Signal handling */ 18 /* Signal handling */
19 signal(SIGCHLD, sigchld_handle); 19 signal(SIGCHLD, sigchld_handle);
20 20
21 if (!load_config()) {
22 sway_abort("Unable to load config");
23 }
21 24
22 setenv("WLC_DIM", "0", 0); 25 setenv("WLC_DIM", "0", 0);
23 if (!wlc_init(&interface, argc, argv)) { 26 if (!wlc_init(&interface, argc, argv)) {
@@ -25,10 +28,6 @@ int main(int argc, char **argv) {
25 } 28 }
26 setenv("DISPLAY", ":1", 1); 29 setenv("DISPLAY", ":1", 1);
27 30
28 if (!load_config()) {
29 sway_abort("Unable to load config");
30 }
31
32 wlc_run(); 31 wlc_run();
33 return 0; 32 return 0;
34} 33}
diff --git a/sway/workspace.c b/sway/workspace.c
index 96604678..9bc6838c 100644
--- a/sway/workspace.c
+++ b/sway/workspace.c
@@ -6,22 +6,27 @@
6#include "list.h" 6#include "list.h"
7#include "log.h" 7#include "log.h"
8#include "container.h" 8#include "container.h"
9#include "config.h"
10#include "stringop.h"
9 11
10swayc_t *active_workspace = NULL; 12swayc_t *active_workspace = NULL;
11 13
12int ws_num = 1;
13
14char *workspace_next_name(void) { 14char *workspace_next_name(void) {
15 sway_log(L_DEBUG, "Workspace: Generating new name");
15 int i; 16 int i;
17 int l = 1;
16 // Scan all workspace bindings to find the next available workspace name, 18 // Scan all workspace bindings to find the next available workspace name,
17 // if none are found/available then default to a number 19 // if none are found/available then default to a number
18 struct sway_mode *mode = config->current_mode; 20 struct sway_mode *mode = config->current_mode;
19 21
20 for (i = 0; i < mode->bindings->length; ++i) { 22 for (i = 0; i < mode->bindings->length; ++i) {
21 const char* command = *binding = mode->bindings->items[i]->command; 23 struct sway_binding *binding = mode->bindings->items[i];
24 const char* command = binding->command;
22 list_t *args = split_string(command, " "); 25 list_t *args = split_string(command, " ");
26 sway_log(L_DEBUG, "Workspace: Checking name '%s'", command);
23 27
24 if (strcmp("workspace", args->items[0]) == 0 && args->length > 2) { 28 if (strcmp("workspace", args->items[0]) == 0 && args->length > 1) {
29 sway_log(L_DEBUG, "Got valid workspace command for target: '%s'", args->items[1]);
25 const char* target = args->items[1]; 30 const char* target = args->items[1];
26 31
27 while (*target == ' ' || *target == '\t') 32 while (*target == ' ' || *target == '\t')
@@ -39,11 +44,10 @@ char *workspace_next_name(void) {
39 continue; 44 continue;
40 45
41 //Make sure that the workspace doesn't already exist 46 //Make sure that the workspace doesn't already exist
42 if (workspace_find_by_name(args->items[2])) 47 if (workspace_find_by_name(args->items[1]))
43 continue; 48 continue;
44 49
45 return args->items[2]; 50 return args->items[1]; }
46 }
47 } 51 }
48 // As a fall back, get the current number of active workspaces 52 // As a fall back, get the current number of active workspaces
49 // and return that + 1 for the next workspace's name 53 // and return that + 1 for the next workspace's name