From a3d3c819cf38d7a04f79f6d5b16e11ac0a786135 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 19 May 2018 19:57:10 -0400 Subject: Fix focus_follows_mouse over swaybar If you moved your mouse over swaybar (e.g. to scroll between workspaces), focus would move to the workspace. This is not the right thing to do. The solution is complicated by the fact that if you move your mouse into a new output with an empty workspace, that workspace _should_ receive focus. --- sway/input/cursor.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'sway/input') diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 9259c475..3a73954c 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -146,7 +146,23 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec) 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->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 + struct sway_container *focus = seat_get_focus(cursor->seat); + 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 -- cgit v1.2.3 From 82cd55a67006a2817daa466fd2a56e3e5aa11e17 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Sun, 20 May 2018 23:12:33 -0400 Subject: Fix border commands from changing focus --- sway/input/cursor.c | 11 ++++++----- sway/input/seat.c | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'sway/input') diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 3a73954c..b0ce8002 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.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,7 +146,7 @@ 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) { + if (c && config->focus_follows_mouse && allow_refocusing) { if (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 @@ -193,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( @@ -203,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, @@ -373,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..7d541f6e 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); -- cgit v1.2.3 From c08f9bf257c38c92a75988d89fba2d4de6bb2aea Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 19 May 2018 22:54:50 +1000 Subject: Implement tabbed layout --- sway/input/cursor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sway/input') diff --git a/sway/input/cursor.c b/sway/input/cursor.c index b0ce8002..e0b987d2 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; } -- cgit v1.2.3 From efc07fb3d45e07529e3817b4a1598f2c3256d600 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 20 May 2018 09:11:55 +1000 Subject: Don't track damage for views on inactive tabs --- sway/input/seat.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'sway/input') diff --git a/sway/input/seat.c b/sway/input/seat.c index 7d541f6e..7a3e928a 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -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; -- cgit v1.2.3 From 8bbf78fdd430a7e315356ebeda36adbf48b8953d Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 21 May 2018 17:21:01 -0400 Subject: Fix focus follows mouse with no focus --- sway/input/cursor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sway/input') diff --git a/sway/input/cursor.c b/sway/input/cursor.c index e0b987d2..9a0b4f01 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -147,10 +147,10 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, struct sway_container *c = container_at_coords(cursor->seat, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); if (c && config->focus_follows_mouse && allow_refocusing) { - if (c->type == C_WORKSPACE) { + 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 - struct sway_container *focus = seat_get_focus(cursor->seat); if (focus->type != C_OUTPUT) { focus = container_parent(focus, C_OUTPUT); } -- cgit v1.2.3