[PATCH weston 05/12] libweston: Use struct timespec for motion events

Alexandros Frantzis alexandros.frantzis at collabora.com
Fri Nov 24 13:54:16 UTC 2017


On Fri, Nov 24, 2017 at 03:29:11PM +0200, Pekka Paalanen wrote:
> On Thu, 16 Nov 2017 18:20:54 +0200
> Alexandros Frantzis <alexandros.frantzis at collabora.com> wrote:
> 
> > Change code related to motion events to use struct timespec to represent
> > time.
> > 
> > This commit is part of a larger effort to transition the Weston codebase
> > to struct timespec.
> > 
> > Signed-off-by: Alexandros Frantzis <alexandros.frantzis at collabora.com>
> > ---
> >  compositor/screen-share.c      |  6 +++++-
> >  desktop-shell/exposay.c        |  3 ++-
> >  desktop-shell/shell.c          | 12 ++++++++----
> >  ivi-shell/hmi-controller.c     |  3 ++-
> >  libweston-desktop/seat.c       |  2 +-
> >  libweston/compositor-rdp.c     | 10 +++++++---
> >  libweston/compositor-wayland.c |  5 ++++-
> >  libweston/compositor-x11.c     |  6 ++++--
> >  libweston/compositor.h         | 12 +++++++-----
> >  libweston/data-device.c        |  8 ++++++--
> >  libweston/input.c              | 30 ++++++++++++++++++------------
> >  libweston/libinput-device.c    | 19 ++++++++++---------
> >  tests/weston-test.c            |  6 +++++-
> >  13 files changed, 79 insertions(+), 43 deletions(-)
> > 
> 
> 
> > diff --git a/libweston/libinput-device.c b/libweston/libinput-device.c
> > index b1d269db..b1087ba5 100644
> > --- a/libweston/libinput-device.c
> > +++ b/libweston/libinput-device.c
> > @@ -39,6 +39,7 @@
> >  #include "compositor.h"
> >  #include "libinput-device.h"
> >  #include "shared/helpers.h"
> > +#include "shared/timespec-util.h"
> >  
> >  void
> >  evdev_led_update(struct evdev_device *device, enum weston_led weston_leds)
> > @@ -86,26 +87,25 @@ handle_pointer_motion(struct libinput_device *libinput_device,
> >  	struct evdev_device *device =
> >  		libinput_device_get_user_data(libinput_device);
> >  	struct weston_pointer_motion_event event = { 0 };
> > -	uint64_t time_usec =
> > -		libinput_event_pointer_get_time_usec(pointer_event);
> > +	struct timespec time;
> >  	double dx_unaccel, dy_unaccel;
> >  
> > +	timespec_from_usec(&time,
> > +			   libinput_event_pointer_get_time_usec(pointer_event));
> >  	dx_unaccel = libinput_event_pointer_get_dx_unaccelerated(pointer_event);
> >  	dy_unaccel = libinput_event_pointer_get_dy_unaccelerated(pointer_event);
> >  
> >  	event = (struct weston_pointer_motion_event) {
> >  		.mask = WESTON_POINTER_MOTION_REL |
> >  			WESTON_POINTER_MOTION_REL_UNACCEL,
> > -		.time_usec = time_usec,
> > +		.time = time,
> >  		.dx = libinput_event_pointer_get_dx(pointer_event),
> >  		.dy = libinput_event_pointer_get_dy(pointer_event),
> >  		.dx_unaccel = dx_unaccel,
> >  		.dy_unaccel = dy_unaccel,
> >  	};
> >  
> > -	notify_motion(device->seat,
> > -		      libinput_event_pointer_get_time(pointer_event),
> > -		      &event);
> > +	notify_motion(device->seat, &time, &event);
> >  
> >  	return true;
> >  }
> > @@ -118,14 +118,15 @@ handle_pointer_motion_absolute(
> >  	struct evdev_device *device =
> >  		libinput_device_get_user_data(libinput_device);
> >  	struct weston_output *output = device->output;
> > -	uint32_t time;
> > +	struct timespec time;
> >  	double x, y;
> >  	uint32_t width, height;
> >  
> >  	if (!output)
> >  		return false;
> >  
> > -	time = libinput_event_pointer_get_time(pointer_event);
> > +	timespec_from_usec(&time,
> > +			   libinput_event_pointer_get_time(pointer_event));
> 
> Hi,
> 
> I think the time here was msec, not usec. Libinput documentation does
> not say what the unit for libinput_event_pointer_get_time() is, but
> since there also exists libinput_event_pointer_get_time_usec(), I
> believe the former returns milliseconds.
> 
> >  	width = device->output->current_mode->width;
> >  	height = device->output->current_mode->height;
> >  
> > @@ -135,7 +136,7 @@ handle_pointer_motion_absolute(
> >  							      height);
> >  
> >  	weston_output_transform_coordinate(device->output, x, y, &x, &y);
> > -	notify_motion_absolute(device->seat, time, x, y);
> > +	notify_motion_absolute(device->seat, &time, x, y);
> >  
> >  	return true;
> >  }
> 
> That was the only problem I could see in this patch, everything else
> looks good.
> 
> 
> Thanks,
> pq

Hi Pekka,

yes you are right, this should be changed to use
libinput_event_pointer_get_time_usec() (like all the other events)).

I will fix this in v2.

Thanks,
Alexandros


More information about the wayland-devel mailing list