mirror of
https://github.com/swaywm/sway.git
synced 2025-11-12 13:29:56 -05:00
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
This commit is contained in:
parent
4799d07ac1
commit
78ca619769
6 changed files with 64 additions and 9 deletions
26
sway/focus.c
26
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue