mirror of
https://github.com/swaywm/sway.git
synced 2024-11-27 02:11:28 +00:00
Merge pull request #1778 from swaywm/fix-cursor
Fix cursor motion issues
This commit is contained in:
commit
26e5974496
|
@ -8,7 +8,6 @@ struct sway_cursor {
|
||||||
struct wlr_cursor *cursor;
|
struct wlr_cursor *cursor;
|
||||||
struct wlr_xcursor_manager *xcursor_manager;
|
struct wlr_xcursor_manager *xcursor_manager;
|
||||||
|
|
||||||
double x, y;
|
|
||||||
struct wl_client *image_client;
|
struct wl_client *image_client;
|
||||||
|
|
||||||
struct wl_listener motion;
|
struct wl_listener motion;
|
||||||
|
@ -30,5 +29,6 @@ struct sway_cursor {
|
||||||
|
|
||||||
void sway_cursor_destroy(struct sway_cursor *cursor);
|
void sway_cursor_destroy(struct sway_cursor *cursor);
|
||||||
struct sway_cursor *sway_cursor_create(struct sway_seat *seat);
|
struct sway_cursor *sway_cursor_create(struct sway_seat *seat);
|
||||||
|
void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,14 +14,6 @@
|
||||||
#include "sway/tree/view.h"
|
#include "sway/tree/view.h"
|
||||||
#include "wlr-layer-shell-unstable-v1-protocol.h"
|
#include "wlr-layer-shell-unstable-v1-protocol.h"
|
||||||
|
|
||||||
static void cursor_update_position(struct sway_cursor *cursor) {
|
|
||||||
double x = cursor->cursor->x;
|
|
||||||
double y = cursor->cursor->y;
|
|
||||||
|
|
||||||
cursor->x = x;
|
|
||||||
cursor->y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct wlr_surface *layer_surface_at(struct sway_output *output,
|
static struct wlr_surface *layer_surface_at(struct sway_output *output,
|
||||||
struct wl_list *layer, double ox, double oy, double *sx, double *sy) {
|
struct wl_list *layer, double ox, double oy, double *sx, double *sy) {
|
||||||
struct sway_layer_surface *sway_layer;
|
struct sway_layer_surface *sway_layer;
|
||||||
|
@ -53,8 +45,8 @@ static struct sway_container *container_at_cursor(struct sway_cursor *cursor,
|
||||||
struct wlr_xwayland_surface *xsurface =
|
struct wlr_xwayland_surface *xsurface =
|
||||||
unmanaged_surface->wlr_xwayland_surface;
|
unmanaged_surface->wlr_xwayland_surface;
|
||||||
|
|
||||||
double _sx = cursor->x - unmanaged_surface->lx;
|
double _sx = cursor->cursor->x - unmanaged_surface->lx;
|
||||||
double _sy = cursor->y - unmanaged_surface->ly;
|
double _sy = cursor->cursor->y - unmanaged_surface->ly;
|
||||||
if (wlr_surface_point_accepts_input(xsurface->surface, _sx, _sy)) {
|
if (wlr_surface_point_accepts_input(xsurface->surface, _sx, _sy)) {
|
||||||
*surface = xsurface->surface;
|
*surface = xsurface->surface;
|
||||||
*sx = _sx;
|
*sx = _sx;
|
||||||
|
@ -67,12 +59,13 @@ static struct sway_container *container_at_cursor(struct sway_cursor *cursor,
|
||||||
struct wlr_output_layout *output_layout =
|
struct wlr_output_layout *output_layout =
|
||||||
root_container.sway_root->output_layout;
|
root_container.sway_root->output_layout;
|
||||||
struct wlr_output *wlr_output =
|
struct wlr_output *wlr_output =
|
||||||
wlr_output_layout_output_at(output_layout, cursor->x, cursor->y);
|
wlr_output_layout_output_at(output_layout,
|
||||||
|
cursor->cursor->x, cursor->cursor->y);
|
||||||
if (wlr_output == NULL) {
|
if (wlr_output == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
struct sway_output *output = wlr_output->data;
|
struct sway_output *output = wlr_output->data;
|
||||||
double ox = cursor->x, oy = cursor->y;
|
double ox = cursor->cursor->x, oy = cursor->cursor->y;
|
||||||
wlr_output_layout_output_coords(output_layout, wlr_output, &ox, &oy);
|
wlr_output_layout_output_coords(output_layout, wlr_output, &ox, &oy);
|
||||||
|
|
||||||
// find the focused workspace on the output for this seat
|
// 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,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sway_container *c;
|
struct sway_container *c;
|
||||||
if ((c = container_at(ws, cursor->x, cursor->y, surface, sx, sy))) {
|
if ((c = container_at(ws, cursor->cursor->x, cursor->cursor->y,
|
||||||
|
surface, sx, sy))) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,8 +118,7 @@ static struct sway_container *container_at_cursor(struct sway_cursor *cursor,
|
||||||
return output->swayc;
|
return output->swayc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cursor_send_pointer_motion(struct sway_cursor *cursor,
|
void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time) {
|
||||||
uint32_t time) {
|
|
||||||
struct wlr_seat *seat = cursor->seat->wlr_seat;
|
struct wlr_seat *seat = cursor->seat->wlr_seat;
|
||||||
struct wlr_surface *surface = NULL;
|
struct wlr_surface *surface = NULL;
|
||||||
double sx, sy;
|
double sx, sy;
|
||||||
|
@ -161,7 +154,6 @@ static void handle_cursor_motion(struct wl_listener *listener, void *data) {
|
||||||
struct wlr_event_pointer_motion *event = data;
|
struct wlr_event_pointer_motion *event = data;
|
||||||
wlr_cursor_move(cursor->cursor, event->device,
|
wlr_cursor_move(cursor->cursor, event->device,
|
||||||
event->delta_x, event->delta_y);
|
event->delta_x, event->delta_y);
|
||||||
cursor_update_position(cursor);
|
|
||||||
cursor_send_pointer_motion(cursor, event->time_msec);
|
cursor_send_pointer_motion(cursor, event->time_msec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +163,6 @@ static void handle_cursor_motion_absolute(
|
||||||
wl_container_of(listener, cursor, motion_absolute);
|
wl_container_of(listener, cursor, motion_absolute);
|
||||||
struct wlr_event_pointer_motion_absolute *event = data;
|
struct wlr_event_pointer_motion_absolute *event = data;
|
||||||
wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y);
|
wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y);
|
||||||
cursor_update_position(cursor);
|
|
||||||
cursor_send_pointer_motion(cursor, event->time_msec);
|
cursor_send_pointer_motion(cursor, event->time_msec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,15 +245,12 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) {
|
||||||
(event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
|
(event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
|
||||||
wlr_cursor_warp_absolute(cursor->cursor, event->device,
|
wlr_cursor_warp_absolute(cursor->cursor, event->device,
|
||||||
event->x, event->y);
|
event->x, event->y);
|
||||||
cursor_update_position(cursor);
|
|
||||||
cursor_send_pointer_motion(cursor, event->time_msec);
|
cursor_send_pointer_motion(cursor, event->time_msec);
|
||||||
} else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X)) {
|
} else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X)) {
|
||||||
wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, -1);
|
wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, -1);
|
||||||
cursor_update_position(cursor);
|
|
||||||
cursor_send_pointer_motion(cursor, event->time_msec);
|
cursor_send_pointer_motion(cursor, event->time_msec);
|
||||||
} else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
|
} else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
|
||||||
wlr_cursor_warp_absolute(cursor->cursor, event->device, -1, event->y);
|
wlr_cursor_warp_absolute(cursor->cursor, event->device, -1, event->y);
|
||||||
cursor_update_position(cursor);
|
|
||||||
cursor_send_pointer_motion(cursor, event->time_msec);
|
cursor_send_pointer_motion(cursor, event->time_msec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -434,6 +434,9 @@ void seat_set_focus_warp(struct sway_seat *seat,
|
||||||
wlr_output, seat->cursor->cursor->x,
|
wlr_output, seat->cursor->cursor->x,
|
||||||
seat->cursor->cursor->y)) {
|
seat->cursor->cursor->y)) {
|
||||||
wlr_cursor_warp(seat->cursor->cursor, NULL, x, y);
|
wlr_cursor_warp(seat->cursor->cursor, NULL, x, y);
|
||||||
|
struct timespec now;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
cursor_send_pointer_motion(seat->cursor, now.tv_nsec / 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue