[PATCH weston v2] compositor: fix initializing idle timeout at startup

Pekka Paalanen ppaalanen at gmail.com
Tue Sep 22 05:47:20 PDT 2015


On Tue, 22 Sep 2015 13:50:00 +0300
Egor Starkov <egor.starkov at ge.com> wrote:

> Read and store idle-time setting before calling weston_compositor_create
> that makes initial setting of idle timeout.
> 
> Fixes https://bugs.freedesktop.org/show_bug.cgi?id=92030

Hi Egor,

strange, I cannot reproduce this problem.

> Signed-off-by: Egor Starkov <egor.starkov at ge.com>
> ---
>  src/compositor.c |  3 ++-
>  src/compositor.h |  2 +-
>  src/main.c       | 11 ++++-------
>  3 files changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/src/compositor.c b/src/compositor.c
> index cbef4dc..d65afab 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -4459,7 +4459,7 @@ timeline_key_binding_handler(struct weston_keyboard *keyboard, uint32_t time,
>   * \return The compositor instance on success or NULL on failure.
>   */
>  WL_EXPORT struct weston_compositor *
> -weston_compositor_create(struct wl_display *display, void *user_data)
> +weston_compositor_create(struct wl_display *display, void *user_data, int32_t idle_time)
>  {
>  	struct weston_compositor *ec;
>  	struct wl_event_loop *loop;
> @@ -4527,6 +4527,7 @@ weston_compositor_create(struct wl_display *display, void *user_data)
>  
>  	loop = wl_display_get_event_loop(ec->wl_display);
>  	ec->idle_source = wl_event_loop_add_timer(loop, idle_handler, ec);
> +	ec->idle_time = idle_time;
>  	wl_event_source_timer_update(ec->idle_source, ec->idle_time * 1000);

This was indeed using idle_time before it was properly set...

>  
>  	ec->input_loop = wl_event_loop_create();
> diff --git a/src/compositor.h b/src/compositor.h
> index c4c81f0..cdcfd39 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -1353,7 +1353,7 @@ weston_compositor_get_time(void);
>  void
>  weston_compositor_destroy(struct weston_compositor *ec);
>  struct weston_compositor *
> -weston_compositor_create(struct wl_display *display, void *user_data);
> +weston_compositor_create(struct wl_display *display, void *user_data, int32_t idle_time);
>  void
>  weston_compositor_exit(struct weston_compositor *ec);
>  void *
> diff --git a/src/main.c b/src/main.c
> index a98570e..c9d35b1 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -727,7 +727,10 @@ int main(int argc, char *argv[])
>  	if (!backend_init)
>  		goto out_signals;
>  
> -	ec = weston_compositor_create(display, NULL);
> +	if (idle_time < 0)
> +		weston_config_section_get_int(section, "idle-time", &idle_time, 300);
> +
> +	ec = weston_compositor_create(display, NULL, idle_time);
>  	if (ec == NULL) {
>  		weston_log("fatal: failed to create compositor\n");
>  		goto out_signals;
> @@ -745,12 +748,6 @@ int main(int argc, char *argv[])
>  	catch_signals();
>  	segv_compositor = ec;
>  
> -	if (idle_time < 0)
> -		weston_config_section_get_int(section, "idle-time", &idle_time, -1);
> -	if (idle_time < 0)
> -		idle_time = 300; /* default idle timeout, in seconds */
> -
> -	ec->idle_time = idle_time;
>  	ec->default_pointer_grab = NULL;
>  	ec->exit = handle_exit;
>  

..however, weston_compositor_wake(), which is called unconditionally
just before wl_display_run() in main(), updates the idle timer always.
And at that point idle_time is properly set.

That makes me confused as how it could not have worked.

On the other hand, this reveals a different minor bug.
weston_compositor_create() is using idle_time before it has the proper
value, when it doesn't need to update the timer at all. IMO we should
be able to just remove the timer update there.


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20150922/b83241c0/attachment.sig>


More information about the wayland-devel mailing list