seat: don't send motion if pointer hasn't moved
This commit is contained in:
parent
c505ce3019
commit
d6de329d98
|
@ -135,6 +135,7 @@ struct wlr_seat_pointer_state {
|
||||||
struct wlr_seat *seat;
|
struct wlr_seat *seat;
|
||||||
struct wlr_seat_client *focused_client;
|
struct wlr_seat_client *focused_client;
|
||||||
struct wlr_surface *focused_surface;
|
struct wlr_surface *focused_surface;
|
||||||
|
double sx, sy;
|
||||||
|
|
||||||
struct wlr_seat_pointer_grab *grab;
|
struct wlr_seat_pointer_grab *grab;
|
||||||
struct wlr_seat_pointer_grab *default_grab;
|
struct wlr_seat_pointer_grab *default_grab;
|
||||||
|
|
|
@ -101,8 +101,7 @@ static void seat_view_deco_button(struct roots_seat_view *view, double sx,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void roots_passthrough_cursor(struct roots_cursor *cursor,
|
static void roots_passthrough_cursor(struct roots_cursor *cursor,
|
||||||
int64_t time) {
|
uint32_t time) {
|
||||||
bool focus_changed;
|
|
||||||
double sx, sy;
|
double sx, sy;
|
||||||
struct roots_view *view = NULL;
|
struct roots_view *view = NULL;
|
||||||
struct roots_seat *seat = cursor->seat;
|
struct roots_seat *seat = cursor->seat;
|
||||||
|
@ -146,11 +145,8 @@ static void roots_passthrough_cursor(struct roots_cursor *cursor,
|
||||||
cursor->wlr_surface = surface;
|
cursor->wlr_surface = surface;
|
||||||
|
|
||||||
if (surface) {
|
if (surface) {
|
||||||
focus_changed = (seat->seat->pointer_state.focused_surface != surface);
|
|
||||||
wlr_seat_pointer_notify_enter(seat->seat, surface, sx, sy);
|
wlr_seat_pointer_notify_enter(seat->seat, surface, sx, sy);
|
||||||
if (!focus_changed && time > 0) {
|
|
||||||
wlr_seat_pointer_notify_motion(seat->seat, time, sx, sy);
|
wlr_seat_pointer_notify_motion(seat->seat, time, sx, sy);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
wlr_seat_pointer_clear_focus(seat->seat);
|
wlr_seat_pointer_clear_focus(seat->seat);
|
||||||
}
|
}
|
||||||
|
@ -161,8 +157,15 @@ static void roots_passthrough_cursor(struct roots_cursor *cursor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int64_t timespec_to_msec(const struct timespec *a) {
|
||||||
|
return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000;
|
||||||
|
}
|
||||||
|
|
||||||
void roots_cursor_update_focus(struct roots_cursor *cursor) {
|
void roots_cursor_update_focus(struct roots_cursor *cursor) {
|
||||||
roots_passthrough_cursor(cursor, -1);
|
struct timespec now;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
roots_passthrough_cursor(cursor, timespec_to_msec(&now));
|
||||||
}
|
}
|
||||||
|
|
||||||
void roots_cursor_update_position(struct roots_cursor *cursor,
|
void roots_cursor_update_position(struct roots_cursor *cursor,
|
||||||
|
|
|
@ -136,10 +136,11 @@ static inline int64_t timespec_to_msec(const struct timespec *a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void input_update_cursor_focus(struct roots_input *input) {
|
void input_update_cursor_focus(struct roots_input *input) {
|
||||||
struct roots_seat *seat;
|
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
wl_list_for_each(seat, &input->seats, link) {
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
struct roots_seat *seat;
|
||||||
|
wl_list_for_each(seat, &input->seats, link) {
|
||||||
roots_cursor_update_position(seat->cursor, timespec_to_msec(&now));
|
roots_cursor_update_position(seat->cursor, timespec_to_msec(&now));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,6 +187,13 @@ void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
|
||||||
|
|
||||||
wlr_seat->pointer_state.focused_client = client;
|
wlr_seat->pointer_state.focused_client = client;
|
||||||
wlr_seat->pointer_state.focused_surface = surface;
|
wlr_seat->pointer_state.focused_surface = surface;
|
||||||
|
if (surface != NULL) {
|
||||||
|
wlr_seat->pointer_state.sx = sx;
|
||||||
|
wlr_seat->pointer_state.sy = sy;
|
||||||
|
} else {
|
||||||
|
wlr_seat->pointer_state.sx = NAN;
|
||||||
|
wlr_seat->pointer_state.sy = NAN;
|
||||||
|
}
|
||||||
|
|
||||||
struct wlr_seat_pointer_focus_change_event event = {
|
struct wlr_seat_pointer_focus_change_event event = {
|
||||||
.seat = wlr_seat,
|
.seat = wlr_seat,
|
||||||
|
@ -209,6 +216,10 @@ void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wlr_seat->pointer_state.sx == sx && wlr_seat->pointer_state.sy == sy) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
wl_resource_for_each(resource, &client->pointers) {
|
wl_resource_for_each(resource, &client->pointers) {
|
||||||
if (wlr_seat_client_from_pointer_resource(resource) == NULL) {
|
if (wlr_seat_client_from_pointer_resource(resource) == NULL) {
|
||||||
|
@ -218,6 +229,9 @@ void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time,
|
||||||
wl_pointer_send_motion(resource, time, wl_fixed_from_double(sx),
|
wl_pointer_send_motion(resource, time, wl_fixed_from_double(sx),
|
||||||
wl_fixed_from_double(sy));
|
wl_fixed_from_double(sy));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wlr_seat->pointer_state.sx = sx;
|
||||||
|
wlr_seat->pointer_state.sy = sy;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time,
|
uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time,
|
||||||
|
|
Loading…
Reference in New Issue