|
|
@ -20,18 +20,24 @@
|
|
|
|
#include "log.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct workspace_config *workspace_find_config(const char *ws_name) {
|
|
|
|
|
|
|
|
for (int i = 0; i < config->workspace_configs->length; ++i) {
|
|
|
|
|
|
|
|
struct workspace_config *wsc = config->workspace_configs->items[i];
|
|
|
|
|
|
|
|
if (strcmp(wsc->workspace, ws_name) == 0) {
|
|
|
|
|
|
|
|
return wsc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct sway_output *workspace_get_initial_output(const char *name) {
|
|
|
|
struct sway_output *workspace_get_initial_output(const char *name) {
|
|
|
|
// Search for workspace<->output pair
|
|
|
|
// Check workspace configs for a workspace<->output pair
|
|
|
|
for (int i = 0; i < config->workspace_outputs->length; ++i) {
|
|
|
|
struct workspace_config *wsc = workspace_find_config(name);
|
|
|
|
struct workspace_output *wso = config->workspace_outputs->items[i];
|
|
|
|
if (wsc && wsc->output) {
|
|
|
|
if (strcasecmp(wso->workspace, name) == 0) {
|
|
|
|
struct sway_output *output = output_by_name(wsc->output);
|
|
|
|
// Find output to use if it exists
|
|
|
|
|
|
|
|
struct sway_output *output = output_by_name(wso->output);
|
|
|
|
|
|
|
|
if (output) {
|
|
|
|
if (output) {
|
|
|
|
return output;
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Otherwise put it on the focused output
|
|
|
|
// Otherwise put it on the focused output
|
|
|
|
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
|
|
|
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
|
|
@ -121,17 +127,8 @@ void next_name_map(struct sway_container *ws, void *data) {
|
|
|
|
|
|
|
|
|
|
|
|
static bool workspace_valid_on_output(const char *output_name,
|
|
|
|
static bool workspace_valid_on_output(const char *output_name,
|
|
|
|
const char *ws_name) {
|
|
|
|
const char *ws_name) {
|
|
|
|
int i;
|
|
|
|
struct workspace_config *wsc = workspace_find_config(ws_name);
|
|
|
|
for (i = 0; i < config->workspace_outputs->length; ++i) {
|
|
|
|
return !wsc || !wsc->output || strcmp(wsc->output, output_name) == 0;
|
|
|
|
struct workspace_output *wso = config->workspace_outputs->items[i];
|
|
|
|
|
|
|
|
if (strcasecmp(wso->workspace, ws_name) == 0) {
|
|
|
|
|
|
|
|
if (strcasecmp(wso->output, output_name) != 0) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void workspace_name_from_binding(const struct sway_binding * binding,
|
|
|
|
static void workspace_name_from_binding(const struct sway_binding * binding,
|
|
|
@ -231,13 +228,13 @@ char *workspace_next_name(const char *output_name) {
|
|
|
|
workspace_name_from_binding(mode->keycode_bindings->items[i],
|
|
|
|
workspace_name_from_binding(mode->keycode_bindings->items[i],
|
|
|
|
output_name, &order, &target);
|
|
|
|
output_name, &order, &target);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 0; i < config->workspace_outputs->length; ++i) {
|
|
|
|
for (int i = 0; i < config->workspace_configs->length; ++i) {
|
|
|
|
// Unlike with bindings, this does not guarantee order
|
|
|
|
// Unlike with bindings, this does not guarantee order
|
|
|
|
const struct workspace_output *wso = config->workspace_outputs->items[i];
|
|
|
|
const struct workspace_config *wsc = config->workspace_configs->items[i];
|
|
|
|
if (strcmp(wso->output, output_name) == 0
|
|
|
|
if (wsc->output && strcmp(wsc->output, output_name) == 0
|
|
|
|
&& workspace_by_name(wso->workspace) == NULL) {
|
|
|
|
&& workspace_by_name(wsc->workspace) == NULL) {
|
|
|
|
free(target);
|
|
|
|
free(target);
|
|
|
|
target = strdup(wso->workspace);
|
|
|
|
target = strdup(wsc->workspace);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|