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.
This commit is contained in:
Jonathan Buch 2018-09-25 10:22:50 +02:00
parent 01b8e171b8
commit 298ccb539c
No known key found for this signature in database
GPG Key ID: 9C46821E98B3343B
7 changed files with 33 additions and 1 deletions

View File

@ -125,6 +125,7 @@ sway_cmd cmd_floating_modifier;
sway_cmd cmd_floating_scroll; sway_cmd cmd_floating_scroll;
sway_cmd cmd_focus; sway_cmd cmd_focus;
sway_cmd cmd_focus_follows_mouse; sway_cmd cmd_focus_follows_mouse;
sway_cmd cmd_raise_floating;
sway_cmd cmd_focus_on_window_activation; sway_cmd cmd_focus_on_window_activation;
sway_cmd cmd_focus_wrapping; sway_cmd cmd_focus_wrapping;
sway_cmd cmd_font; sway_cmd cmd_font;

View File

@ -359,6 +359,7 @@ struct sway_config {
// Flags // Flags
bool focus_follows_mouse; bool focus_follows_mouse;
bool raise_floating;
bool mouse_warping; bool mouse_warping;
enum focus_wrapping_mode focus_wrapping; enum focus_wrapping_mode focus_wrapping;
bool active; bool active;

View File

@ -107,6 +107,7 @@ static struct cmd_handler handlers[] = {
{ "new_window", cmd_default_border }, { "new_window", cmd_default_border },
{ "no_focus", cmd_no_focus }, { "no_focus", cmd_no_focus },
{ "output", cmd_output }, { "output", cmd_output },
{ "raise_floating", cmd_raise_floating },
{ "seat", cmd_seat }, { "seat", cmd_seat },
{ "set", cmd_set }, { "set", cmd_set },
{ "show_marks", cmd_show_marks }, { "show_marks", cmd_show_marks },

View File

@ -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);
}

View File

@ -221,6 +221,7 @@ static void config_defaults(struct sway_config *config) {
// Flags // Flags
config->focus_follows_mouse = true; config->focus_follows_mouse = true;
config->raise_floating = true;
config->mouse_warping = true; config->mouse_warping = true;
config->focus_wrapping = WRAP_YES; config->focus_wrapping = WRAP_YES;
config->validating = false; config->validating = false;

View File

@ -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. // 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. // 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; struct sway_container *floater = container;
while (floater->parent) { while (floater->parent) {
floater = 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_lx = sx;
seat->op_ref_con_ly = sy; seat->op_ref_con_ly = sy;
seat->op_moved = false; 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, void seat_begin_move_floating(struct sway_seat *seat,

View File

@ -48,6 +48,7 @@ sway_sources = files(
'commands/floating_modifier.c', 'commands/floating_modifier.c',
'commands/focus.c', 'commands/focus.c',
'commands/focus_follows_mouse.c', 'commands/focus_follows_mouse.c',
'commands/raise_floating.c',
'commands/focus_on_window_activation.c', 'commands/focus_on_window_activation.c',
'commands/focus_wrapping.c', 'commands/focus_wrapping.c',
'commands/font.c', 'commands/font.c',