diff --git a/compositor/compositor.c b/compositor/compositor.c index 7b1adec9..8fadf76d 100644 --- a/compositor/compositor.c +++ b/compositor/compositor.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include "wayland-server-protocol.h" @@ -568,16 +567,6 @@ shell_resize(struct wl_client *client, struct wl_shell *shell, wlsc_input_device_set_pointer_image(wd, pointer); } -static uint32_t -get_time(void) -{ - struct timeval tv; - - gettimeofday(&tv, NULL); - - return tv.tv_sec * 1000 + tv.tv_usec / 1000; -} - struct wlsc_drag { struct wl_drag drag; struct wl_listener listener; @@ -607,7 +596,8 @@ drag_handle_surface_destroy(struct wl_listener *listener, { struct wlsc_drag *drag = container_of(listener, struct wlsc_drag, listener); - uint32_t time = get_time(); + uint32_t time = + wl_display_get_time(wl_client_get_display(surface->client)); if (drag->drag.pointer_focus == surface) wl_drag_set_pointer_focus(&drag->drag, NULL, time, 0, 0, 0, 0); @@ -1139,11 +1129,13 @@ drag_cancel(struct wl_client *client, struct wl_drag *drag) { struct wlsc_input_device *device = (struct wlsc_input_device *) drag->input_device; + uint32_t time; if (drag->source == NULL || drag->source->client != client) return; - wlsc_input_device_end_grab(device, get_time()); + time = wl_display_get_time(wl_client_get_display(client)); + wlsc_input_device_end_grab(device, time); device->drag = NULL; } @@ -1157,11 +1149,12 @@ static void lose_pointer_focus(struct wl_listener *listener, struct wl_surface *surface) { - uint32_t time = get_time(); struct wlsc_input_device *device = container_of(listener, struct wlsc_input_device, input_device.pointer_focus_listener); + uint32_t time; + time = wl_display_get_time(wl_client_get_display(surface->client)); wl_input_device_set_pointer_focus(&device->input_device, NULL, time, 0, 0, 0, 0); wlsc_input_device_end_grab(device, time); @@ -1171,11 +1164,12 @@ static void lose_keyboard_focus(struct wl_listener *listener, struct wl_surface *surface) { - uint32_t time = get_time(); struct wlsc_input_device *device = container_of(listener, struct wlsc_input_device, input_device.keyboard_focus_listener); + uint32_t time; + time = wl_display_get_time(wl_client_get_display(surface->client)); wl_input_device_set_keyboard_focus(&device->input_device, NULL, time); } diff --git a/wayland/wayland-server.c b/wayland/wayland-server.c index 487bddc5..7a0268f1 100644 --- a/wayland/wayland-server.c +++ b/wayland/wayland-server.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include "wayland-server.h" @@ -484,6 +485,16 @@ wl_display_destroy(struct wl_display *display) free(display); } +WL_EXPORT uint32_t +wl_display_get_time(struct wl_display *display) +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + + return tv.tv_sec * 1000 + tv.tv_usec / 1000; +} + WL_EXPORT void wl_display_add_object(struct wl_display *display, struct wl_object *object) { diff --git a/wayland/wayland-server.h b/wayland/wayland-server.h index 15a02a4f..6f4b2cee 100644 --- a/wayland/wayland-server.h +++ b/wayland/wayland-server.h @@ -177,6 +177,9 @@ wl_display_set_compositor(struct wl_display *display, struct wl_compositor *compositor, const struct wl_compositor_interface *implementation); +uint32_t +wl_display_get_time(struct wl_display *display); + void wl_display_post_frame(struct wl_display *display, uint32_t msecs);