swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit bafc060909606fd7bed017c15c38bc5690321b4c
parent 09ae3a9f1527d2c4cc14f5414bf213661855d421
Author: Michael Forney <mforney@mforney.org>
Date:   Wed, 22 Jan 2014 03:23:46 -0800

seat: Remove udev dependency

Diffstat:
MREADME.md | 5-----
Mlibswc/local.mk | 1-
Mlibswc/seat.c | 66+++++++++++++++++++++++++++++++++---------------------------------
Mlibswc/swc.c | 45+++++++++++++++++----------------------------
4 files changed, 50 insertions(+), 67 deletions(-)

diff --git a/README.md b/README.md @@ -17,13 +17,8 @@ Dependencies * libxkbcommon * pixman * [wld](http://github.com/michaelforney/wld) -* libudev * linux\[>=3.12\] (for EVIOCREVOKE) -libudev is currently required for input hotplugging support. I'd like to get rid -of this dependency, but it seems that libudev is currently the only way to get -this functionality. - For XWayland support, the following are also required: * libxcb * xcb-util-wm diff --git a/libswc/local.mk b/libswc/local.mk @@ -22,7 +22,6 @@ endif $(dir)_PACKAGES = \ libdrm \ libevdev \ - libudev \ pixman-1 \ wayland-server \ wld \ diff --git a/libswc/seat.c b/libswc/seat.c @@ -1,6 +1,6 @@ /* swc: libswc/seat.c * - * Copyright (c) 2013 Michael Forney + * Copyright (c) 2013, 2014 Michael Forney * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,6 +31,7 @@ #include "pointer.h" #include "util.h" +#include <dirent.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -192,25 +193,11 @@ static void bind_seat(struct wl_client * client, void * data, uint32_t version, wl_seat_send_capabilities(resource, seat.capabilities); } -static void add_device(struct udev_device * udev_device) +static void add_device(const char * path) { - const char * device_seat; - const char * device_path; struct swc_evdev_device * device; - device_seat = udev_device_get_property_value(udev_device, "ID_SEAT"); - - /* If the ID_SEAT property is not set, the device belongs to seat0. */ - if (!device_seat) - device_seat = "seat0"; - - if (strcmp(device_seat, seat.name) != 0) - return; - - device_path = udev_device_get_devnode(udev_device); - device = swc_evdev_device_new(device_path, &evdev_handler); - - if (!device) + if (!(device = swc_evdev_device_new(path, &evdev_handler))) { ERROR("Could not create evdev device\n"); return; @@ -228,28 +215,38 @@ static void add_device(struct udev_device * udev_device) wl_list_insert(&seat.devices, &device->link); } -static void add_devices() +static int select_device(const struct dirent * entry) +{ + unsigned num; + + return sscanf(entry->d_name, "event%u", &num) == 1; +} + +static bool add_devices() { - struct udev_enumerate * enumerate; - struct udev_list_entry * entry; - const char * path; - struct udev_device * device; + struct dirent ** devices; + int num_devices; + char path[64]; + unsigned index; - enumerate = udev_enumerate_new(swc.udev); - udev_enumerate_add_match_subsystem(enumerate, "input"); - udev_enumerate_add_match_sysname(enumerate, "event[0-9]*"); + num_devices = scandir("/dev/input", &devices, &select_device, &alphasort); - udev_enumerate_scan_devices(enumerate); + if (num_devices == -1) + { + ERROR("Failed to scan /dev/input for event devices\n"); + return false; + } - udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(enumerate)) + for (index = 0; index < num_devices; ++index) { - path = udev_list_entry_get_name(entry); - device = udev_device_new_from_syspath(swc.udev, path); - add_device(device); - udev_device_unref(device); + snprintf(path, sizeof path, "/dev/input/%s", devices[index]->d_name); + free(devices[index]); + add_device(path); } - udev_enumerate_unref(enumerate); + free(devices); + + return true; } bool swc_seat_initialize(const char * seat_name) @@ -293,10 +290,13 @@ bool swc_seat_initialize(const char * seat_name) goto error4; } - add_devices(); + if (!add_devices()) + goto error5; return true; + error5: + swc_pointer_finalize(&seat.pointer); error4: swc_keyboard_finalize(&seat.keyboard); error3: diff --git a/libswc/swc.c b/libswc/swc.c @@ -40,8 +40,6 @@ # include "xserver.h" #endif -#include <libudev.h> - extern struct swc_launch swc_launch; extern const struct swc_seat swc_seat; extern const struct swc_bindings swc_bindings; @@ -101,65 +99,59 @@ bool swc_initialize(struct wl_display * display, goto error0; } - if (!(swc.udev = udev_new())) - { - ERROR("Could not initialize udev\n"); - goto error1; - } - if (!swc_drm_initialize()) { ERROR("Could not initialize DRM\n"); - goto error2; + goto error1; } if (!swc_shm_initialize()) { ERROR("Could not initialize SHM\n"); - goto error3; + goto error2; } if (!swc_bindings_initialize()) { ERROR("Could not initialize bindings\n"); - goto error4; + goto error3; } if (!swc_screens_initialize()) { ERROR("Could not initialize screens\n"); - goto error5; + goto error4; } if (!swc_compositor_initialize()) { ERROR("Could not initialize compositor\n"); - goto error6; + goto error5; } if (!swc_data_device_manager_initialize()) { ERROR("Could not initialize data device manager\n"); - goto error7; + goto error6; } if (!swc_seat_initialize(default_seat)) { ERROR("Could not initialize seat\n"); - goto error8; + goto error7; } if (!swc_shell_initialize()) { ERROR("Could not initialize shell\n"); - goto error9; + goto error8; } #ifdef ENABLE_XWAYLAND if (!swc_xserver_initialize()) { ERROR("Could not initialize xwayland\n"); - goto error10; + goto error9; } #endif @@ -167,24 +159,22 @@ bool swc_initialize(struct wl_display * display, return true; - error10: - swc_shell_finalize(); error9: - swc_seat_finalize(); + swc_shell_finalize(); error8: - swc_data_device_manager_finalize(); + swc_seat_finalize(); error7: - swc_compositor_finalize(); + swc_data_device_manager_finalize(); error6: - swc_screens_finalize(); + swc_compositor_finalize(); error5: - swc_bindings_finalize(); + swc_screens_finalize(); error4: - swc_shm_finalize(); + swc_bindings_finalize(); error3: - swc_drm_finalize(); + swc_shm_finalize(); error2: - udev_unref(swc.udev); + swc_drm_finalize(); error1: swc_launch_finalize(); error0: @@ -205,7 +195,6 @@ void swc_finalize() swc_bindings_finalize(); swc_shm_finalize(); swc_drm_finalize(); - udev_unref(swc.udev); swc_launch_finalize(); }