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

Egor Starkov egor.starkov at ge.com
Fri Sep 18 04:14:16 PDT 2015


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

Signed-off-by: Egor Starkov <egor.starkov at ge.com>
---
 src/compositor.c |  3 ++-
 src/compositor.h |  2 +-
 src/main.c       | 13 ++++++-------
 3 files changed, 9 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);
 
 	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..3814f20 100644
--- a/src/main.c
+++ b/src/main.c
@@ -727,7 +727,12 @@ 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, -1);
+	if (idle_time < 0)
+		idle_time = 300; /* default idle timeout, in seconds */
+
+	ec = weston_compositor_create(display, NULL, idle_time);
 	if (ec == NULL) {
 		weston_log("fatal: failed to create compositor\n");
 		goto out_signals;
@@ -745,12 +750,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;
 
-- 
1.8.3.1



More information about the wayland-devel mailing list