pointer: add a frame event

Frame events group logically connected pointer events. It makes sense to make
the backend responsible for sending frame events, since once the events are
split (ie. once the frame events are stripped) it's not easy to figure out
which events belongs to which frame again.

This is also how Weston handles frame events.

Fixes https://github.com/swaywm/wlroots/issues/1468
This commit is contained in:
emersion 2019-01-26 11:04:05 +01:00
parent 209210d307
commit 5de26ad8ed
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
14 changed files with 96 additions and 21 deletions

View file

@ -31,6 +31,10 @@ static void default_pointer_axis(struct wlr_seat_pointer_grab *grab,
value_discrete, source);
}
static void default_pointer_frame(struct wlr_seat_pointer_grab *grab) {
wlr_seat_pointer_send_frame(grab->seat);
}
static void default_pointer_cancel(struct wlr_seat_pointer_grab *grab) {
// cannot be cancelled
}
@ -40,6 +44,7 @@ const struct wlr_pointer_grab_interface default_pointer_grab_impl = {
.motion = default_pointer_motion,
.button = default_pointer_button,
.axis = default_pointer_axis,
.frame = default_pointer_frame,
.cancel = default_pointer_cancel,
};
@ -212,7 +217,6 @@ 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_fixed_from_double(sy));
pointer_send_frame(resource);
}
}
@ -231,7 +235,6 @@ uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time,
}
wl_pointer_send_button(resource, serial, time, button, state);
pointer_send_frame(resource);
}
return serial;
}
@ -267,6 +270,21 @@ void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time,
} else if (version >= WL_POINTER_AXIS_STOP_SINCE_VERSION) {
wl_pointer_send_axis_stop(resource, time, orientation);
}
}
}
void wlr_seat_pointer_send_frame(struct wlr_seat *wlr_seat) {
struct wlr_seat_client *client = wlr_seat->pointer_state.focused_client;
if (client == NULL) {
return;
}
struct wl_resource *resource;
wl_resource_for_each(resource, &client->pointers) {
if (wlr_seat_client_from_pointer_resource(resource) == NULL) {
continue;
}
pointer_send_frame(resource);
}
}
@ -336,6 +354,14 @@ void wlr_seat_pointer_notify_axis(struct wlr_seat *wlr_seat, uint32_t time,
source);
}
void wlr_seat_pointer_notify_frame(struct wlr_seat *wlr_seat) {
clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event);
struct wlr_seat_pointer_grab *grab = wlr_seat->pointer_state.grab;
if (grab->interface->frame) {
grab->interface->frame(grab);
}
}
bool wlr_seat_pointer_has_grab(struct wlr_seat *seat) {
return seat->pointer_state.grab->interface != &default_pointer_grab_impl;
}