aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/commands.c13
-rw-r--r--sway/commands/bar/binding_mode_indicator.c6
-rw-r--r--sway/commands/output/background.c18
-rw-r--r--sway/commands/resize.c30
-rw-r--r--sway/commands/workspace.c38
-rw-r--r--sway/config.c11
-rw-r--r--sway/config/input.c3
-rw-r--r--sway/config/output.c4
-rw-r--r--sway/desktop/transaction.c55
-rw-r--r--sway/input/cursor.c2
-rw-r--r--sway/input/input-manager.c6
-rw-r--r--sway/ipc-server.c13
-rw-r--r--sway/sway-bar.5.scd3
-rw-r--r--sway/sway-input.5.scd4
-rw-r--r--sway/sway.5.scd58
-rw-r--r--sway/tree/container.c13
-rw-r--r--sway/tree/view.c10
-rw-r--r--sway/tree/workspace.c49
18 files changed, 173 insertions, 163 deletions
diff --git a/sway/commands.c b/sway/commands.c
index bff230f7..03761c52 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -391,14 +391,12 @@ struct cmd_results *config_command(char *exec) {
// Var replacement, for all but first argument of set
// TODO commands
for (i = handler->handle == cmd_set ? 2 : 1; i < argc; ++i) {
+ if (*argv[i] == '\"' || *argv[i] == '\'') {
+ strip_quotes(argv[i]);
+ }
argv[i] = do_var_replacement(argv[i]);
unescape_string(argv[i]);
}
- // Strip quotes for first argument.
- // TODO This part needs to be handled much better
- if (argc>1 && (*argv[1] == '\"' || *argv[1] == '\'')) {
- strip_quotes(argv[1]);
- }
if (handler->handle) {
results = handler->handle(argc-1, argv+1);
} else {
@@ -422,11 +420,6 @@ struct cmd_results *config_subcommand(char **argv, int argc,
char *input = argv[0] ? argv[0] : "(empty)";
return cmd_results_new(CMD_INVALID, input, "Unknown/invalid command");
}
- // Strip quotes for first argument.
- // TODO This part needs to be handled much better
- if (argc > 1 && (*argv[1] == '\"' || *argv[1] == '\'')) {
- strip_quotes(argv[1]);
- }
if (handler->handle) {
return handler->handle(argc - 1, argv + 1);
}
diff --git a/sway/commands/bar/binding_mode_indicator.c b/sway/commands/bar/binding_mode_indicator.c
index 0c48bee9..f18b8d7c 100644
--- a/sway/commands/bar/binding_mode_indicator.c
+++ b/sway/commands/bar/binding_mode_indicator.c
@@ -21,7 +21,9 @@ struct cmd_results *bar_cmd_binding_mode_indicator(int argc, char **argv) {
config->current_bar->binding_mode_indicator = false;
wlr_log(WLR_DEBUG, "Disabling binding mode indicator on bar: %s",
config->current_bar->id);
+ } else {
+ return cmd_results_new(CMD_INVALID, "binding_mode_indicator",
+ "Invalid value %s", argv[0]);
}
- return cmd_results_new(CMD_INVALID, "binding_mode_indicator",
- "Invalid value %s", argv[0]);
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}
diff --git a/sway/commands/output/background.c b/sway/commands/output/background.c
index 9e370d43..30fb47c4 100644
--- a/sway/commands/output/background.c
+++ b/sway/commands/output/background.c
@@ -123,19 +123,13 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
}
free(src);
} else {
- // Escape spaces and quotes in the final path for swaybg
+ // Escape double quotes in the final path for swaybg
for (size_t i = 0; i < strlen(src); i++) {
- switch (src[i]) {
- case ' ':
- case '\'':
- case '\"':
- src = realloc(src, strlen(src) + 2);
- memmove(src + i + 1, src + i, strlen(src + i) + 1);
- *(src + i) = '\\';
- i++;
- break;
- default:
- break;
+ if (src[i] == '"') {
+ src = realloc(src, strlen(src) + 2);
+ memmove(src + i + 1, src + i, strlen(src + i) + 1);
+ *(src + i) = '\\';
+ i++;
}
}
diff --git a/sway/commands/resize.c b/sway/commands/resize.c
index 99e9dbda..1343b165 100644
--- a/sway/commands/resize.c
+++ b/sway/commands/resize.c
@@ -179,11 +179,11 @@ static void container_recursive_resize(struct sway_container *container,
}
}
-static void resize_tiled(struct sway_container *parent, int amount,
+static bool resize_tiled(struct sway_container *parent, int amount,
enum resize_axis axis) {
struct sway_container *focused = parent;
if (!parent) {
- return;
+ return false;
}
enum sway_container_layout parallel_layout =
@@ -216,7 +216,7 @@ static void resize_tiled(struct sway_container *parent, int amount,
}
if (!parent) {
// Can't resize in this direction
- return;
+ return false;
}
// Implement up/down/left/right direction by zeroing one of the weights,
@@ -248,22 +248,22 @@ static void resize_tiled(struct sway_container *parent, int amount,
if (sibling_pos < parent_pos && minor_weight) {
double pixels = -amount / minor_weight;
if (major_weight && (sibling_size + pixels / 2) < min_sane) {
- return; // Too small
+ return false; // Too small
} else if (!major_weight && sibling_size + pixels < min_sane) {
- return; // Too small
+ return false; // Too small
}
} else if (sibling_pos > parent_pos && major_weight) {
double pixels = -amount / major_weight;
if (minor_weight && (sibling_size + pixels / 2) < min_sane) {
- return; // Too small
+ return false; // Too small
} else if (!minor_weight && sibling_size + pixels < min_sane) {
- return; // Too small
+ return false; // Too small
}
}
} else {
double pixels = amount;
if (parent_size + pixels < min_sane) {
- return; // Too small
+ return false; // Too small
}
}
}
@@ -317,9 +317,10 @@ static void resize_tiled(struct sway_container *parent, int amount,
} else {
arrange_workspace(parent->workspace);
}
+ return true;
}
-void container_resize_tiled(struct sway_container *parent,
+bool container_resize_tiled(struct sway_container *parent,
enum wlr_edges edge, int amount) {
enum resize_axis axis = RESIZE_AXIS_INVALID;
switch (edge) {
@@ -338,7 +339,7 @@ void container_resize_tiled(struct sway_container *parent,
case WLR_EDGE_NONE:
break;
}
- resize_tiled(parent, amount, axis);
+ return resize_tiled(parent, amount, axis);
}
/**
@@ -395,6 +396,10 @@ static struct cmd_results *resize_adjust_floating(enum resize_axis axis,
case RESIZE_AXIS_INVALID:
return cmd_results_new(CMD_INVALID, "resize", "Invalid axis/direction");
}
+ if (grow_x == 0 && grow_y == 0) {
+ return cmd_results_new(CMD_INVALID, "resize",
+ "Cannot resize any further");
+ }
con->x += grow_x;
con->y += grow_y;
con->width += grow_width;
@@ -442,7 +447,10 @@ static struct cmd_results *resize_adjust_tiled(enum resize_axis axis,
}
}
- resize_tiled(current, amount->amount, axis);
+ if (!resize_tiled(current, amount->amount, axis)) {
+ return cmd_results_new(CMD_INVALID, "resize",
+ "Cannot resize any further");
+ }
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c
index f026a39d..2ce7872d 100644
--- a/sway/commands/workspace.c
+++ b/sway/commands/workspace.c
@@ -10,6 +10,26 @@
#include "log.h"
#include "stringop.h"
+static struct workspace_config *workspace_config_find_or_create(char *ws_name) {
+ struct workspace_config *wsc = workspace_find_config(ws_name);
+ if (wsc) {
+ return wsc;
+ }
+ wsc = calloc(1, sizeof(struct workspace_config));
+ if (!wsc) {
+ return NULL;
+ }
+ wsc->workspace = strdup(ws_name);
+ list_add(config->workspace_configs, wsc);
+ return wsc;
+}
+
+void free_workspace_config(struct workspace_config *wsc) {
+ free(wsc->workspace);
+ free(wsc->output);
+ free(wsc);
+}
+
struct cmd_results *cmd_workspace(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "workspace", EXPECTED_AT_LEAST, 1))) {
@@ -28,21 +48,15 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO, output_location + 2))) {
return error;
}
- struct workspace_output *wso = calloc(1, sizeof(struct workspace_output));
- if (!wso) {
+ char *ws_name = join_args(argv, argc - 2);
+ struct workspace_config *wsc = workspace_config_find_or_create(ws_name);
+ free(ws_name);
+ if (!wsc) {
return cmd_results_new(CMD_FAILURE, "workspace output",
"Unable to allocate workspace output");
}
- wso->workspace = join_args(argv, argc - 2);
- wso->output = strdup(argv[output_location + 1]);
- int i = -1;
- if ((i = list_seq_find(config->workspace_outputs, workspace_output_cmp_workspace, wso)) != -1) {
- struct workspace_output *old = config->workspace_outputs->items[i];
- free(old); // workspaces can only be assigned to a single output
- list_del(config->workspace_outputs, i);
- }
- wlr_log(WLR_DEBUG, "Assigning workspace %s to output %s", wso->workspace, wso->output);
- list_add(config->workspace_outputs, wso);
+ free(wsc->output);
+ wsc->output = strdup(argv[output_location + 1]);
} else {
if (config->reading || !config->active) {
return cmd_results_new(CMD_DEFER, "workspace", NULL);
diff --git a/sway/config.c b/sway/config.c
index 830fb65f..1e08559d 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -95,7 +95,12 @@ void free_config(struct sway_config *config) {
list_free(config->bars);
}
list_free(config->cmd_queue);
- list_free(config->workspace_outputs);
+ if (config->workspace_configs) {
+ for (int i = 0; i < config->workspace_configs->length; i++) {
+ free_workspace_config(config->workspace_configs->items[i]);
+ }
+ list_free(config->workspace_configs);
+ }
if (config->output_configs) {
for (int i = 0; i < config->output_configs->length; i++) {
free_output_config(config->output_configs->items[i]);
@@ -175,7 +180,7 @@ static void config_defaults(struct sway_config *config) {
if (!(config->symbols = create_list())) goto cleanup;
if (!(config->modes = create_list())) goto cleanup;
if (!(config->bars = create_list())) goto cleanup;
- if (!(config->workspace_outputs = create_list())) goto cleanup;
+ if (!(config->workspace_configs = create_list())) goto cleanup;
if (!(config->criteria = create_list())) goto cleanup;
if (!(config->no_focus = create_list())) goto cleanup;
if (!(config->input_configs = create_list())) goto cleanup;
@@ -804,7 +809,7 @@ char *do_var_replacement(char *str) {
// would compare two structs in full, while this method only compares the
// workspace.
int workspace_output_cmp_workspace(const void *a, const void *b) {
- const struct workspace_output *wsa = a, *wsb = b;
+ const struct workspace_config *wsa = a, *wsb = b;
return lenient_strcmp(wsa->workspace, wsb->workspace);
}
diff --git a/sway/config/input.c b/sway/config/input.c
index fffc8518..6b43a5b9 100644
--- a/sway/config/input.c
+++ b/sway/config/input.c
@@ -52,6 +52,9 @@ void merge_input_config(struct input_config *dst, struct input_config *src) {
if (src->dwt != INT_MIN) {
dst->dwt = src->dwt;
}
+ if (src->left_handed != INT_MIN) {
+ dst->left_handed = src->left_handed;
+ }
if (src->middle_emulation != INT_MIN) {
dst->middle_emulation = src->middle_emulation;
}
diff --git a/sway/config/output.c b/sway/config/output.c
index 74d79130..6f337b66 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -237,7 +237,7 @@ void apply_output_config(struct output_config *oc, struct sway_output *output) {
wlr_log(WLR_DEBUG, "Setting background for output %d to %s",
output_i, oc->background);
- size_t len = snprintf(NULL, 0, "%s %d %s %s %s",
+ size_t len = snprintf(NULL, 0, "%s %d \"%s\" %s %s",
config->swaybg_command ? config->swaybg_command : "swaybg",
output_i, oc->background, oc->background_option,
oc->background_fallback ? oc->background_fallback : "");
@@ -246,7 +246,7 @@ void apply_output_config(struct output_config *oc, struct sway_output *output) {
wlr_log(WLR_DEBUG, "Unable to allocate swaybg command");
return;
}
- snprintf(command, len + 1, "%s %d %s %s %s",
+ snprintf(command, len + 1, "%s %d \"%s\" %s %s",
config->swaybg_command ? config->swaybg_command : "swaybg",
output_i, oc->background, oc->background_option,
oc->background_fallback ? oc->background_fallback : "");
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index 797f6b4c..34d99d52 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -31,14 +31,14 @@ struct sway_transaction_instruction {
struct sway_transaction *transaction;
struct sway_node *node;
union {
- struct sway_output_state *output_state;
- struct sway_workspace_state *workspace_state;
- struct sway_container_state *container_state;
+ struct sway_output_state output_state;
+ struct sway_workspace_state workspace_state;
+ struct sway_container_state container_state;
};
uint32_t serial;
};
-static struct sway_transaction *transaction_create() {
+static struct sway_transaction *transaction_create(void) {
struct sway_transaction *transaction =
calloc(1, sizeof(struct sway_transaction));
if (!sway_assert(transaction, "Unable to allocate transaction")) {
@@ -86,14 +86,7 @@ static void transaction_destroy(struct sway_transaction *transaction) {
static void copy_output_state(struct sway_output *output,
struct sway_transaction_instruction *instruction) {
- struct sway_output_state *state =
- calloc(1, sizeof(struct sway_output_state));
- if (!state) {
- wlr_log(WLR_ERROR, "Could not allocate output state");
- return;
- }
- instruction->output_state = state;
-
+ struct sway_output_state *state = &instruction->output_state;
state->workspaces = create_list();
list_cat(state->workspaces, output->workspaces);
@@ -102,13 +95,7 @@ static void copy_output_state(struct sway_output *output,
static void copy_workspace_state(struct sway_workspace *ws,
struct sway_transaction_instruction *instruction) {
- struct sway_workspace_state *state =
- calloc(1, sizeof(struct sway_workspace_state));
- if (!state) {
- wlr_log(WLR_ERROR, "Could not allocate workspace state");
- return;
- }
- instruction->workspace_state = state;
+ struct sway_workspace_state *state = &instruction->workspace_state;
state->fullscreen = ws->fullscreen;
state->x = ws->x;
@@ -138,13 +125,7 @@ static void copy_workspace_state(struct sway_workspace *ws,
static void copy_container_state(struct sway_container *container,
struct sway_transaction_instruction *instruction) {
- struct sway_container_state *state =
- calloc(1, sizeof(struct sway_container_state));
- if (!state) {
- wlr_log(WLR_ERROR, "Could not allocate container state");
- return;
- }
- instruction->container_state = state;
+ struct sway_container_state *state = &instruction->container_state;
state->layout = container->layout;
state->con_x = container->x;
@@ -301,15 +282,15 @@ static void transaction_apply(struct sway_transaction *transaction) {
case N_ROOT:
break;
case N_OUTPUT:
- apply_output_state(node->sway_output, instruction->output_state);
+ apply_output_state(node->sway_output, &instruction->output_state);
break;
case N_WORKSPACE:
apply_workspace_state(node->sway_workspace,
- instruction->workspace_state);
+ &instruction->workspace_state);
break;
case N_CONTAINER:
apply_container_state(node->sway_container,
- instruction->container_state);
+ &instruction->container_state);
break;
}
@@ -335,7 +316,7 @@ static bool transaction_same_nodes(struct sway_transaction *a,
return true;
}
-static void transaction_progress_queue() {
+static void transaction_progress_queue(void) {
if (!server.transactions->length) {
return;
}
@@ -390,7 +371,7 @@ static bool should_configure(struct sway_node *node,
return false;
}
struct sway_container_state *cstate = &node->sway_container->current;
- struct sway_container_state *istate = instruction->container_state;
+ struct sway_container_state *istate = &instruction->container_state;
#ifdef HAVE_XWAYLAND
// Xwayland views are position-aware and need to be reconfigured
// when their position changes.
@@ -418,10 +399,10 @@ static void transaction_commit(struct sway_transaction *transaction) {
struct sway_node *node = instruction->node;
if (should_configure(node, instruction)) {
instruction->serial = view_configure(node->sway_container->view,
- instruction->container_state->view_x,
- instruction->container_state->view_y,
- instruction->container_state->view_width,
- instruction->container_state->view_height);
+ instruction->container_state.view_x,
+ instruction->container_state.view_y,
+ instruction->container_state.view_width,
+ instruction->container_state.view_height);
++transaction->num_waiting;
// From here on we are rendering a saved buffer of the view, which
@@ -513,8 +494,8 @@ void transaction_notify_view_ready_by_size(struct sway_view *view,
int width, int height) {
struct sway_transaction_instruction *instruction =
view->container->node.instruction;
- if (instruction->container_state->view_width == width &&
- instruction->container_state->view_height == height) {
+ if (instruction->container_state.view_width == width &&
+ instruction->container_state.view_height == height) {
set_instruction_ready(instruction);
}
}
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 8c9f65ab..2d5d351f 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -897,7 +897,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
// Handle moving a tiling container
if (config->tiling_drag && mod_pressed && state == WLR_BUTTON_PRESSED &&
- !is_floating_or_child && !cont->is_fullscreen) {
+ !is_floating_or_child && cont && !cont->is_fullscreen) {
seat_pointer_notify_button(seat, time_msec, button, state);
seat_begin_move_tiling(seat, cont, button);
return;
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index f696646f..f39fe29c 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -233,7 +233,8 @@ static void handle_new_input(struct wl_listener *listener, void *data) {
wlr_log(WLR_DEBUG, "adding device: '%s'",
input_device->identifier);
- if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) {
+ if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER ||
+ input_device->wlr_device->type == WLR_INPUT_DEVICE_TABLET_TOOL) {
input_manager_libinput_config_pointer(input_device);
}
@@ -393,7 +394,8 @@ void input_manager_apply_input_config(struct sway_input_manager *input,
wl_list_for_each(input_device, &input->devices, link) {
if (strcmp(input_device->identifier, input_config->identifier) == 0
|| wildcard) {
- if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) {
+ if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER ||
+ input_device->wlr_device->type == WLR_INPUT_DEVICE_TABLET_TOOL) {
input_manager_libinput_config_pointer(input_device);
}
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index 99959c97..2d915502 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -1,8 +1,5 @@
// See https://i3wm.org/docs/ipc.html for protocol information
-#ifndef __FreeBSD__
-// Any value will hide SOCK_CLOEXEC on FreeBSD (__BSD_VISIBLE=0)
-#define _XOPEN_SOURCE 700
-#endif
+#define _POSIX_C_SOURCE 200112L
#ifdef __linux__
#include <linux/input-event-codes.h>
#elif __FreeBSD__
@@ -89,10 +86,16 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
}
void ipc_init(struct sway_server *server) {
- ipc_socket = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
+ ipc_socket = socket(AF_UNIX, SOCK_STREAM, 0);
if (ipc_socket == -1) {
sway_abort("Unable to create IPC socket");
}
+ if (fcntl(ipc_socket, F_SETFD, FD_CLOEXEC) == -1) {
+ sway_abort("Unable to set CLOEXEC on IPC socket");
+ }
+ if (fcntl(ipc_socket, F_SETFL, O_NONBLOCK) == -1) {
+ sway_abort("Unable to set NONBLOCK on IPC socket");
+ }
ipc_sockaddr = ipc_user_sockaddr();
diff --git a/sway/sway-bar.5.scd b/sway/sway-bar.5.scd
index a61e2829..00b9386e 100644
--- a/sway/sway-bar.5.scd
+++ b/sway/sway-bar.5.scd
@@ -6,8 +6,7 @@ sway-bar - bar configuration file and commands
# DESCRIPTION
-Sway allows configuring swaybar in the sway configuration file. Swaybar
-commands must be used inside a _bar { }_ block in the config file.
+Sway allows configuring swaybar in the sway configuration file.
# COMMANDS
diff --git a/sway/sway-input.5.scd b/sway/sway-input.5.scd
index 707c36af..5736d70a 100644
--- a/sway/sway-input.5.scd
+++ b/sway/sway-input.5.scd
@@ -7,7 +7,6 @@ sway-input - input configuration file and commands
# DESCRIPTION
Sway allows for configuration of devices within the sway configuration file.
-sway-input commands must be used inside an _input { }_ block in the config.
To obtain a list of available device identifiers, run *swaymsg -t get\_inputs*.
# INPUT COMMANDS
@@ -116,8 +115,7 @@ The following commands may only be used in the configuration file.
## SEAT CONFIGURATION
-Configure options for multiseat mode. sway-seat commands must be used inside a
-_seat { }_ block in the config.
+Configure options for multiseat mode.
A *seat* is a collection of input devices that act independently of each other.
Seats are identified by name and the default seat is _seat0_ if no seats are
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index 927bf55c..1526eee3 100644
--- a/sway/sway.5.scd
+++ b/sway/sway.5.scd
@@ -19,6 +19,24 @@ bindsym Shift+XF86AudioRaiseVolume exec \\
pactl set-sink-volume @DEFAULT_SINK@ -1%
```
+Commands can also be given as a block in the form *command { <subcommands...>
+}*. Anything before the opening *{* will be prepended to the lines inside the
+block. For example:
+
+```
+output eDP-1 {
+ background ~/wallpaper.png
+ resolution 1920x1080
+}
+```
+
+is identical to
+
+```
+output eDP-1 background ~/wallpaper.png
+output eDP-1 resolution 1920x1080
+```
+
These commands can be executed in your config file, via *swaymsg*(1), or via
the bindsym command.
@@ -37,10 +55,8 @@ which you may only select one. *[...]* is used for optional arguments, and
The following commands may only be used in the configuration file.
-*bar {* <commands...> *}*
- _commands..._ after *{* will be interpreted as bar commands. For
- details, see *sway-bar*(5). A newline is required between *{* and the
- first command, and *}* must be alone on a line.
+*bar* [<bar-id>] <bar-subcommands...>
+ For details on bar subcommands, see *sway-bar*(5).
*default\_orientation* horizontal|vertical|auto
Sets the default container layout for tiled containers.
@@ -51,10 +67,6 @@ The following commands may only be used in the configuration file.
*wordexp*(3) for details). The same include file can only be included once;
subsequent attempts will be ignored.
-*set* $<name> <value>
- Sets variable $_name_ to _value_. You can use the new variable in the
- arguments of future commands.
-
*swaybg\_command* <command>
Executes custom background _command_. Default is _swaybg_. Refer to
*output* below for more information.
@@ -424,20 +436,15 @@ The default colors are:
*hide\_edge\_borders* none|vertical|horizontal|both|smart
Hides window borders adjacent to the screen edges. Default is _none_.
-*input* <input\_device> *{* <commands...> *}*
- _commands..._ after *{* will be interpreted as input commands applying to
- the specified input device. For details, see *sway-input*(5). A newline is
- required between *{* and the first command, and *}* must be alone on a
- line.
+*input* <input\_device> <input-subcommands...>
+ For details on input subcommands, see *sway-input*(5).
\* may be used in lieu of a specific device name to configure all input
devices. A list of input device names may be obtained via *swaymsg -t
get\_inputs*.
-*seat* <seat> *{* <commands...> *}*
- _commands..._ after *{* will be interpreted as seat commands applying to
- the specified seat. For details, see *sway-input*(5). A newline is required
- between *{* and the first command, and *}* must be alone on a line.
+*seat* <seat> <seat-subcommands...>
+ For details on seat subcommands, see *sway-input*(5).
*seat* <seat> cursor move|set <x> <y>
Move specified seat's cursor relative to current position or wrap to
@@ -465,10 +472,8 @@ The default colors are:
*mode* <mode>
Switches to the specified mode. The default mode _default_.
-*mode* [--pango\_markup] <mode> *{* <commands...> *}*
- _commands..._ after *{* will be added to the specified mode. A newline is
- required between *{* and the first command, and *}* must be alone on a
- line. Only *bindsym* and *bindcode* commands are permitted in mode blocks.
+*mode* [--pango\_markup] <mode> <mode-subcommands...>
+ The only two valid _mode-subcommands..._ are *bindsym* and *bindcode*.
If _--pango\_markup_ is given, then _mode_ will be interpreted as pango
markup.
@@ -533,8 +538,15 @@ You may combine output commands into one, like so:
output HDMI-A-1 mode 1920x1080 pos 1920,0 bg ~/wallpaper.png stretch
You can get a list of output names with *swaymsg -t get\_outputs*. You may also
-match any output by using the output name "\*". Be sure to add this output
-config after the others, or it will be matched instead of the others.
+match any output by using the output name "\*".
+
+*set* $<name> <value>
+ Sets variable $_name_ to _value_. You can use the new variable in the
+ arguments of future commands. When the variable is used, it can be escaped
+ with an additional $ (ie $$_name_) to have the replacement happen at run
+ time instead of when reading the config. However, it does not always make
+ sense for the variable to be replaced at run time since some arguments do
+ need to be known at config time.
*show\_marks* yes|no
If *show\_marks* is yes, marks will be displayed in the window borders.
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 53b127b7..baaa82fd 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -67,12 +67,10 @@ void container_destroy(struct sway_container *con) {
list_free(con->outputs);
if (con->view) {
- struct sway_view *view = con->view;
- view->container = NULL;
- free(view->title_format);
- view->title_format = NULL;
-
- if (view->destroying) {
+ if (con->view->container == con) {
+ con->view->container = NULL;
+ }
+ if (con->view->destroying) {
view_destroy(con->view);
}
}
@@ -985,7 +983,8 @@ void container_discover_outputs(struct sway_container *con) {
}
}
struct sway_output *new_output = container_get_effective_output(con);
- double old_scale = old_output ? old_output->wlr_output->scale : -1;
+ double old_scale = old_output && old_output->enabled ?
+ old_output->wlr_output->scale : -1;
double new_scale = new_output ? new_output->wlr_output->scale : -1;
if (old_scale != new_scale) {
container_update_title_textures(con);
diff --git a/sway/tree/view.c b/sway/tree/view.c
index e370443c..a024f325 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -989,12 +989,16 @@ bool view_is_visible(struct sway_view *view) {
floater = floater->parent;
}
bool is_sticky = container_is_floating(floater) && floater->is_sticky;
+ if (!is_sticky && !workspace_is_visible(workspace)) {
+ return false;
+ }
// Check view isn't in a tabbed or stacked container on an inactive tab
struct sway_seat *seat = input_manager_current_seat(input_manager);
struct sway_container *con = view->container;
while (con) {
enum sway_container_layout layout = container_parent_layout(con);
- if (layout == L_TABBED || layout == L_STACKED) {
+ if ((layout == L_TABBED || layout == L_STACKED)
+ && !container_is_floating(con)) {
struct sway_node *parent = con->parent ?
&con->parent->node : &con->workspace->node;
if (seat_get_active_tiling_child(seat, parent) != &con->node) {
@@ -1008,10 +1012,6 @@ bool view_is_visible(struct sway_view *view) {
!container_is_fullscreen_or_child(view->container)) {
return false;
}
- // Check the workspace is visible
- if (!is_sticky) {
- return workspace_is_visible(workspace);
- }
return true;
}
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 16031e87..d65a3e4c 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -20,17 +20,23 @@
#include "log.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) {
- // Search for workspace<->output pair
- for (int i = 0; i < config->workspace_outputs->length; ++i) {
- struct workspace_output *wso = config->workspace_outputs->items[i];
- if (strcasecmp(wso->workspace, name) == 0) {
- // Find output to use if it exists
- struct sway_output *output = output_by_name(wso->output);
- if (output) {
- return output;
- }
- break;
+ // Check workspace configs for a workspace<->output pair
+ struct workspace_config *wsc = workspace_find_config(name);
+ if (wsc && wsc->output) {
+ struct sway_output *output = output_by_name(wsc->output);
+ if (output) {
+ return output;
}
}
// Otherwise put it on the focused output
@@ -121,17 +127,8 @@ void next_name_map(struct sway_container *ws, void *data) {
static bool workspace_valid_on_output(const char *output_name,
const char *ws_name) {
- int i;
- for (i = 0; i < config->workspace_outputs->length; ++i) {
- 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;
+ struct workspace_config *wsc = workspace_find_config(ws_name);
+ return !wsc || !wsc->output || strcmp(wsc->output, output_name) == 0;
}
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],
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
- const struct workspace_output *wso = config->workspace_outputs->items[i];
- if (strcmp(wso->output, output_name) == 0
- && workspace_by_name(wso->workspace) == NULL) {
+ const struct workspace_config *wsc = config->workspace_configs->items[i];
+ if (wsc->output && strcmp(wsc->output, output_name) == 0
+ && workspace_by_name(wsc->workspace) == NULL) {
free(target);
- target = strdup(wso->workspace);
+ target = strdup(wsc->workspace);
break;
}
}