diff options
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r-- | sway/input/cursor.c | 31 |
1 files changed, 24 insertions, 7 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( | |||
108 | } | 108 | } |
109 | 109 | ||
110 | struct sway_container *c; | 110 | struct sway_container *c; |
111 | if ((c = container_at(ws, x, y, surface, sx, sy))) { | 111 | if ((c = container_at(ws, ox, oy, surface, sx, sy))) { |
112 | return c; | 112 | return c; |
113 | } | 113 | } |
114 | 114 | ||
@@ -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,8 +146,24 @@ 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 | seat_set_focus_warp(cursor->seat, c, false); | 150 | struct sway_container *focus = seat_get_focus(cursor->seat); |
151 | if (focus && c->type == C_WORKSPACE) { | ||
152 | // Only follow the mouse if it would move to a new output | ||
153 | // Otherwise we'll focus the workspace, which is probably wrong | ||
154 | if (focus->type != C_OUTPUT) { | ||
155 | focus = container_parent(focus, C_OUTPUT); | ||
156 | } | ||
157 | struct sway_container *output = c; | ||
158 | if (output->type != C_OUTPUT) { | ||
159 | output = container_parent(c, C_OUTPUT); | ||
160 | } | ||
161 | if (output != focus) { | ||
162 | seat_set_focus_warp(cursor->seat, c, false); | ||
163 | } | ||
164 | } else { | ||
165 | seat_set_focus_warp(cursor->seat, c, false); | ||
166 | } | ||
150 | } | 167 | } |
151 | 168 | ||
152 | // reset cursor if switching between clients | 169 | // reset cursor if switching between clients |
@@ -177,7 +194,7 @@ static void handle_cursor_motion(struct wl_listener *listener, void *data) { | |||
177 | struct wlr_event_pointer_motion *event = data; | 194 | struct wlr_event_pointer_motion *event = data; |
178 | wlr_cursor_move(cursor->cursor, event->device, | 195 | wlr_cursor_move(cursor->cursor, event->device, |
179 | event->delta_x, event->delta_y); | 196 | event->delta_x, event->delta_y); |
180 | cursor_send_pointer_motion(cursor, event->time_msec); | 197 | cursor_send_pointer_motion(cursor, event->time_msec, true); |
181 | } | 198 | } |
182 | 199 | ||
183 | static void handle_cursor_motion_absolute( | 200 | static void handle_cursor_motion_absolute( |
@@ -187,7 +204,7 @@ static void handle_cursor_motion_absolute( | |||
187 | 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); |
188 | struct wlr_event_pointer_motion_absolute *event = data; | 205 | struct wlr_event_pointer_motion_absolute *event = data; |
189 | 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); |
190 | cursor_send_pointer_motion(cursor, event->time_msec); | 207 | cursor_send_pointer_motion(cursor, event->time_msec, true); |
191 | } | 208 | } |
192 | 209 | ||
193 | void dispatch_cursor_button(struct sway_cursor *cursor, | 210 | void dispatch_cursor_button(struct sway_cursor *cursor, |
@@ -357,7 +374,7 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) { | |||
357 | } | 374 | } |
358 | 375 | ||
359 | wlr_cursor_warp_absolute(cursor->cursor, event->device, x, y); | 376 | wlr_cursor_warp_absolute(cursor->cursor, event->device, x, y); |
360 | cursor_send_pointer_motion(cursor, event->time_msec); | 377 | cursor_send_pointer_motion(cursor, event->time_msec, true); |
361 | } | 378 | } |
362 | 379 | ||
363 | static void handle_tool_tip(struct wl_listener *listener, void *data) { | 380 | static void handle_tool_tip(struct wl_listener *listener, void *data) { |