aboutsummaryrefslogtreecommitdiff
path: root/sway/input
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-05-23 22:54:52 +0100
committeremersion <contact@emersion.fr>2018-05-23 22:54:52 +0100
commitcd0fca2ebf81c252b3743c4474a5fdbcd3e2afad (patch)
tree595f1e80551b64de0d4e24f5721bae27acc195d9 /sway/input
parentb7ab7c0e66433aacaaccce08d6e40304e6f6593c (diff)
parent12a12878b9883c345dd73752a9cf714aeb245b8a (diff)
downloadsway-cd0fca2ebf81c252b3743c4474a5fdbcd3e2afad.tar.xz
Merge branch 'master' into fix-swaylock-hotplugging
Diffstat (limited to 'sway/input')
-rw-r--r--sway/input/cursor.c31
-rw-r--r--sway/input/seat.c16
2 files changed, 38 insertions, 9 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 9259c475..9a0b4f01 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -108,7 +108,7 @@ static struct sway_container *container_at_coords(
}
struct sway_container *c;
- if ((c = container_at(ws, x, y, surface, sx, sy))) {
+ if ((c = container_at(ws, ox, oy, surface, sx, sy))) {
return c;
}
@@ -135,7 +135,8 @@ static struct sway_container *container_at_coords(
return output->swayc;
}
-void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec) {
+void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
+ bool allow_refocusing) {
if (time_msec == 0) {
time_msec = get_current_time_msec();
}
@@ -145,8 +146,24 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec)
double sx, sy;
struct sway_container *c = container_at_coords(cursor->seat,
cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy);
- if (c && config->focus_follows_mouse) {
- seat_set_focus_warp(cursor->seat, c, false);
+ if (c && config->focus_follows_mouse && allow_refocusing) {
+ struct sway_container *focus = seat_get_focus(cursor->seat);
+ if (focus && c->type == C_WORKSPACE) {
+ // Only follow the mouse if it would move to a new output
+ // Otherwise we'll focus the workspace, which is probably wrong
+ if (focus->type != C_OUTPUT) {
+ focus = container_parent(focus, C_OUTPUT);
+ }
+ struct sway_container *output = c;
+ if (output->type != C_OUTPUT) {
+ output = container_parent(c, C_OUTPUT);
+ }
+ if (output != focus) {
+ seat_set_focus_warp(cursor->seat, c, false);
+ }
+ } else {
+ seat_set_focus_warp(cursor->seat, c, false);
+ }
}
// reset cursor if switching between clients
@@ -177,7 +194,7 @@ static void handle_cursor_motion(struct wl_listener *listener, void *data) {
struct wlr_event_pointer_motion *event = data;
wlr_cursor_move(cursor->cursor, event->device,
event->delta_x, event->delta_y);
- cursor_send_pointer_motion(cursor, event->time_msec);
+ cursor_send_pointer_motion(cursor, event->time_msec, true);
}
static void handle_cursor_motion_absolute(
@@ -187,7 +204,7 @@ static void handle_cursor_motion_absolute(
wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat);
struct wlr_event_pointer_motion_absolute *event = data;
wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y);
- cursor_send_pointer_motion(cursor, event->time_msec);
+ cursor_send_pointer_motion(cursor, event->time_msec, true);
}
void dispatch_cursor_button(struct sway_cursor *cursor,
@@ -357,7 +374,7 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) {
}
wlr_cursor_warp_absolute(cursor->cursor, event->device, x, y);
- cursor_send_pointer_motion(cursor, event->time_msec);
+ cursor_send_pointer_motion(cursor, event->time_msec, true);
}
static void handle_tool_tip(struct wl_listener *listener, void *data) {
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 9ac3e6a8..7a3e928a 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -602,7 +602,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
wlr_output, seat->cursor->cursor->x,
seat->cursor->cursor->y)) {
wlr_cursor_warp(seat->cursor->cursor, NULL, x, y);
- cursor_send_pointer_motion(seat->cursor, 0);
+ cursor_send_pointer_motion(seat->cursor, 0, true);
}
}
}
@@ -613,7 +613,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
}
if (last_workspace && last_workspace != new_workspace) {
- cursor_send_pointer_motion(seat->cursor, 0);
+ cursor_send_pointer_motion(seat->cursor, 0, true);
}
seat->has_focus = (container != NULL);
@@ -718,6 +718,18 @@ struct sway_container *seat_get_focus_inactive(struct sway_seat *seat,
return seat_get_focus_by_type(seat, container, C_TYPES);
}
+struct sway_container *seat_get_active_child(struct sway_seat *seat,
+ struct sway_container *container) {
+ struct sway_container *focus = seat_get_focus_inactive(seat, container);
+ if (!focus) {
+ return NULL;
+ }
+ while (focus->parent != container) {
+ focus = focus->parent;
+ }
+ return focus;
+}
+
struct sway_container *sway_seat_get_focus(struct sway_seat *seat) {
if (!seat->has_focus) {
return NULL;