diff options
-rw-r--r-- | include/sway/input/cursor.h | 2 | ||||
-rw-r--r-- | sway/input/cursor.c | 28 | ||||
-rw-r--r-- | sway/input/seat.c | 3 |
3 files changed, 12 insertions, 21 deletions
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 8f907dcd..daf7d4ee 100644 --- a/include/sway/input/cursor.h +++ b/include/sway/input/cursor.h | |||
@@ -8,7 +8,6 @@ struct sway_cursor { | |||
8 | struct wlr_cursor *cursor; | 8 | struct wlr_cursor *cursor; |
9 | struct wlr_xcursor_manager *xcursor_manager; | 9 | struct wlr_xcursor_manager *xcursor_manager; |
10 | 10 | ||
11 | double x, y; | ||
12 | struct wl_client *image_client; | 11 | struct wl_client *image_client; |
13 | 12 | ||
14 | struct wl_listener motion; | 13 | struct wl_listener motion; |
@@ -30,5 +29,6 @@ struct sway_cursor { | |||
30 | 29 | ||
31 | void sway_cursor_destroy(struct sway_cursor *cursor); | 30 | void sway_cursor_destroy(struct sway_cursor *cursor); |
32 | 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); | ||
33 | 33 | ||
34 | #endif | 34 | #endif |
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 4bcf72fc..0df01504 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -14,14 +14,6 @@ | |||
14 | #include "sway/tree/view.h" | 14 | #include "sway/tree/view.h" |
15 | #include "wlr-layer-shell-unstable-v1-protocol.h" | 15 | #include "wlr-layer-shell-unstable-v1-protocol.h" |
16 | 16 | ||
17 | static void cursor_update_position(struct sway_cursor *cursor) { | ||
18 | double x = cursor->cursor->x; | ||
19 | double y = cursor->cursor->y; | ||
20 | |||
21 | cursor->x = x; | ||
22 | cursor->y = y; | ||
23 | } | ||
24 | |||
25 | static struct wlr_surface *layer_surface_at(struct sway_output *output, | 17 | static struct wlr_surface *layer_surface_at(struct sway_output *output, |
26 | struct wl_list *layer, double ox, double oy, double *sx, double *sy) { | 18 | struct wl_list *layer, double ox, double oy, double *sx, double *sy) { |
27 | struct sway_layer_surface *sway_layer; | 19 | struct sway_layer_surface *sway_layer; |
@@ -53,8 +45,8 @@ static struct sway_container *container_at_cursor(struct sway_cursor *cursor, | |||
53 | struct wlr_xwayland_surface *xsurface = | 45 | struct wlr_xwayland_surface *xsurface = |
54 | unmanaged_surface->wlr_xwayland_surface; | 46 | unmanaged_surface->wlr_xwayland_surface; |
55 | 47 | ||
56 | double _sx = cursor->x - unmanaged_surface->lx; | 48 | double _sx = cursor->cursor->x - unmanaged_surface->lx; |
57 | double _sy = cursor->y - unmanaged_surface->ly; | 49 | double _sy = cursor->cursor->y - unmanaged_surface->ly; |
58 | if (wlr_surface_point_accepts_input(xsurface->surface, _sx, _sy)) { | 50 | if (wlr_surface_point_accepts_input(xsurface->surface, _sx, _sy)) { |
59 | *surface = xsurface->surface; | 51 | *surface = xsurface->surface; |
60 | *sx = _sx; | 52 | *sx = _sx; |
@@ -67,12 +59,13 @@ static struct sway_container *container_at_cursor(struct sway_cursor *cursor, | |||
67 | struct wlr_output_layout *output_layout = | 59 | struct wlr_output_layout *output_layout = |
68 | root_container.sway_root->output_layout; | 60 | root_container.sway_root->output_layout; |
69 | struct wlr_output *wlr_output = | 61 | struct wlr_output *wlr_output = |
70 | wlr_output_layout_output_at(output_layout, cursor->x, cursor->y); | 62 | wlr_output_layout_output_at(output_layout, |
63 | cursor->cursor->x, cursor->cursor->y); | ||
71 | if (wlr_output == NULL) { | 64 | if (wlr_output == NULL) { |
72 | return NULL; | 65 | return NULL; |
73 | } | 66 | } |
74 | struct sway_output *output = wlr_output->data; | 67 | struct sway_output *output = wlr_output->data; |
75 | double ox = cursor->x, oy = cursor->y; | 68 | double ox = cursor->cursor->x, oy = cursor->cursor->y; |
76 | wlr_output_layout_output_coords(output_layout, wlr_output, &ox, &oy); | 69 | wlr_output_layout_output_coords(output_layout, wlr_output, &ox, &oy); |
77 | 70 | ||
78 | // find the focused workspace on the output for this seat | 71 | // find the focused workspace on the output for this seat |
@@ -97,7 +90,8 @@ static struct sway_container *container_at_cursor(struct sway_cursor *cursor, | |||
97 | } | 90 | } |
98 | 91 | ||
99 | struct sway_container *c; | 92 | struct sway_container *c; |
100 | if ((c = container_at(ws, cursor->x, cursor->y, surface, sx, sy))) { | 93 | if ((c = container_at(ws, cursor->cursor->x, cursor->cursor->y, |
94 | surface, sx, sy))) { | ||
101 | return c; | 95 | return c; |
102 | } | 96 | } |
103 | 97 | ||
@@ -124,8 +118,7 @@ static struct sway_container *container_at_cursor(struct sway_cursor *cursor, | |||
124 | return output->swayc; | 118 | return output->swayc; |
125 | } | 119 | } |
126 | 120 | ||
127 | static void cursor_send_pointer_motion(struct sway_cursor *cursor, | 121 | void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time) { |
128 | uint32_t time) { | ||
129 | struct wlr_seat *seat = cursor->seat->wlr_seat; | 122 | struct wlr_seat *seat = cursor->seat->wlr_seat; |
130 | struct wlr_surface *surface = NULL; | 123 | struct wlr_surface *surface = NULL; |
131 | double sx, sy; | 124 | double sx, sy; |
@@ -161,7 +154,6 @@ static void handle_cursor_motion(struct wl_listener *listener, void *data) { | |||
161 | struct wlr_event_pointer_motion *event = data; | 154 | struct wlr_event_pointer_motion *event = data; |
162 | wlr_cursor_move(cursor->cursor, event->device, | 155 | wlr_cursor_move(cursor->cursor, event->device, |
163 | event->delta_x, event->delta_y); | 156 | event->delta_x, event->delta_y); |
164 | cursor_update_position(cursor); | ||
165 | cursor_send_pointer_motion(cursor, event->time_msec); | 157 | cursor_send_pointer_motion(cursor, event->time_msec); |
166 | } | 158 | } |
167 | 159 | ||
@@ -171,7 +163,6 @@ static void handle_cursor_motion_absolute( | |||
171 | wl_container_of(listener, cursor, motion_absolute); | 163 | wl_container_of(listener, cursor, motion_absolute); |
172 | struct wlr_event_pointer_motion_absolute *event = data; | 164 | struct wlr_event_pointer_motion_absolute *event = data; |
173 | wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y); | 165 | wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y); |
174 | cursor_update_position(cursor); | ||
175 | cursor_send_pointer_motion(cursor, event->time_msec); | 166 | cursor_send_pointer_motion(cursor, event->time_msec); |
176 | } | 167 | } |
177 | 168 | ||
@@ -254,15 +245,12 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) { | |||
254 | (event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) { | 245 | (event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) { |
255 | wlr_cursor_warp_absolute(cursor->cursor, event->device, | 246 | wlr_cursor_warp_absolute(cursor->cursor, event->device, |
256 | event->x, event->y); | 247 | event->x, event->y); |
257 | cursor_update_position(cursor); | ||
258 | cursor_send_pointer_motion(cursor, event->time_msec); | 248 | cursor_send_pointer_motion(cursor, event->time_msec); |
259 | } else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X)) { | 249 | } else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X)) { |
260 | wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, -1); | 250 | wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, -1); |
261 | cursor_update_position(cursor); | ||
262 | cursor_send_pointer_motion(cursor, event->time_msec); | 251 | cursor_send_pointer_motion(cursor, event->time_msec); |
263 | } else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) { | 252 | } else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) { |
264 | wlr_cursor_warp_absolute(cursor->cursor, event->device, -1, event->y); | 253 | wlr_cursor_warp_absolute(cursor->cursor, event->device, -1, event->y); |
265 | cursor_update_position(cursor); | ||
266 | cursor_send_pointer_motion(cursor, event->time_msec); | 254 | cursor_send_pointer_motion(cursor, event->time_msec); |
267 | } | 255 | } |
268 | } | 256 | } |
diff --git a/sway/input/seat.c b/sway/input/seat.c index c34da5e5..d9b42828 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -434,6 +434,9 @@ void seat_set_focus_warp(struct sway_seat *seat, | |||
434 | wlr_output, seat->cursor->cursor->x, | 434 | wlr_output, seat->cursor->cursor->x, |
435 | seat->cursor->cursor->y)) { | 435 | seat->cursor->cursor->y)) { |
436 | wlr_cursor_warp(seat->cursor->cursor, NULL, x, y); | 436 | wlr_cursor_warp(seat->cursor->cursor, NULL, x, y); |
437 | struct timespec now; | ||
438 | clock_gettime(CLOCK_MONOTONIC, &now); | ||
439 | cursor_send_pointer_motion(seat->cursor, now.tv_nsec / 1000); | ||
437 | } | 440 | } |
438 | } | 441 | } |
439 | } | 442 | } |