summaryrefslogtreecommitdiffstats
path: root/sway/focus.c
diff options
context:
space:
mode:
authorLibravatar S. Christoffer Eliesen <christoffer@eliesen.no>2015-10-26 12:20:32 +0100
committerLibravatar S. Christoffer Eliesen <christoffer@eliesen.no>2015-10-29 17:41:33 +0100
commit78ca6197697d4f07eddf0c544daff85603adab90 (patch)
treee499ab901ab3371d5860e36db086ea8b46e8227e /sway/focus.c
parentinput_state: Extract 'pointer_position_set' function from handlers. (diff)
downloadsway-78ca6197697d4f07eddf0c544daff85603adab90.tar.gz
sway-78ca6197697d4f07eddf0c544daff85603adab90.tar.zst
sway-78ca6197697d4f07eddf0c544daff85603adab90.zip
commands: Learn mouse_warping.
Place mouse at center of focused view when changing to a workspace on a different output, if option is enabled. (This replicates existing i3 option.) This can be triggered in multiple ways: A) via `workspace <name>` which changes output B) via `focus <direction>` which changes output C) via `focus output <name>` which (obviously) changes output
Diffstat (limited to 'sway/focus.c')
-rw-r--r--sway/focus.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/sway/focus.c b/sway/focus.c
index 1aa7579b..7f0b1599 100644
--- a/sway/focus.c
+++ b/sway/focus.c
@@ -4,6 +4,8 @@
4#include "log.h" 4#include "log.h"
5#include "workspace.h" 5#include "workspace.h"
6#include "layout.h" 6#include "layout.h"
7#include "config.h"
8#include "input_state.h"
7 9
8bool locked_container_focus = false; 10bool locked_container_focus = false;
9bool locked_view_focus = false; 11bool locked_view_focus = false;
@@ -49,14 +51,24 @@ static void update_focus(swayc_t *c) {
49} 51}
50 52
51bool move_focus(enum movement_direction direction) { 53bool move_focus(enum movement_direction direction) {
52 swayc_t *view = get_focused_container(&root_container); 54 swayc_t *old_view = get_focused_container(&root_container);
53 view = get_swayc_in_direction(view, direction); 55 swayc_t *new_view = get_swayc_in_direction(old_view, direction);
54 if (view) { 56 if (!new_view) {
55 if (direction == MOVE_PARENT) { 57 return false;
56 return set_focused_container(view); 58 } else if (direction == MOVE_PARENT) {
57 } else { 59 return set_focused_container(new_view);
58 return set_focused_container(get_focused_view(view)); 60 } else if (config->mouse_warping) {
61 swayc_t *old_op = old_view->type == C_OUTPUT ?
62 old_view : swayc_parent_by_type(old_view, C_OUTPUT);
63 swayc_t *focused = get_focused_view(new_view);
64 if (set_focused_container(focused)) {
65 if (old_op != swayc_active_output() && focused && focused->type == C_VIEW) {
66 center_pointer_on(focused);
67 }
68 return true;
59 } 69 }
70 } else {
71 return set_focused_container(get_focused_view(new_view));
60 } 72 }
61 return false; 73 return false;
62} 74}