[PATCH weston 3/6] test: Add clock_settime()

Bryce Harrington bryce at osg.samsung.com
Fri Dec 19 12:35:17 PST 2014


On Fri, Dec 19, 2014 at 12:45:47PM -0600, Derek Foreman wrote:
> Add a way to set the presentation clock to an arbitrary value, but only
> when in test mode.
> 
> Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
> ---
>  protocol/wayland-test.xml |  4 ++++
>  src/compositor.c          | 13 +++++++++++++
>  src/compositor.h          |  4 ++++
>  tests/weston-test.c       | 13 +++++++++++++
>  4 files changed, 34 insertions(+)
> 
> diff --git a/protocol/wayland-test.xml b/protocol/wayland-test.xml
> index 7174907..7133555 100644
> --- a/protocol/wayland-test.xml
> +++ b/protocol/wayland-test.xml
> @@ -60,5 +60,9 @@
>      </event>
>      <!-- interface version 2 -->
>      <request name="enable_test_mode"/>
> +    <request name="clock_settime">
> +      <arg name="sec" type="string"/>
> +      <arg name="nsec" type="string"/>

      <arg name="sec" type="string" summary="whole part in seconds"/>
      <arg name="nsec" type="string" summary="fractional part in nano-seconds"/>

Also needs a <description> section.

> +    </request>
>    </interface>
>  </protocol>
> diff --git a/src/compositor.c b/src/compositor.c
> index 6109eb5..61ba041 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -4233,6 +4233,19 @@ weston_compositor_presentation_clock_gettime(
>  }
>  
>  WL_EXPORT int

doxygen comments needed (maybe?)

> +weston_compositor_presentation_clock_settime(
> +					 struct weston_compositor *compositor,
> +					 const struct timespec *ts)
> +{
> +	if (!compositor->test_mode) {
> +		weston_log("warning: attempt to control presentation clock outside of test mode\n");
> +		return -1;
> +	}
> +	compositor->test_time = *ts;
> +	return 0;
> +}
> +
> +WL_EXPORT int
>  weston_compositor_set_presentation_clock(struct weston_compositor *compositor,
>  					 clockid_t clk_id)
>  {
> diff --git a/src/compositor.h b/src/compositor.h
> index 924e354..17ce070 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -1281,6 +1281,10 @@ int
>  weston_compositor_presentation_clock_gettime(
>  					 struct weston_compositor *compositor,
>  					 struct timespec *ts);
> +int
> +weston_compositor_presentation_clock_settime(
> +					 struct weston_compositor *compositor,
> +					 const struct timespec *ts);
>  void
>  weston_compositor_shutdown(struct weston_compositor *ec);
>  void
> diff --git a/tests/weston-test.c b/tests/weston-test.c
> index 0a213b2..ba37cdf 100644
> --- a/tests/weston-test.c
> +++ b/tests/weston-test.c
> @@ -243,6 +243,18 @@ enable_test_mode(struct wl_client *client, struct wl_resource *resource)
>  	weston_compositor_test_mode_enable(test->compositor);
>  }
>  
> +static void
> +settime(struct wl_client *client, struct wl_resource *resource,
> +	const char *sec, const char *nsec)
> +{
> +	struct weston_test *test = wl_resource_get_user_data(resource);
> +	struct timespec ts;
> +
> +	ts.tv_sec = atoll(sec);
> +	ts.tv_nsec = atoll(nsec);
> +	weston_compositor_presentation_clock_settime(test->compositor, &ts);
> +}
> +
>  static const struct wl_test_interface test_implementation = {
>  	move_surface,
>  	move_pointer,
> @@ -251,6 +263,7 @@ static const struct wl_test_interface test_implementation = {
>  	send_key,
>  	get_n_buffers,
>  	enable_test_mode,
> +	settime,

Since we have get_*, perhaps settime should really be set_time ?

>  };
>  
>  static void
> -- 
> 2.1.3
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list