rootston: add support for wlr_input_timestamps_v1

This commit is contained in:
random human 2019-06-14 20:46:15 +00:00
parent ab3a760874
commit dcb38e7f1c
No known key found for this signature in database
GPG key ID: 73E5A60444CC77A3
7 changed files with 49 additions and 25 deletions

View file

@ -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);

View file

@ -7,15 +7,16 @@
#include <wlr/types/wlr_foreign_toplevel_management_v1.h>
#include <wlr/types/wlr_gamma_control_v1.h>
#include <wlr/types/wlr_gtk_primary_selection.h>
#include <wlr/types/wlr_idle_inhibit_v1.h>
#include <wlr/types/wlr_idle.h>
#include <wlr/types/wlr_idle_inhibit_v1.h>
#include <wlr/types/wlr_input_inhibitor.h>
#include <wlr/types/wlr_input_method_v2.h>
#include <wlr/types/wlr_input_timestamps_v1.h>
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_list.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output_management_v1.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_pointer_gestures_v1.h>
#include <wlr/types/wlr_presentation_time.h>
#include <wlr/types/wlr_relative_pointer_v1.h>
@ -24,8 +25,8 @@
#include <wlr/types/wlr_virtual_keyboard_v1.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/types/wlr_xdg_decoration_v1.h>
#include <wlr/types/wlr_xdg_shell_v6.h>
#include <wlr/types/wlr_xdg_shell.h>
#include <wlr/types/wlr_xdg_shell_v6.h>
#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;

View file

@ -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,

View file

@ -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);

View file

@ -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);
}
}

View file

@ -5,8 +5,9 @@
#include <wayland-server.h>
#include <wlr/backend/session.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_pointer_constraints_v1.h>
#include <wlr/types/wlr_input_timestamps_v1.h>
#include <wlr/types/wlr_pointer.h>
#include <wlr/types/wlr_pointer_constraints_v1.h>
#include <wlr/util/log.h>
#include <xkbcommon/xkbcommon.h>
#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);
}

View file

@ -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));