mirror of
https://github.com/swaywm/sway.git
synced 2024-11-24 17:01:29 +00:00
Fixes to workspace generation
This commit is contained in:
parent
52243a87a0
commit
8c1191d0e1
|
@ -18,6 +18,9 @@ int main(int argc, char **argv) {
|
||||||
/* Signal handling */
|
/* Signal handling */
|
||||||
signal(SIGCHLD, sigchld_handle);
|
signal(SIGCHLD, sigchld_handle);
|
||||||
|
|
||||||
|
if (!load_config()) {
|
||||||
|
sway_abort("Unable to load config");
|
||||||
|
}
|
||||||
|
|
||||||
setenv("WLC_DIM", "0", 0);
|
setenv("WLC_DIM", "0", 0);
|
||||||
if (!wlc_init(&interface, argc, argv)) {
|
if (!wlc_init(&interface, argc, argv)) {
|
||||||
|
@ -25,10 +28,6 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
setenv("DISPLAY", ":1", 1);
|
setenv("DISPLAY", ":1", 1);
|
||||||
|
|
||||||
if (!load_config()) {
|
|
||||||
sway_abort("Unable to load config");
|
|
||||||
}
|
|
||||||
|
|
||||||
wlc_run();
|
wlc_run();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,22 +6,27 @@
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "container.h"
|
#include "container.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "stringop.h"
|
||||||
|
|
||||||
swayc_t *active_workspace = NULL;
|
swayc_t *active_workspace = NULL;
|
||||||
|
|
||||||
int ws_num = 1;
|
|
||||||
|
|
||||||
char *workspace_next_name(void) {
|
char *workspace_next_name(void) {
|
||||||
|
sway_log(L_DEBUG, "Workspace: Generating new name");
|
||||||
int i;
|
int i;
|
||||||
|
int l = 1;
|
||||||
// Scan all workspace bindings to find the next available workspace name,
|
// Scan all workspace bindings to find the next available workspace name,
|
||||||
// if none are found/available then default to a number
|
// if none are found/available then default to a number
|
||||||
struct sway_mode *mode = config->current_mode;
|
struct sway_mode *mode = config->current_mode;
|
||||||
|
|
||||||
for (i = 0; i < mode->bindings->length; ++i) {
|
for (i = 0; i < mode->bindings->length; ++i) {
|
||||||
const char* command = *binding = mode->bindings->items[i]->command;
|
struct sway_binding *binding = mode->bindings->items[i];
|
||||||
|
const char* command = binding->command;
|
||||||
list_t *args = split_string(command, " ");
|
list_t *args = split_string(command, " ");
|
||||||
|
sway_log(L_DEBUG, "Workspace: Checking name '%s'", command);
|
||||||
|
|
||||||
if (strcmp("workspace", args->items[0]) == 0 && args->length > 2) {
|
if (strcmp("workspace", args->items[0]) == 0 && args->length > 1) {
|
||||||
|
sway_log(L_DEBUG, "Got valid workspace command for target: '%s'", args->items[1]);
|
||||||
const char* target = args->items[1];
|
const char* target = args->items[1];
|
||||||
|
|
||||||
while (*target == ' ' || *target == '\t')
|
while (*target == ' ' || *target == '\t')
|
||||||
|
@ -39,11 +44,10 @@ char *workspace_next_name(void) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//Make sure that the workspace doesn't already exist
|
//Make sure that the workspace doesn't already exist
|
||||||
if (workspace_find_by_name(args->items[2]))
|
if (workspace_find_by_name(args->items[1]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return args->items[2];
|
return args->items[1]; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// As a fall back, get the current number of active workspaces
|
// As a fall back, get the current number of active workspaces
|
||||||
// and return that + 1 for the next workspace's name
|
// and return that + 1 for the next workspace's name
|
||||||
|
|
Loading…
Reference in a new issue