[weston,v1,14/17] weston-test: use real time instead of magic number

Submitted by Marek Chalupa on Dec. 5, 2014, 1:36 p.m.

Details

Message ID 1417786610-2440-15-git-send-email-mchqwerty@gmail.com
State Changes Requested
Headers show

Not browsing as part of any series.

Commit Message

Marek Chalupa Dec. 5, 2014, 1:36 p.m.
Pass time from weston_compositor_get_time() into notify_{motion, button}
etc. Until now the time was hardcoded to 100 and with toytoolkit clients
it causes problems, because toytoolkit checks the time.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
---
 tests/weston-test.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/tests/weston-test.c b/tests/weston-test.c
index d1539e7..1014cdb 100644
--- a/tests/weston-test.c
+++ b/tests/weston-test.c
@@ -131,7 +131,7 @@  move_pointer(struct wl_client *client, struct wl_resource *resource,
 	struct weston_seat *seat = get_seat(test);
 	struct weston_pointer *pointer = seat->pointer;
 
-	notify_motion(seat, 100,
+	notify_motion(seat, weston_compositor_get_time(),
 		      wl_fixed_from_int(x) - pointer->x,
 		      wl_fixed_from_int(y) - pointer->y);
 
@@ -145,7 +145,7 @@  send_button(struct wl_client *client, struct wl_resource *resource,
 	struct weston_test *test = wl_resource_get_user_data(resource);
 	struct weston_seat *seat = get_seat(test);
 
-	notify_button(seat, 100, button, state);
+	notify_button(seat, weston_compositor_get_time(), button, state);
 }
 
 static void
@@ -177,7 +177,8 @@  send_key(struct wl_client *client, struct wl_resource *resource,
 	struct weston_test *test = wl_resource_get_user_data(resource);
 	struct weston_seat *seat = get_seat(test);
 
-	notify_key(seat, 100, key, state, STATE_UPDATE_AUTOMATIC);
+	notify_key(seat, weston_compositor_get_time(),
+		   key, state, STATE_UPDATE_AUTOMATIC);
 }
 
 #ifdef ENABLE_EGL

Comments

On Fri,  5 Dec 2014 14:36:47 +0100
Marek Chalupa <mchqwerty@gmail.com> wrote:

> Pass time from weston_compositor_get_time() into notify_{motion, button}
> etc. Until now the time was hardcoded to 100 and with toytoolkit clients
> it causes problems, because toytoolkit checks the time.
> 
> Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
> ---
>  tests/weston-test.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/weston-test.c b/tests/weston-test.c
> index d1539e7..1014cdb 100644
> --- a/tests/weston-test.c
> +++ b/tests/weston-test.c
> @@ -131,7 +131,7 @@ move_pointer(struct wl_client *client, struct wl_resource *resource,
>  	struct weston_seat *seat = get_seat(test);
>  	struct weston_pointer *pointer = seat->pointer;
>  
> -	notify_motion(seat, 100,
> +	notify_motion(seat, weston_compositor_get_time(),
>  		      wl_fixed_from_int(x) - pointer->x,
>  		      wl_fixed_from_int(y) - pointer->y);
>  
> @@ -145,7 +145,7 @@ send_button(struct wl_client *client, struct wl_resource *resource,
>  	struct weston_test *test = wl_resource_get_user_data(resource);
>  	struct weston_seat *seat = get_seat(test);
>  
> -	notify_button(seat, 100, button, state);
> +	notify_button(seat, weston_compositor_get_time(), button, state);
>  }
>  
>  static void
> @@ -177,7 +177,8 @@ send_key(struct wl_client *client, struct wl_resource *resource,
>  	struct weston_test *test = wl_resource_get_user_data(resource);
>  	struct weston_seat *seat = get_seat(test);
>  
> -	notify_key(seat, 100, key, state, STATE_UPDATE_AUTOMATIC);
> +	notify_key(seat, weston_compositor_get_time(),
> +		   key, state, STATE_UPDATE_AUTOMATIC);
>  }
>  
>  #ifdef ENABLE_EGL

The fundamental problem with this is that you might not be reading the
right clock. Therefore the input timestamps may jump unexpectedly.

What the right clock is depends on where the backend gets its input
events.

Ideally, during tests, the normal input sources would not be used at
all. Currently when running with a real backend like DRM or x11, the
normal input paths still work, which can cause tests to fail if a user
touches input devices during a test.

OTOH, I wouldn't want to disable real input devices completely on the
DRM backend during tests, because if a test gets stuck, you would not
be able to VT-switch away.

So, hardcoding 100 as the timestamp is obviously wrong, but I reject
this patch, because weston_compositor_get_time() is also wrong but it's
no longer *obviously wrong*.

I'm afraid fixing this needs more work, and I'm not quite sure how it
should be done. Maybe the wl_test extension should override all
backend input paths, except perhaps a fail-safe to kill the compositor?

(The above explains why adding a fake input device is so problematic,
and in this case we do not even need to make a fake device work
together with real devices.)

I think I might allow a patch, which essentially does what this patch
does, but wraps it in a function FIXME_fake_input_timestamp() or
something, so it stays obviously suspicious until a real solution is
made. With a big comment explaining why it's wrong.


Thanks,
pq