diff options
author | Jonathan Buch <jbuch@synyx.de> | 2018-09-25 10:22:50 +0200 |
---|---|---|
committer | Jonathan Buch <jbuch@synyx.de> | 2018-10-03 16:23:12 +0200 |
commit | 298ccb539c5f9d538e49364f45e57ff0d88df717 (patch) | |
tree | 147027d52b22aaa2bae2257235d29d01d3f620a5 /sway | |
parent | 01b8e171b8dd2dbdda1b1a652c39022602cd9dfb (diff) |
Add configuration for raising containers on focus
* New configuration option: raise_floating
(From the discussion on https://github.com/i3/i3/issues/2990)
* By default, it still raises the window on focus, otherwise it
will raise the window on click.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 1 | ||||
-rw-r--r-- | sway/commands/raise_floating.c | 14 | ||||
-rw-r--r-- | sway/config.c | 1 | ||||
-rw-r--r-- | sway/input/seat.c | 15 | ||||
-rw-r--r-- | sway/meson.build | 1 |
5 files changed, 31 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c index 72db8ab9..5dd27f7e 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -107,6 +107,7 @@ static struct cmd_handler handlers[] = { { "new_window", cmd_default_border }, { "no_focus", cmd_no_focus }, { "output", cmd_output }, + { "raise_floating", cmd_raise_floating }, { "seat", cmd_seat }, { "set", cmd_set }, { "show_marks", cmd_show_marks }, diff --git a/sway/commands/raise_floating.c b/sway/commands/raise_floating.c new file mode 100644 index 00000000..930299a1 --- /dev/null +++ b/sway/commands/raise_floating.c @@ -0,0 +1,14 @@ +#include <string.h> +#include <strings.h> +#include "sway/commands.h" +#include "util.h" + +struct cmd_results *cmd_raise_floating(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "raise_floating", EXPECTED_EQUAL_TO, 1))) { + return error; + } + config->raise_floating = + parse_boolean(argv[0], config->raise_floating); + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} diff --git a/sway/config.c b/sway/config.c index 048b57de..b56c4f71 100644 --- a/sway/config.c +++ b/sway/config.c @@ -221,6 +221,7 @@ static void config_defaults(struct sway_config *config) { // Flags config->focus_follows_mouse = true; + config->raise_floating = true; config->mouse_warping = true; config->focus_wrapping = WRAP_YES; config->validating = false; diff --git a/sway/input/seat.c b/sway/input/seat.c index 69bee47e..c747eafc 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -734,7 +734,7 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node, // If we've focused a floating container, bring it to the front. // We do this by putting it at the end of the floating list. - if (container) { + if (container && config->raise_floating) { struct sway_container *floater = container; while (floater->parent) { floater = floater->parent; @@ -1017,6 +1017,19 @@ void seat_begin_down(struct sway_seat *seat, struct sway_container *con, seat->op_ref_con_lx = sx; seat->op_ref_con_ly = sy; seat->op_moved = false; + + // If we've focused a floating container, bring it to the front. + // We do this by putting it at the end of the floating list. + if (con && !config->raise_floating) { + struct sway_container *floater = con; + while (floater->parent) { + floater = floater->parent; + } + if (container_is_floating(floater)) { + list_move_to_end(floater->workspace->floating, floater); + node_set_dirty(&floater->workspace->node); + } + } } void seat_begin_move_floating(struct sway_seat *seat, diff --git a/sway/meson.build b/sway/meson.build index 00ebcb40..8ab28869 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -48,6 +48,7 @@ sway_sources = files( 'commands/floating_modifier.c', 'commands/focus.c', 'commands/focus_follows_mouse.c', + 'commands/raise_floating.c', 'commands/focus_on_window_activation.c', 'commands/focus_wrapping.c', 'commands/font.c', |