[PATCH v2 xf86-input-libinput 3/4] Add a helper function for the driver context initialization

Peter Hutterer peter.hutterer at who-t.net
Tue Nov 17 00:36:16 PST 2015


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
New patch in v2

 src/xf86libinput.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index b1b1943..bc6e677 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -1505,6 +1505,21 @@ xf86libinput_get_type_name(struct libinput_device *device,
 	return type_name;
 }
 
+static void
+xf86libinput_init_driver_context(void)
+{
+	if (!driver_context.libinput) {
+		driver_context.libinput = libinput_path_create_context(&interface, &driver_context);
+		libinput_log_set_handler(driver_context.libinput,
+					 xf86libinput_log_handler);
+		/* we want all msgs, let the server filter */
+		libinput_log_set_priority(driver_context.libinput,
+					  LIBINPUT_LOG_PRIORITY_DEBUG);
+	} else {
+		libinput_ref(driver_context.libinput);
+	}
+}
+
 static int
 xf86libinput_pre_init(InputDriverPtr drv,
 		      InputInfoPtr pInfo,
@@ -1540,17 +1555,7 @@ xf86libinput_pre_init(InputDriverPtr drv,
 	if (!path)
 		goto fail;
 
-	if (!driver_context.libinput) {
-		driver_context.libinput = libinput_path_create_context(&interface, &driver_context);
-		libinput_log_set_handler(driver_context.libinput,
-					 xf86libinput_log_handler);
-		/* we want all msgs, let the server filter */
-		libinput_log_set_priority(driver_context.libinput,
-					  LIBINPUT_LOG_PRIORITY_DEBUG);
-	} else {
-		libinput_ref(driver_context.libinput);
-	}
-
+	xf86libinput_init_driver_context();
 	libinput = driver_context.libinput;
 
 	if (libinput == NULL) {
-- 
2.5.0



More information about the xorg-devel mailing list