diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-09-22 11:11:11 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2017-09-22 11:11:53 -0400 |
commit | e5e6dab7fdbbcc5ce62a40a14b138b4e59a148d9 (patch) | |
tree | f2951af43b09c99a39ef468dfb0cafa5ce3ff26d | |
parent | 087894ae99a680d9228d03bae66becc6112682a1 (diff) |
Fix use of serial on motion_request
-rw-r--r-- | examples/compositor.c | 14 | ||||
-rw-r--r-- | include/wlr/types/wlr_seat.h | 4 | ||||
-rw-r--r-- | types/wlr_seat.c | 5 |
3 files changed, 12 insertions, 11 deletions
diff --git a/examples/compositor.c b/examples/compositor.c index 56974486..721ae6bf 100644 --- a/examples/compositor.c +++ b/examples/compositor.c @@ -417,8 +417,7 @@ static struct wlr_xdg_surface_v6 *example_xdg_surface_at( return NULL; } -static void update_pointer_position(struct sample_state *sample, - uint32_t serial) { +static void update_pointer_position(struct sample_state *sample, uint32_t time) { if (sample->motion_context.surface) { struct example_xdg_surface_v6 *surface; surface = sample->motion_context.surface; @@ -438,7 +437,7 @@ static void update_pointer_position(struct sample_state *sample, // TODO z-order wlr_seat_pointer_enter(sample->wl_seat, surface->surface, sx, sy); - wlr_seat_pointer_send_motion(sample->wl_seat, serial, sx, sy); + wlr_seat_pointer_send_motion(sample->wl_seat, time, sx, sy); } else { wlr_seat_pointer_clear_focus(sample->wl_seat); } @@ -483,6 +482,9 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) { struct wlr_xdg_surface_v6 *surface = example_xdg_surface_at(sample, sample->cursor->x, sample->cursor->y); + uint32_t serial = wlr_seat_pointer_send_button(sample->wl_seat, + (uint32_t)event->time_usec, event->button, event->state); + int i; switch (event->state) { case WLR_BUTTON_RELEASED: @@ -492,12 +494,13 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) { break; case WLR_BUTTON_PRESSED: i = sample->input_cache_idx; - sample->input_cache[i].serial = (uint32_t)event->time_usec; + sample->input_cache[i].serial = serial; sample->input_cache[i].cursor = sample->cursor; sample->input_cache[i].device = event->device; sample->input_cache_idx = (i + 1) % (sizeof(sample->input_cache) / sizeof(sample->input_cache[0])); example_set_focused_surface(sample, surface); + wlr_log(L_DEBUG, "Stored event %d at %d", serial, i); if (sample->mod_down && event->button == BTN_LEFT) { struct example_xdg_surface_v6 *esurface = surface->data; sample->motion_context.surface = esurface; @@ -507,9 +510,6 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) { } break; } - - wlr_seat_pointer_send_button(sample->wl_seat, (uint32_t)event->time_usec, - event->button, event->state); } static void handle_tool_axis(struct wl_listener *listener, void *data) { diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index f992b2f2..aa17d650 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -104,9 +104,9 @@ void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time, /** * Send a button event to the surface with pointer focus. Coordinates for the - * button event are surface-local. + * button event are surface-local. Returns the serial. */ -void 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, uint32_t button, uint32_t state); void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time, diff --git a/types/wlr_seat.c b/types/wlr_seat.c index 54b55ba9..cbf1abc7 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -341,16 +341,17 @@ void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time, wl_pointer_send_frame(wlr_seat->pointer_state.focused_handle->pointer); } -void 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, uint32_t button, uint32_t state) { if (!wlr_seat_pointer_has_focus_resource(wlr_seat)) { - return; + return 0; } uint32_t serial = wl_display_next_serial(wlr_seat->display); wl_pointer_send_button(wlr_seat->pointer_state.focused_handle->pointer, serial, time, button, state); wl_pointer_send_frame(wlr_seat->pointer_state.focused_handle->pointer); + return serial; } void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time, |