From 197d0ab82f64ea9a96786e55e375c930389aa85b Mon Sep 17 00:00:00 2001 From: siikamiika Date: Sun, 10 Oct 2021 01:57:48 +0300 Subject: commands/focus: focus view inside container seat_get_focus_inactive_floating and seat_get_focus_inactive_tiling do not always return a view, so get the previously focused view from the container with seat_get_focus_inactive_view. This is the i3 behavior. --- sway/commands/focus.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sway/commands') diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 6771ca2f..ceb43d45 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c @@ -267,6 +267,11 @@ static struct cmd_results *focus_mode(struct sway_workspace *ws, new_focus = seat_get_focus_inactive_tiling(seat, ws); } if (new_focus) { + struct sway_container *new_focus_view = + seat_get_focus_inactive_view(seat, &new_focus->node); + if (new_focus_view) { + new_focus = new_focus_view; + } seat_set_focus_container(seat, new_focus); // If we're on the floating layer and the floating container area -- cgit v1.2.3 From 9969de9e00a1ca89ded85d418a72c4ebbce91331 Mon Sep 17 00:00:00 2001 From: bR3iN Date: Thu, 28 Oct 2021 15:31:23 +0200 Subject: Add smart_gaps inverse_outer command Add a subcommand for `smart_gaps` that enables outer gaps only on workspaces with exactly one visible child. Also add documentation for `smart_gaps toggle`. --- sway/commands/smart_gaps.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sway/commands') diff --git a/sway/commands/smart_gaps.c b/sway/commands/smart_gaps.c index b27f9ccd..a6d165dc 100644 --- a/sway/commands/smart_gaps.c +++ b/sway/commands/smart_gaps.c @@ -15,7 +15,12 @@ struct cmd_results *cmd_smart_gaps(int argc, char **argv) { return error; } - config->smart_gaps = parse_boolean(argv[0], config->smart_gaps); + if (strcmp(argv[0], "inverse_outer") == 0) { + config->smart_gaps = SMART_GAPS_INVERSE_OUTER; + } else { + config->smart_gaps = parse_boolean(argv[0], config->smart_gaps) + ? SMART_GAPS_ON : SMART_GAPS_OFF; + } arrange_root(); -- cgit v1.2.3 From 38020d157ddb58e756c654e9a2ff203c1562b25b Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 21 Oct 2021 21:52:17 +0200 Subject: Bump RLIMIT_NOFILE Wayland compositors handle many file descriptors: client connections, DMA-BUFs, sync_files, wl_data_device pipes, and so on. Bump the limit to the max. Closes: https://github.com/swaywm/sway/issues/6285 --- sway/commands/exec_always.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sway/commands') diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c index fce337d5..b35065c1 100644 --- a/sway/commands/exec_always.c +++ b/sway/commands/exec_always.c @@ -7,6 +7,7 @@ #include #include "sway/commands.h" #include "sway/config.h" +#include "sway/server.h" #include "sway/tree/container.h" #include "sway/tree/root.h" #include "sway/tree/workspace.h" @@ -53,6 +54,7 @@ struct cmd_results *cmd_exec_process(int argc, char **argv) { // Fork process if ((pid = fork()) == 0) { // Fork child process again + restore_nofile_limit(); setsid(); sigset_t set; sigemptyset(&set); -- cgit v1.2.3 From a23cdbbea145e0890627743d316c0ab6fe6c9c1f Mon Sep 17 00:00:00 2001 From: Manuel Stoeckl Date: Thu, 2 Sep 2021 21:45:23 -0400 Subject: Add 'output render_bit_depth [8|10]' command This makes it possible to hint to the renderer and backends how many bits per channel the buffers that the compositor draws windows onto should have. Renderers and backends may deviate from this if they do not support the formats with higher bit depth. --- sway/commands/output.c | 1 + sway/commands/output/render_bit_depth.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 sway/commands/output/render_bit_depth.c (limited to 'sway/commands') diff --git a/sway/commands/output.c b/sway/commands/output.c index d8ef2885..42230bd7 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c @@ -18,6 +18,7 @@ static const struct cmd_handler output_handlers[] = { { "modeline", output_cmd_modeline }, { "pos", output_cmd_position }, { "position", output_cmd_position }, + { "render_bit_depth", output_cmd_render_bit_depth }, { "res", output_cmd_mode }, { "resolution", output_cmd_mode }, { "scale", output_cmd_scale }, diff --git a/sway/commands/output/render_bit_depth.c b/sway/commands/output/render_bit_depth.c new file mode 100644 index 00000000..c419321e --- /dev/null +++ b/sway/commands/output/render_bit_depth.c @@ -0,0 +1,29 @@ +#include +#include +#include "sway/commands.h" +#include "sway/config.h" + +struct cmd_results *output_cmd_render_bit_depth(int argc, char **argv) { + if (!config->handler_context.output_config) { + return cmd_results_new(CMD_FAILURE, "Missing output config"); + } + if (!argc) { + return cmd_results_new(CMD_INVALID, "Missing bit depth argument."); + } + + if (strcmp(*argv, "8") == 0) { + config->handler_context.output_config->render_bit_depth = + RENDER_BIT_DEPTH_8; + } else if (strcmp(*argv, "10") == 0) { + config->handler_context.output_config->render_bit_depth = + RENDER_BIT_DEPTH_10; + } else { + return cmd_results_new(CMD_INVALID, + "Invalid bit depth. Must be a value in (8|10)."); + } + + config->handler_context.leftovers.argc = argc - 1; + config->handler_context.leftovers.argv = argv + 1; + return NULL; +} + -- cgit v1.2.3 From 94dc486f0e2eb1693b64dcc84309794f17d0f79b Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Mon, 22 Nov 2021 20:52:19 -0800 Subject: ipc: make `bar mode|hidden_state` behave as documented sway-bar(5) says: > For compatibility with i3, bar mode [] syntax is > supported along with the sway only bar mode syntax. while the actual behavior is that `bar_cmd_mode` ignores already selected `config->current_bar` and applies the change to all the configured bars. --- sway/commands/bar/hidden_state.c | 2 +- sway/commands/bar/mode.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sway/commands') diff --git a/sway/commands/bar/hidden_state.c b/sway/commands/bar/hidden_state.c index 1f08a5d2..8b661e3a 100644 --- a/sway/commands/bar/hidden_state.c +++ b/sway/commands/bar/hidden_state.c @@ -54,7 +54,7 @@ struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) { } const char *state = argv[0]; - if (config->reading) { + if (config->current_bar) { error = bar_set_hidden_state(config->current_bar, state); } else { const char *id = argc == 2 ? argv[1] : NULL; diff --git a/sway/commands/bar/mode.c b/sway/commands/bar/mode.c index 8b3fb275..7c2f423b 100644 --- a/sway/commands/bar/mode.c +++ b/sway/commands/bar/mode.c @@ -58,7 +58,7 @@ struct cmd_results *bar_cmd_mode(int argc, char **argv) { } const char *mode = argv[0]; - if (config->reading) { + if (config->current_bar) { error = bar_set_mode(config->current_bar, mode); } else { const char *id = argc == 2 ? argv[1] : NULL; -- cgit v1.2.3 From 0cd8efe0bb669e71e9cdc30d96ae466cb583e605 Mon Sep 17 00:00:00 2001 From: Simon Zeni Date: Mon, 4 Oct 2021 10:04:46 -0400 Subject: sway: replace noop_output by fallback_output wlroots removed the support for the noop backend. Instead we rely on the headless backend to provide the fallback output. --- sway/commands/output.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sway/commands') diff --git a/sway/commands/output.c b/sway/commands/output.c index 42230bd7..125df5a7 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c @@ -34,9 +34,9 @@ struct cmd_results *cmd_output(int argc, char **argv) { return error; } - // The NOOP-1 output is a dummy output used when there's no outputs + // The HEADLESS-1 output is a dummy output used when there's no outputs // connected. It should never be configured. - if (strcasecmp(argv[0], root->noop_output->wlr_output->name) == 0) { + if (strcasecmp(argv[0], root->fallback_output->wlr_output->name) == 0) { return cmd_results_new(CMD_FAILURE, "Refusing to configure the no op output"); } @@ -53,7 +53,7 @@ struct cmd_results *cmd_output(int argc, char **argv) { if (!sway_output) { return cmd_results_new(CMD_FAILURE, "Unknown output"); } - if (sway_output == root->noop_output) { + if (sway_output == root->fallback_output) { return cmd_results_new(CMD_FAILURE, "Refusing to configure the no op output"); } -- cgit v1.2.3 From f7725011efd3bc2762a0d1002ea5071470962213 Mon Sep 17 00:00:00 2001 From: Vsevolod Date: Fri, 10 Dec 2021 17:09:29 +0200 Subject: Add focused_tab_title --- sway/commands/client.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sway/commands') diff --git a/sway/commands/client.c b/sway/commands/client.c index dd0694df..77263145 100644 --- a/sway/commands/client.c +++ b/sway/commands/client.c @@ -18,6 +18,12 @@ static struct cmd_results *handle_command(int argc, char **argv, char *cmd_name, return error; } + if (argc > 3 && strcmp(cmd_name, "client.focused_tab_title") == 0) { + sway_log(SWAY_ERROR, + "Warning: indicator and child_border colors have no effect for %s", + cmd_name); + } + struct border_colors colors = {0}; const char *ind_hex = argc > 3 ? argv[3] : default_indicator; const char *child_hex = argc > 4 ? argv[4] : argv[1]; // def to background @@ -80,3 +86,13 @@ struct cmd_results *cmd_client_noop(int argc, char **argv) { sway_log(SWAY_INFO, "Warning: %s is ignored by sway", argv[-1]); return cmd_results_new(CMD_SUCCESS, NULL); } + +struct cmd_results *cmd_client_focused_tab_title(int argc, char **argv) { + struct cmd_results *result = handle_command(argc, argv, + "client.focused_tab_title", + &config->border_colors.focused_tab_title, "#2e9ef4ff"); + if (result && result->status == CMD_SUCCESS) { + config->has_focused_tab_title = true; + } + return result; +} -- cgit v1.2.3 From 3ab1c7f15376511d3f76ec8a3c42c3758b8bc2a8 Mon Sep 17 00:00:00 2001 From: David96 Date: Sat, 8 Jan 2022 19:33:19 +0100 Subject: commands/move: Fix crash when pos_y is omitted Fixes #6737 (cherry picked from commit 1bf1d84b7535c3c132240ed7b18414dc6cfe7e8a) --- sway/commands/move.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sway/commands') diff --git a/sway/commands/move.c b/sway/commands/move.c index f2702fa1..1a05a7a6 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c @@ -874,6 +874,10 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) { return cmd_results_new(CMD_INVALID, "Invalid x position specified"); } + if (argc < 1) { + return cmd_results_new(CMD_FAILURE, expected_position_syntax); + } + struct movement_amount ly = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID }; // Y direction num_consumed_args = parse_movement_amount(argc, argv, &ly); -- cgit v1.2.3 From cd1a0aa29358cbc9f18517807cd9b329b67dd526 Mon Sep 17 00:00:00 2001 From: Patrick Hilhorst Date: Mon, 22 Nov 2021 19:44:22 +0100 Subject: treat fullscreen windows as 'tiled' for commands/focus (cherry picked from commit b2ee964434b25a0ccbccb1486b027f69ef34acff) --- sway/commands/focus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sway/commands') diff --git a/sway/commands/focus.c b/sway/commands/focus.c index ceb43d45..b8d28480 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c @@ -451,7 +451,8 @@ struct cmd_results *cmd_focus(int argc, char **argv) { return cmd_results_new(CMD_FAILURE, ""); } struct sway_node *next_focus = NULL; - if (container_is_floating(container)) { + if (container_is_floating(container) && + container->pending.fullscreen_mode == FULLSCREEN_NONE) { next_focus = node_get_in_direction_floating(container, seat, direction); } else { next_focus = node_get_in_direction_tiling(container, seat, direction, descend); -- cgit v1.2.3 From 3a65ad427a2922ef747521ac173caab9eb6cdab1 Mon Sep 17 00:00:00 2001 From: Ronan Pigott Date: Sat, 22 Jan 2022 10:52:03 -0700 Subject: cmd/swap: error on swapping a container with itself (cherry picked from commit feea4b44108cf971ff8d1d474a75128dd737c1db) --- sway/commands/swap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sway/commands') diff --git a/sway/commands/swap.c b/sway/commands/swap.c index ce5e5128..9355944d 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c @@ -126,10 +126,10 @@ void container_swap(struct sway_container *con1, struct sway_container *con2) { } enum sway_fullscreen_mode fs1 = con1->pending.fullscreen_mode; - enum sway_fullscreen_mode fs2 = con2->pending.fullscreen_mode; if (fs1) { container_fullscreen_disable(con1); } + enum sway_fullscreen_mode fs2 = con2->pending.fullscreen_mode; if (fs2) { container_fullscreen_disable(con2); } @@ -247,6 +247,9 @@ struct cmd_results *cmd_swap(int argc, char **argv) { } else if (!current) { error = cmd_results_new(CMD_FAILURE, "Can only swap with containers and views"); + } else if (current == other) { + error = cmd_results_new(CMD_FAILURE, + "Cannot swap a container with itself"); } else if (container_has_ancestor(current, other) || container_has_ancestor(other, current)) { error = cmd_results_new(CMD_FAILURE, -- cgit v1.2.3