[PATCH weston 2/2] compositor-drm: Only add input devices after a frame is displayed

Ander Conselvan de Oliveira ander.conselvan.de.oliveira at intel.com
Tue Feb 12 07:52:53 PST 2013


Input device initialization takes several microseconds to complete. Two
things causes this: compiling the XKB keymap and reading the properties
database from the udev daemon. The user can't really interact with
anything on the screen until something is displayed, so this can be
delayed.

On my system, this patch saves ~50ms from launching Weston to have the
first frame displayed.
---
 src/compositor-drm.c |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index f1f7343..234b56c 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -189,6 +189,7 @@ struct drm_seat {
 	struct udev_monitor *udev_monitor;
 	struct wl_event_source *udev_monitor_source;
 	char *seat_id;
+	struct wl_listener first_frame_listener;
 };
 
 static void
@@ -2137,6 +2138,17 @@ drm_led_update(struct weston_seat *seat_base, enum weston_led leds)
 }
 
 static void
+drm_seat_delayed_init(struct wl_listener *listener, void *data)
+{
+	struct drm_seat *seat =
+		container_of(listener, struct drm_seat,
+			     first_frame_listener);
+	struct drm_compositor *c = data;
+
+	evdev_add_devices(c->udev, &seat->base);
+}
+
+static void
 evdev_input_create(struct weston_compositor *c, struct udev *udev,
 		   const char *seat_id)
 {
@@ -2158,7 +2170,8 @@ evdev_input_create(struct weston_compositor *c, struct udev *udev,
 		return;
 	}
 
-	evdev_add_devices(udev, &seat->base);
+	seat->first_frame_listener.notify = drm_seat_delayed_init;
+	wl_signal_add(&c->first_frame_signal, &seat->first_frame_listener);
 }
 
 static void
-- 
1.7.10.4



More information about the wayland-devel mailing list