diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2015-11-13 09:39:29 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2015-11-18 07:00:29 +1000 |
commit | a72e96538af2c4a94ead48f96e8e59a2a4980a64 (patch) | |
tree | b0d9f4c2b7889d5a339e44b9d3f9528be7deabc3 | |
parent | b1a9bea6079550fa8be4fa0b2e18ea810b0ea68c (diff) |
Add a helper function for the driver context initialization
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | src/xf86libinput.c | 27 |
1 files 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) { |