aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Jonathan Buch <jbuch@synyx.de>2018-09-25 10:22:50 +0200
committerLibravatar Jonathan Buch <jbuch@synyx.de>2018-10-03 16:23:12 +0200
commit298ccb539c5f9d538e49364f45e57ff0d88df717 (patch)
tree147027d52b22aaa2bae2257235d29d01d3f620a5
parentMerge pull request #2757 from RyanDwyer/check-focus-stack-empty (diff)
downloadsway-298ccb539c5f9d538e49364f45e57ff0d88df717.tar.gz
sway-298ccb539c5f9d538e49364f45e57ff0d88df717.tar.zst
sway-298ccb539c5f9d538e49364f45e57ff0d88df717.zip
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.
-rw-r--r--include/sway/commands.h1
-rw-r--r--include/sway/config.h1
-rw-r--r--sway/commands.c1
-rw-r--r--sway/commands/raise_floating.c14
-rw-r--r--sway/config.c1
-rw-r--r--sway/input/seat.c15
-rw-r--r--sway/meson.build1
7 files changed, 33 insertions, 1 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
index 64f707f4..f7fafb96 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -125,6 +125,7 @@ sway_cmd cmd_floating_modifier;
125sway_cmd cmd_floating_scroll; 125sway_cmd cmd_floating_scroll;
126sway_cmd cmd_focus; 126sway_cmd cmd_focus;
127sway_cmd cmd_focus_follows_mouse; 127sway_cmd cmd_focus_follows_mouse;
128sway_cmd cmd_raise_floating;
128sway_cmd cmd_focus_on_window_activation; 129sway_cmd cmd_focus_on_window_activation;
129sway_cmd cmd_focus_wrapping; 130sway_cmd cmd_focus_wrapping;
130sway_cmd cmd_font; 131sway_cmd cmd_font;
diff --git a/include/sway/config.h b/include/sway/config.h
index 98a18b76..02ace979 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -359,6 +359,7 @@ struct sway_config {
359 359
360 // Flags 360 // Flags
361 bool focus_follows_mouse; 361 bool focus_follows_mouse;
362 bool raise_floating;
362 bool mouse_warping; 363 bool mouse_warping;
363 enum focus_wrapping_mode focus_wrapping; 364 enum focus_wrapping_mode focus_wrapping;
364 bool active; 365 bool active;
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[] = {
107 { "new_window", cmd_default_border }, 107 { "new_window", cmd_default_border },
108 { "no_focus", cmd_no_focus }, 108 { "no_focus", cmd_no_focus },
109 { "output", cmd_output }, 109 { "output", cmd_output },
110 { "raise_floating", cmd_raise_floating },
110 { "seat", cmd_seat }, 111 { "seat", cmd_seat },
111 { "set", cmd_set }, 112 { "set", cmd_set },
112 { "show_marks", cmd_show_marks }, 113 { "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 @@
1#include <string.h>
2#include <strings.h>
3#include "sway/commands.h"
4#include "util.h"
5
6struct cmd_results *cmd_raise_floating(int argc, char **argv) {
7 struct cmd_results *error = NULL;
8 if ((error = checkarg(argc, "raise_floating", EXPECTED_EQUAL_TO, 1))) {
9 return error;
10 }
11 config->raise_floating =
12 parse_boolean(argv[0], config->raise_floating);
13 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
14}
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) {
221 221
222 // Flags 222 // Flags
223 config->focus_follows_mouse = true; 223 config->focus_follows_mouse = true;
224 config->raise_floating = true;
224 config->mouse_warping = true; 225 config->mouse_warping = true;
225 config->focus_wrapping = WRAP_YES; 226 config->focus_wrapping = WRAP_YES;
226 config->validating = false; 227 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,
734 734
735 // If we've focused a floating container, bring it to the front. 735 // If we've focused a floating container, bring it to the front.
736 // We do this by putting it at the end of the floating list. 736 // We do this by putting it at the end of the floating list.
737 if (container) { 737 if (container && config->raise_floating) {
738 struct sway_container *floater = container; 738 struct sway_container *floater = container;
739 while (floater->parent) { 739 while (floater->parent) {
740 floater = floater->parent; 740 floater = floater->parent;
@@ -1017,6 +1017,19 @@ void seat_begin_down(struct sway_seat *seat, struct sway_container *con,
1017 seat->op_ref_con_lx = sx; 1017 seat->op_ref_con_lx = sx;
1018 seat->op_ref_con_ly = sy; 1018 seat->op_ref_con_ly = sy;
1019 seat->op_moved = false; 1019 seat->op_moved = false;
1020
1021 // If we've focused a floating container, bring it to the front.
1022 // We do this by putting it at the end of the floating list.
1023 if (con && !config->raise_floating) {
1024 struct sway_container *floater = con;
1025 while (floater->parent) {
1026 floater = floater->parent;
1027 }
1028 if (container_is_floating(floater)) {
1029 list_move_to_end(floater->workspace->floating, floater);
1030 node_set_dirty(&floater->workspace->node);
1031 }
1032 }
1020} 1033}
1021 1034
1022void seat_begin_move_floating(struct sway_seat *seat, 1035void 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(
48 'commands/floating_modifier.c', 48 'commands/floating_modifier.c',
49 'commands/focus.c', 49 'commands/focus.c',
50 'commands/focus_follows_mouse.c', 50 'commands/focus_follows_mouse.c',
51 'commands/raise_floating.c',
51 'commands/focus_on_window_activation.c', 52 'commands/focus_on_window_activation.c',
52 'commands/focus_wrapping.c', 53 'commands/focus_wrapping.c',
53 'commands/font.c', 54 'commands/font.c',