aboutsummaryrefslogtreecommitdiff
path: root/sway/focus.c
diff options
context:
space:
mode:
authorS. Christoffer Eliesen <christoffer@eliesen.no>2015-10-26 12:20:32 +0100
committerS. Christoffer Eliesen <christoffer@eliesen.no>2015-10-29 17:41:33 +0100
commit78ca6197697d4f07eddf0c544daff85603adab90 (patch)
treee499ab901ab3371d5860e36db086ea8b46e8227e /sway/focus.c
parent4799d07ac1bb08a770ee702eb3fd0ab4654f878a (diff)
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 @@
#include "log.h"
#include "workspace.h"
#include "layout.h"
+#include "config.h"
+#include "input_state.h"
bool locked_container_focus = false;
bool locked_view_focus = false;
@@ -49,14 +51,24 @@ static void update_focus(swayc_t *c) {
}
bool move_focus(enum movement_direction direction) {
- swayc_t *view = get_focused_container(&root_container);
- view = get_swayc_in_direction(view, direction);
- if (view) {
- if (direction == MOVE_PARENT) {
- return set_focused_container(view);
- } else {
- return set_focused_container(get_focused_view(view));
+ swayc_t *old_view = get_focused_container(&root_container);
+ swayc_t *new_view = get_swayc_in_direction(old_view, direction);
+ if (!new_view) {
+ return false;
+ } else if (direction == MOVE_PARENT) {
+ return set_focused_container(new_view);
+ } else if (config->mouse_warping) {
+ swayc_t *old_op = old_view->type == C_OUTPUT ?
+ old_view : swayc_parent_by_type(old_view, C_OUTPUT);
+ swayc_t *focused = get_focused_view(new_view);
+ if (set_focused_container(focused)) {
+ if (old_op != swayc_active_output() && focused && focused->type == C_VIEW) {
+ center_pointer_on(focused);
+ }
+ return true;
}
+ } else {
+ return set_focused_container(get_focused_view(new_view));
}
return false;
}