diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-05-20 23:12:33 -0400 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-05-20 23:12:33 -0400 |
commit | 82cd55a67006a2817daa466fd2a56e3e5aa11e17 (patch) | |
tree | 483fbc00ce738270067487978199b670e970893a | |
parent | Merge pull request #2007 from swaywm/fix-focus-follows-mouse (diff) | |
download | sway-82cd55a67006a2817daa466fd2a56e3e5aa11e17.tar.gz sway-82cd55a67006a2817daa466fd2a56e3e5aa11e17.tar.zst sway-82cd55a67006a2817daa466fd2a56e3e5aa11e17.zip |
Fix border commands from changing focus
-rw-r--r-- | include/sway/input/cursor.h | 3 | ||||
-rw-r--r-- | sway/commands/border.c | 2 | ||||
-rw-r--r-- | sway/commands/seat/cursor.c | 4 | ||||
-rw-r--r-- | sway/input/cursor.c | 11 | ||||
-rw-r--r-- | sway/input/seat.c | 4 |
5 files changed, 13 insertions, 11 deletions
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 20c1c903..42c894a4 100644 --- a/include/sway/input/cursor.h +++ b/include/sway/input/cursor.h | |||
@@ -29,7 +29,8 @@ struct sway_cursor { | |||
29 | 29 | ||
30 | void sway_cursor_destroy(struct sway_cursor *cursor); | 30 | void sway_cursor_destroy(struct sway_cursor *cursor); |
31 | struct sway_cursor *sway_cursor_create(struct sway_seat *seat); | 31 | struct sway_cursor *sway_cursor_create(struct sway_seat *seat); |
32 | void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec); | 32 | void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, |
33 | bool allow_refocusing); | ||
33 | void dispatch_cursor_button(struct sway_cursor *cursor, uint32_t time_msec, | 34 | void dispatch_cursor_button(struct sway_cursor *cursor, uint32_t time_msec, |
34 | uint32_t button, enum wlr_button_state state); | 35 | uint32_t button, enum wlr_button_state state); |
35 | 36 | ||
diff --git a/sway/commands/border.c b/sway/commands/border.c index 1eb06a21..4ba361da 100644 --- a/sway/commands/border.c +++ b/sway/commands/border.c | |||
@@ -41,7 +41,7 @@ struct cmd_results *cmd_border(int argc, char **argv) { | |||
41 | 41 | ||
42 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 42 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
43 | if (seat->cursor) { | 43 | if (seat->cursor) { |
44 | cursor_send_pointer_motion(seat->cursor, 0); | 44 | cursor_send_pointer_motion(seat->cursor, 0, false); |
45 | } | 45 | } |
46 | 46 | ||
47 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 47 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
diff --git a/sway/commands/seat/cursor.c b/sway/commands/seat/cursor.c index 929384b0..4d0a22c7 100644 --- a/sway/commands/seat/cursor.c +++ b/sway/commands/seat/cursor.c | |||
@@ -36,7 +36,7 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) { | |||
36 | int delta_x = strtol(argv[1], NULL, 10); | 36 | int delta_x = strtol(argv[1], NULL, 10); |
37 | int delta_y = strtol(argv[2], NULL, 10); | 37 | int delta_y = strtol(argv[2], NULL, 10); |
38 | wlr_cursor_move(cursor->cursor, NULL, delta_x, delta_y); | 38 | wlr_cursor_move(cursor->cursor, NULL, delta_x, delta_y); |
39 | cursor_send_pointer_motion(cursor, 0); | 39 | cursor_send_pointer_motion(cursor, 0, true); |
40 | } else if (strcasecmp(argv[0], "set") == 0) { | 40 | } else if (strcasecmp(argv[0], "set") == 0) { |
41 | if (argc < 3) { | 41 | if (argc < 3) { |
42 | return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); | 42 | return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); |
@@ -45,7 +45,7 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) { | |||
45 | float x = strtof(argv[1], NULL) / root_container.width; | 45 | float x = strtof(argv[1], NULL) / root_container.width; |
46 | float y = strtof(argv[2], NULL) / root_container.height; | 46 | float y = strtof(argv[2], NULL) / root_container.height; |
47 | wlr_cursor_warp_absolute(cursor->cursor, NULL, x, y); | 47 | wlr_cursor_warp_absolute(cursor->cursor, NULL, x, y); |
48 | cursor_send_pointer_motion(cursor, 0); | 48 | cursor_send_pointer_motion(cursor, 0, true); |
49 | } else { | 49 | } else { |
50 | if (argc < 2) { | 50 | if (argc < 2) { |
51 | return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); | 51 | return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); |
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( | |||
135 | return output->swayc; | 135 | return output->swayc; |
136 | } | 136 | } |
137 | 137 | ||
138 | void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec) { | 138 | void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, |
139 | bool allow_refocusing) { | ||
139 | if (time_msec == 0) { | 140 | if (time_msec == 0) { |
140 | time_msec = get_current_time_msec(); | 141 | time_msec = get_current_time_msec(); |
141 | } | 142 | } |
@@ -145,7 +146,7 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec) | |||
145 | double sx, sy; | 146 | double sx, sy; |
146 | struct sway_container *c = container_at_coords(cursor->seat, | 147 | struct sway_container *c = container_at_coords(cursor->seat, |
147 | cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); | 148 | cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); |
148 | if (c && config->focus_follows_mouse) { | 149 | if (c && config->focus_follows_mouse && allow_refocusing) { |
149 | if (c->type == C_WORKSPACE) { | 150 | if (c->type == C_WORKSPACE) { |
150 | // Only follow the mouse if it would move to a new output | 151 | // Only follow the mouse if it would move to a new output |
151 | // Otherwise we'll focus the workspace, which is probably wrong | 152 | // 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) { | |||
193 | struct wlr_event_pointer_motion *event = data; | 194 | struct wlr_event_pointer_motion *event = data; |
194 | wlr_cursor_move(cursor->cursor, event->device, | 195 | wlr_cursor_move(cursor->cursor, event->device, |
195 | event->delta_x, event->delta_y); | 196 | event->delta_x, event->delta_y); |
196 | cursor_send_pointer_motion(cursor, event->time_msec); | 197 | cursor_send_pointer_motion(cursor, event->time_msec, true); |
197 | } | 198 | } |
198 | 199 | ||
199 | static void handle_cursor_motion_absolute( | 200 | static void handle_cursor_motion_absolute( |
@@ -203,7 +204,7 @@ static void handle_cursor_motion_absolute( | |||
203 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); | 204 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); |
204 | struct wlr_event_pointer_motion_absolute *event = data; | 205 | struct wlr_event_pointer_motion_absolute *event = data; |
205 | wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y); | 206 | wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y); |
206 | cursor_send_pointer_motion(cursor, event->time_msec); | 207 | cursor_send_pointer_motion(cursor, event->time_msec, true); |
207 | } | 208 | } |
208 | 209 | ||
209 | void dispatch_cursor_button(struct sway_cursor *cursor, | 210 | void dispatch_cursor_button(struct sway_cursor *cursor, |
@@ -373,7 +374,7 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) { | |||
373 | } | 374 | } |
374 | 375 | ||
375 | wlr_cursor_warp_absolute(cursor->cursor, event->device, x, y); | 376 | wlr_cursor_warp_absolute(cursor->cursor, event->device, x, y); |
376 | cursor_send_pointer_motion(cursor, event->time_msec); | 377 | cursor_send_pointer_motion(cursor, event->time_msec, true); |
377 | } | 378 | } |
378 | 379 | ||
379 | static void handle_tool_tip(struct wl_listener *listener, void *data) { | 380 | 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, | |||
602 | wlr_output, seat->cursor->cursor->x, | 602 | wlr_output, seat->cursor->cursor->x, |
603 | seat->cursor->cursor->y)) { | 603 | seat->cursor->cursor->y)) { |
604 | wlr_cursor_warp(seat->cursor->cursor, NULL, x, y); | 604 | wlr_cursor_warp(seat->cursor->cursor, NULL, x, y); |
605 | cursor_send_pointer_motion(seat->cursor, 0); | 605 | cursor_send_pointer_motion(seat->cursor, 0, true); |
606 | } | 606 | } |
607 | } | 607 | } |
608 | } | 608 | } |
@@ -613,7 +613,7 @@ void seat_set_focus_warp(struct sway_seat *seat, | |||
613 | } | 613 | } |
614 | 614 | ||
615 | if (last_workspace && last_workspace != new_workspace) { | 615 | if (last_workspace && last_workspace != new_workspace) { |
616 | cursor_send_pointer_motion(seat->cursor, 0); | 616 | cursor_send_pointer_motion(seat->cursor, 0, true); |
617 | } | 617 | } |
618 | 618 | ||
619 | seat->has_focus = (container != NULL); | 619 | seat->has_focus = (container != NULL); |