diff --git a/include/rootston/cursor.h b/include/rootston/cursor.h index 0d6b60143..6bc1f765b 100644 --- a/include/rootston/cursor.h +++ b/include/rootston/cursor.h @@ -104,7 +104,7 @@ void roots_cursor_handle_focus_change(struct roots_cursor *cursor, void roots_cursor_handle_constraint_commit(struct roots_cursor *cursor); void roots_cursor_update_position(struct roots_cursor *cursor, - uint32_t time); + uint32_t time_msec, uint64_t time_nsec); void roots_cursor_update_focus(struct roots_cursor *cursor); diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h index 791f5a8b1..ee26405c7 100644 --- a/include/rootston/desktop.h +++ b/include/rootston/desktop.h @@ -7,15 +7,16 @@ #include #include #include -#include #include +#include #include #include +#include #include #include +#include #include #include -#include #include #include #include @@ -24,8 +25,8 @@ #include #include #include -#include #include +#include #include "rootston/config.h" #include "rootston/output.h" #include "rootston/view.h" @@ -65,6 +66,7 @@ struct roots_desktop { struct wlr_relative_pointer_manager_v1 *relative_pointer_manager; struct wlr_pointer_gestures_v1 *pointer_gestures; struct wlr_output_manager_v1 *output_manager_v1; + struct wlr_input_timestamps_manager_v1 *input_timestamps_manager; struct wl_listener new_output; struct wl_listener layout_change; diff --git a/rootston/cursor.c b/rootston/cursor.c index 6e09c06e0..d6bbf16c8 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -101,7 +101,7 @@ static void seat_view_deco_button(struct roots_seat_view *view, double sx, } static void roots_passthrough_cursor(struct roots_cursor *cursor, - uint32_t time) { + uint32_t time_msec, uint64_t time_nsec) { double sx, sy; struct roots_view *view = NULL; struct roots_seat *seat = cursor->seat; @@ -145,8 +145,11 @@ static void roots_passthrough_cursor(struct roots_cursor *cursor, cursor->wlr_surface = surface; if (surface) { + wlr_input_timestamps_manager_v1_send_pointer_timestamp( + cursor->seat->input->server->desktop->input_timestamps_manager, + cursor->seat->seat, time_msec / 1000, time_nsec % 1000000000); wlr_seat_pointer_notify_enter(seat->seat, surface, sx, sy); - wlr_seat_pointer_notify_motion(seat->seat, time, sx, sy); + wlr_seat_pointer_notify_motion(seat->seat, time_msec, sx, sy); } else { wlr_seat_pointer_clear_focus(seat->seat); } @@ -164,16 +167,16 @@ void roots_cursor_update_focus(struct roots_cursor *cursor) { struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); - roots_passthrough_cursor(cursor, timespec_to_msec(&now)); + roots_passthrough_cursor(cursor, timespec_to_msec(&now), now.tv_nsec); } void roots_cursor_update_position(struct roots_cursor *cursor, - uint32_t time) { + uint32_t time_msec, uint64_t time_nsec) { struct roots_seat *seat = cursor->seat; struct roots_view *view; switch (cursor->mode) { case ROOTS_CURSOR_PASSTHROUGH: - roots_passthrough_cursor(cursor, time); + roots_passthrough_cursor(cursor, time_msec, time_nsec); break; case ROOTS_CURSOR_MOVE: view = roots_seat_get_focus(seat); @@ -235,8 +238,9 @@ void roots_cursor_update_position(struct roots_cursor *cursor, } static void roots_cursor_press_button(struct roots_cursor *cursor, - struct wlr_input_device *device, uint32_t time, uint32_t button, - uint32_t state, double lx, double ly) { + struct wlr_input_device *device, uint32_t time_msec, + uint64_t time_nsec, uint32_t button, uint32_t state, + double lx, double ly) { struct roots_seat *seat = cursor->seat; struct roots_desktop *desktop = seat->input->server->desktop; @@ -300,7 +304,10 @@ static void roots_cursor_press_button(struct roots_cursor *cursor, } if (!is_touch) { - wlr_seat_pointer_notify_button(seat->seat, time, button, state); + wlr_input_timestamps_manager_v1_send_pointer_timestamp( + cursor->seat->input->server->desktop->input_timestamps_manager, + cursor->seat->seat, time_msec / 1000, time_nsec % 1000000000); + wlr_seat_pointer_notify_button(seat->seat, time_msec, button, state); } } @@ -314,8 +321,8 @@ void roots_cursor_handle_motion(struct roots_cursor *cursor, wlr_relative_pointer_manager_v1_send_relative_motion( cursor->seat->input->server->desktop->relative_pointer_manager, - cursor->seat->seat, (uint64_t)event->time_msec * 1000, dx, dy, - dx_unaccel, dy_unaccel); + cursor->seat->seat, event->time_nsec / 1000, + dx, dy, dx_unaccel, dy_unaccel); if (cursor->active_constraint) { struct roots_view *view = cursor->pointer_view->view; @@ -347,7 +354,7 @@ void roots_cursor_handle_motion(struct roots_cursor *cursor, } wlr_cursor_move(cursor->cursor, event->device, dx, dy); - roots_cursor_update_position(cursor, event->time_msec); + roots_cursor_update_position(cursor, event->time_msec, event->time_nsec); } void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor, @@ -373,17 +380,22 @@ void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor, } wlr_cursor_warp_closest(cursor->cursor, event->device, lx, ly); - roots_cursor_update_position(cursor, event->time_msec); + roots_cursor_update_position(cursor, event->time_msec, event->time_nsec); } void roots_cursor_handle_button(struct roots_cursor *cursor, struct wlr_event_pointer_button *event) { roots_cursor_press_button(cursor, event->device, event->time_msec, - event->button, event->state, cursor->cursor->x, cursor->cursor->y); + event->time_nsec, event->button, event->state, + cursor->cursor->x, cursor->cursor->y); } void roots_cursor_handle_axis(struct roots_cursor *cursor, struct wlr_event_pointer_axis *event) { + wlr_input_timestamps_manager_v1_send_pointer_timestamp( + cursor->seat->input->server->desktop->input_timestamps_manager, + cursor->seat->seat, event->time_msec / 1000, + event->time_nsec % 1000000000); wlr_seat_pointer_notify_axis(cursor->seat->seat, event->time_msec, event->orientation, event->delta, event->delta_discrete, event->source); } @@ -414,7 +426,7 @@ void roots_cursor_handle_touch_down(struct roots_cursor *cursor, cursor->seat->touch_x = lx; cursor->seat->touch_y = ly; roots_cursor_press_button(cursor, event->device, event->time_msec, - BTN_LEFT, 1, lx, ly); + event->time_nsec, BTN_LEFT, 1, lx, ly); } } @@ -428,7 +440,8 @@ void roots_cursor_handle_touch_up(struct roots_cursor *cursor, if (wlr_seat_touch_num_points(cursor->seat->seat) == 1) { roots_cursor_press_button(cursor, event->device, event->time_msec, - BTN_LEFT, 0, cursor->seat->touch_x, cursor->seat->touch_y); + event->time_nsec, BTN_LEFT, 0, cursor->seat->touch_x, + cursor->seat->touch_y); } wlr_seat_touch_notify_up(cursor->seat->seat, event->time_msec, @@ -497,14 +510,15 @@ void roots_cursor_handle_tool_axis(struct roots_cursor *cursor, } wlr_cursor_warp_closest(cursor->cursor, event->device, lx, ly); - roots_cursor_update_position(cursor, event->time_msec); + roots_cursor_update_position(cursor, event->time_msec, + event->time_msec * 1000000); } void roots_cursor_handle_tool_tip(struct roots_cursor *cursor, struct wlr_event_tablet_tool_tip *event) { roots_cursor_press_button(cursor, event->device, - event->time_msec, BTN_LEFT, event->state, cursor->cursor->x, - cursor->cursor->y); + event->time_msec, event->time_msec * 1000000, BTN_LEFT, event->state, + cursor->cursor->x, cursor->cursor->y); } void roots_cursor_handle_request_set_cursor(struct roots_cursor *cursor, diff --git a/rootston/desktop.c b/rootston/desktop.c index 3d9888e3a..1afab3b78 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -433,6 +433,8 @@ struct roots_desktop *desktop_create(struct roots_server *server, wlr_relative_pointer_manager_v1_create(server->wl_display); desktop->pointer_gestures = wlr_pointer_gestures_v1_create(server->wl_display); + desktop->input_timestamps_manager = + wlr_input_timestamps_manager_v1_create(server->wl_display); desktop->output_manager_v1 = wlr_output_manager_v1_create(server->wl_display); diff --git a/rootston/input.c b/rootston/input.c index 757f1b352..42c9cde33 100644 --- a/rootston/input.c +++ b/rootston/input.c @@ -141,6 +141,7 @@ void input_update_cursor_focus(struct roots_input *input) { 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), + now.tv_nsec); } } diff --git a/rootston/keyboard.c b/rootston/keyboard.c index 9d3fadf60..a34d374d5 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -5,8 +5,9 @@ #include #include #include -#include +#include #include +#include #include #include #include "rootston/bindings.h" @@ -236,6 +237,10 @@ void roots_keyboard_handle_key(struct roots_keyboard *keyboard, if (!handled) { wlr_seat_set_keyboard(keyboard->seat->seat, keyboard->device); + wlr_input_timestamps_manager_v1_send_keyboard_timestamp( + keyboard->seat->input->server->desktop->input_timestamps_manager, + keyboard->seat->seat, (event->time_msec / 1000.0), + event->time_nsec % 1000000000); wlr_seat_keyboard_notify_key(keyboard->seat->seat, event->time_msec, event->keycode, event->state); } diff --git a/rootston/layer_shell.c b/rootston/layer_shell.c index 1a5337557..36666a794 100644 --- a/rootston/layer_shell.c +++ b/rootston/layer_shell.c @@ -93,7 +93,7 @@ static void update_cursors(struct roots_layer_surface *roots_surface, struct timespec time; if (clock_gettime(CLOCK_MONOTONIC, &time) == 0) { roots_cursor_update_position(seat->cursor, - time.tv_sec * 1000 + time.tv_nsec / 1000000); + time.tv_sec * 1000 + time.tv_nsec / 1000000, time.tv_nsec); } else { wlr_log(WLR_ERROR, "Failed to get time, not updating" "position. Errno: %s\n", strerror(errno));