|
|
@ -14,43 +14,46 @@ swayc_t *active_workspace = NULL;
|
|
|
|
char *workspace_next_name(void) {
|
|
|
|
char *workspace_next_name(void) {
|
|
|
|
sway_log(L_DEBUG, "Workspace: Generating new name");
|
|
|
|
sway_log(L_DEBUG, "Workspace: Generating new name");
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
int l = 1;
|
|
|
|
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) {
|
|
|
|
struct sway_binding *binding = mode->bindings->items[i];
|
|
|
|
struct sway_binding *binding = mode->bindings->items[i];
|
|
|
|
const char* command = binding->command;
|
|
|
|
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 > 1) {
|
|
|
|
if (strcmp("workspace", args->items[0]) == 0 && args->length > 1) {
|
|
|
|
sway_log(L_DEBUG, "Got valid workspace command for target: '%s'", args->items[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')
|
|
|
|
target++;
|
|
|
|
target++;
|
|
|
|
|
|
|
|
|
|
|
|
// Make sure that the command references an actual workspace
|
|
|
|
// Make sure that the command references an actual workspace
|
|
|
|
// not a command about workspaces
|
|
|
|
// not a command about workspaces
|
|
|
|
if (strcmp(target, "next") == 0 ||
|
|
|
|
if (strcmp(target, "next") == 0 ||
|
|
|
|
strcmp(target, "prev") == 0 ||
|
|
|
|
strcmp(target, "prev") == 0 ||
|
|
|
|
strcmp(target, "next_on_output") == 0 ||
|
|
|
|
strcmp(target, "next_on_output") == 0 ||
|
|
|
|
strcmp(target, "prev_on_output") == 0 ||
|
|
|
|
strcmp(target, "prev_on_output") == 0 ||
|
|
|
|
strcmp(target, "number") == 0 ||
|
|
|
|
strcmp(target, "number") == 0 ||
|
|
|
|
strcmp(target, "back_and_forth") == 0 ||
|
|
|
|
strcmp(target, "back_and_forth") == 0 ||
|
|
|
|
strcmp(target, "current") == 0)
|
|
|
|
strcmp(target, "current") == 0)
|
|
|
|
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[1]))
|
|
|
|
if (workspace_find_by_name(args->items[1]))
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
list_free(args);
|
|
|
|
return args->items[1]; }
|
|
|
|
|
|
|
|
}
|
|
|
|
sway_log(L_DEBUG, "Workspace: Found free name %s", args->items[1]);
|
|
|
|
// As a fall back, get the current number of active workspaces
|
|
|
|
return args->items[1];
|
|
|
|
// and return that + 1 for the next workspace's name
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// As a fall back, get the current number of active workspaces
|
|
|
|
|
|
|
|
// and return that + 1 for the next workspace's name
|
|
|
|
int ws_num = root_container.children->length;
|
|
|
|
int ws_num = root_container.children->length;
|
|
|
|
if (ws_num >= 10) {
|
|
|
|
if (ws_num >= 10) {
|
|
|
|
l = 2;
|
|
|
|
l = 2;
|
|
|
|