udev-seat: Rename udev_seat to udev_input

This is a pure rename of the structure, functions and local variables in
preparation of the separation of the seat from the other udev input
handling.
dev
Rob Bradford 12 years ago committed by Kristian Høgsberg
parent 643641dfb7
commit d27b99d950
  1. 22
      src/compositor-drm.c
  2. 18
      src/compositor-fbdev.c
  3. 114
      src/udev-seat.c
  4. 10
      src/udev-seat.h

@ -2222,10 +2222,10 @@ static void
drm_destroy(struct weston_compositor *ec) drm_destroy(struct weston_compositor *ec)
{ {
struct drm_compositor *d = (struct drm_compositor *) ec; struct drm_compositor *d = (struct drm_compositor *) ec;
struct udev_seat *seat, *next; struct udev_input *input, *next;
wl_list_for_each_safe(seat, next, &ec->seat_list, base.link) wl_list_for_each_safe(input, next, &ec->seat_list, base.link)
udev_seat_destroy(seat); udev_input_destroy(input);
wl_event_source_remove(d->udev_drm_source); wl_event_source_remove(d->udev_drm_source);
wl_event_source_remove(d->drm_source); wl_event_source_remove(d->drm_source);
@ -2282,7 +2282,7 @@ static void
vt_func(struct weston_compositor *compositor, int event) vt_func(struct weston_compositor *compositor, int event)
{ {
struct drm_compositor *ec = (struct drm_compositor *) compositor; struct drm_compositor *ec = (struct drm_compositor *) compositor;
struct udev_seat *seat; struct udev_input *input;
struct drm_sprite *sprite; struct drm_sprite *sprite;
struct drm_output *output; struct drm_output *output;
@ -2297,13 +2297,13 @@ vt_func(struct weston_compositor *compositor, int event)
compositor->state = ec->prev_state; compositor->state = ec->prev_state;
drm_compositor_set_modes(ec); drm_compositor_set_modes(ec);
weston_compositor_damage_all(compositor); weston_compositor_damage_all(compositor);
wl_list_for_each(seat, &compositor->seat_list, base.link) wl_list_for_each(input, &compositor->seat_list, base.link)
udev_seat_enable(seat, ec->udev); udev_input_enable(input, ec->udev);
break; break;
case TTY_LEAVE_VT: case TTY_LEAVE_VT:
weston_log("leaving VT\n"); weston_log("leaving VT\n");
wl_list_for_each(seat, &compositor->seat_list, base.link) wl_list_for_each(input, &compositor->seat_list, base.link)
udev_seat_disable(seat); udev_input_disable(input);
compositor->focus = 0; compositor->focus = 0;
ec->prev_state = compositor->state; ec->prev_state = compositor->state;
@ -2431,7 +2431,7 @@ drm_compositor_create(struct wl_display *display,
struct drm_compositor *ec; struct drm_compositor *ec;
struct udev_device *drm_device; struct udev_device *drm_device;
struct wl_event_loop *loop; struct wl_event_loop *loop;
struct udev_seat *udev_seat, *next; struct udev_input *udev_input, *next;
const char *path; const char *path;
uint32_t key; uint32_t key;
@ -2563,8 +2563,8 @@ err_udev_monitor:
udev_monitor_unref(ec->udev_monitor); udev_monitor_unref(ec->udev_monitor);
err_drm_source: err_drm_source:
wl_event_source_remove(ec->drm_source); wl_event_source_remove(ec->drm_source);
wl_list_for_each_safe(udev_seat, next, &ec->base.seat_list, base.link) wl_list_for_each_safe(udev_input, next, &ec->base.seat_list, base.link)
udev_seat_destroy(udev_seat); udev_input_destroy(udev_input);
err_sprite: err_sprite:
ec->base.renderer->destroy(&ec->base); ec->base.renderer->destroy(&ec->base);
gbm_device_destroy(ec->gbm); gbm_device_destroy(ec->gbm);

@ -751,11 +751,11 @@ static void
fbdev_compositor_destroy(struct weston_compositor *base) fbdev_compositor_destroy(struct weston_compositor *base)
{ {
struct fbdev_compositor *compositor = to_fbdev_compositor(base); struct fbdev_compositor *compositor = to_fbdev_compositor(base);
struct udev_seat *seat, *next; struct udev_input *input, *next;
/* Destroy all inputs. */ /* Destroy all inputs. */
wl_list_for_each_safe(seat, next, &compositor->base.seat_list, base.link) wl_list_for_each_safe(input, next, &compositor->base.seat_list, base.link)
udev_seat_destroy(seat); udev_input_destroy(input);
/* Destroy the output. */ /* Destroy the output. */
weston_compositor_shutdown(&compositor->base); weston_compositor_shutdown(&compositor->base);
@ -771,7 +771,7 @@ static void
vt_func(struct weston_compositor *base, int event) vt_func(struct weston_compositor *base, int event)
{ {
struct fbdev_compositor *compositor = to_fbdev_compositor(base); struct fbdev_compositor *compositor = to_fbdev_compositor(base);
struct udev_seat *seat; struct udev_input *input;
struct weston_output *output; struct weston_output *output;
switch (event) { switch (event) {
@ -786,13 +786,13 @@ vt_func(struct weston_compositor *base, int event)
weston_compositor_damage_all(&compositor->base); weston_compositor_damage_all(&compositor->base);
wl_list_for_each(seat, &compositor->base.seat_list, base.link) wl_list_for_each(input, &compositor->base.seat_list, base.link)
udev_seat_enable(seat, compositor->udev); udev_input_enable(input, compositor->udev);
break; break;
case TTY_LEAVE_VT: case TTY_LEAVE_VT:
weston_log("leaving VT\n"); weston_log("leaving VT\n");
wl_list_for_each(seat, &compositor->base.seat_list, base.link) wl_list_for_each(input, &compositor->base.seat_list, base.link)
udev_seat_disable(seat); udev_input_disable(input);
wl_list_for_each(output, &compositor->base.output_list, link) { wl_list_for_each(output, &compositor->base.output_list, link) {
fbdev_output_disable(output); fbdev_output_disable(output);
@ -884,7 +884,7 @@ fbdev_compositor_create(struct wl_display *display, int *argc, char *argv[],
if (fbdev_output_create(compositor, param->device) < 0) if (fbdev_output_create(compositor, param->device) < 0)
goto out_pixman; goto out_pixman;
udev_seat_create(&compositor->base, compositor->udev, seat); udev_input_create(&compositor->base, compositor->udev, seat);
return &compositor->base; return &compositor->base;

@ -33,7 +33,7 @@
static const char default_seat[] = "seat0"; static const char default_seat[] = "seat0";
static int static int
device_added(struct udev_device *udev_device, struct udev_seat *master) device_added(struct udev_device *udev_device, struct udev_input *input)
{ {
struct weston_compositor *c; struct weston_compositor *c;
struct evdev_device *device; struct evdev_device *device;
@ -46,10 +46,10 @@ device_added(struct udev_device *udev_device, struct udev_seat *master)
if (!device_seat) if (!device_seat)
device_seat = default_seat; device_seat = default_seat;
if (strcmp(device_seat, master->seat_id)) if (strcmp(device_seat, input->seat_id))
return 0; return 0;
c = master->base.compositor; c = input->base.compositor;
devnode = udev_device_get_devnode(udev_device); devnode = udev_device_get_devnode(udev_device);
/* Use non-blocking mode so that we can loop on read on /* Use non-blocking mode so that we can loop on read on
@ -61,7 +61,7 @@ device_added(struct udev_device *udev_device, struct udev_seat *master)
return 0; return 0;
} }
device = evdev_device_create(&master->base, devnode, fd); device = evdev_device_create(&input->base, devnode, fd);
if (device == EVDEV_UNHANDLED_DEVICE) { if (device == EVDEV_UNHANDLED_DEVICE) {
close(fd); close(fd);
weston_log("not using input device '%s'.\n", devnode); weston_log("not using input device '%s'.\n", devnode);
@ -94,13 +94,13 @@ device_added(struct udev_device *udev_device, struct udev_seat *master)
device->abs.calibration[5]); device->abs.calibration[5]);
} }
wl_list_insert(master->devices_list.prev, &device->link); wl_list_insert(input->devices_list.prev, &device->link);
return 0; return 0;
} }
static int static int
udev_seat_add_devices(struct udev_seat *seat, struct udev *udev) udev_input_add_devices(struct udev_input *input, struct udev *udev)
{ {
struct udev_enumerate *e; struct udev_enumerate *e;
struct udev_list_entry *entry; struct udev_list_entry *entry;
@ -120,7 +120,7 @@ udev_seat_add_devices(struct udev_seat *seat, struct udev *udev)
continue; continue;
} }
if (device_added(device, seat) < 0) { if (device_added(device, input) < 0) {
udev_device_unref(device); udev_device_unref(device);
udev_enumerate_unref(e); udev_enumerate_unref(e);
return -1; return -1;
@ -130,9 +130,9 @@ udev_seat_add_devices(struct udev_seat *seat, struct udev *udev)
} }
udev_enumerate_unref(e); udev_enumerate_unref(e);
evdev_notify_keyboard_focus(&seat->base, &seat->devices_list); evdev_notify_keyboard_focus(&input->base, &input->devices_list);
if (wl_list_empty(&seat->devices_list)) { if (wl_list_empty(&input->devices_list)) {
weston_log( weston_log(
"warning: no input devices on entering Weston. " "warning: no input devices on entering Weston. "
"Possible causes:\n" "Possible causes:\n"
@ -149,13 +149,13 @@ udev_seat_add_devices(struct udev_seat *seat, struct udev *udev)
static int static int
evdev_udev_handler(int fd, uint32_t mask, void *data) evdev_udev_handler(int fd, uint32_t mask, void *data)
{ {
struct udev_seat *seat = data; struct udev_input *input = data;
struct udev_device *udev_device; struct udev_device *udev_device;
struct evdev_device *device, *next; struct evdev_device *device, *next;
const char *action; const char *action;
const char *devnode; const char *devnode;
udev_device = udev_monitor_receive_device(seat->udev_monitor); udev_device = udev_monitor_receive_device(input->udev_monitor);
if (!udev_device) if (!udev_device)
return 1; return 1;
@ -167,11 +167,11 @@ evdev_udev_handler(int fd, uint32_t mask, void *data)
goto out; goto out;
if (!strcmp(action, "add")) { if (!strcmp(action, "add")) {
device_added(udev_device, seat); device_added(udev_device, input);
} }
else if (!strcmp(action, "remove")) { else if (!strcmp(action, "remove")) {
devnode = udev_device_get_devnode(udev_device); devnode = udev_device_get_devnode(udev_device);
wl_list_for_each_safe(device, next, &seat->devices_list, link) wl_list_for_each_safe(device, next, &input->devices_list, link)
if (!strcmp(device->devnode, devnode)) { if (!strcmp(device->devnode, devnode)) {
weston_log("input device %s, %s removed\n", weston_log("input device %s, %s removed\n",
device->devname, device->devnode); device->devname, device->devnode);
@ -187,112 +187,112 @@ out:
} }
int int
udev_seat_enable(struct udev_seat *seat, struct udev *udev) udev_input_enable(struct udev_input *input, struct udev *udev)
{ {
struct wl_event_loop *loop; struct wl_event_loop *loop;
struct weston_compositor *c = seat->base.compositor; struct weston_compositor *c = input->base.compositor;
int fd; int fd;
seat->udev_monitor = udev_monitor_new_from_netlink(udev, "udev"); input->udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
if (!seat->udev_monitor) { if (!input->udev_monitor) {
weston_log("udev: failed to create the udev monitor\n"); weston_log("udev: failed to create the udev monitor\n");
return -1; return -1;
} }
udev_monitor_filter_add_match_subsystem_devtype(seat->udev_monitor, udev_monitor_filter_add_match_subsystem_devtype(input->udev_monitor,
"input", NULL); "input", NULL);
if (udev_monitor_enable_receiving(seat->udev_monitor)) { if (udev_monitor_enable_receiving(input->udev_monitor)) {
weston_log("udev: failed to bind the udev monitor\n"); weston_log("udev: failed to bind the udev monitor\n");
udev_monitor_unref(seat->udev_monitor); udev_monitor_unref(input->udev_monitor);
return -1; return -1;
} }
loop = wl_display_get_event_loop(c->wl_display); loop = wl_display_get_event_loop(c->wl_display);
fd = udev_monitor_get_fd(seat->udev_monitor); fd = udev_monitor_get_fd(input->udev_monitor);
seat->udev_monitor_source = input->udev_monitor_source =
wl_event_loop_add_fd(loop, fd, WL_EVENT_READABLE, wl_event_loop_add_fd(loop, fd, WL_EVENT_READABLE,
evdev_udev_handler, seat); evdev_udev_handler, input);
if (!seat->udev_monitor_source) { if (!input->udev_monitor_source) {
udev_monitor_unref(seat->udev_monitor); udev_monitor_unref(input->udev_monitor);
return -1; return -1;
} }
if (udev_seat_add_devices(seat, udev) < 0) if (udev_input_add_devices(input, udev) < 0)
return -1; return -1;
return 0; return 0;
} }
static void static void
udev_seat_remove_devices(struct udev_seat *seat) udev_input_remove_devices(struct udev_input *input)
{ {
struct evdev_device *device, *next; struct evdev_device *device, *next;
wl_list_for_each_safe(device, next, &seat->devices_list, link) wl_list_for_each_safe(device, next, &input->devices_list, link)
evdev_device_destroy(device); evdev_device_destroy(device);
if (seat->base.keyboard) if (input->base.keyboard)
notify_keyboard_focus_out(&seat->base); notify_keyboard_focus_out(&input->base);
} }
void void
udev_seat_disable(struct udev_seat *seat) udev_input_disable(struct udev_input *input)
{ {
if (!seat->udev_monitor) if (!input->udev_monitor)
return; return;
udev_monitor_unref(seat->udev_monitor); udev_monitor_unref(input->udev_monitor);
seat->udev_monitor = NULL; input->udev_monitor = NULL;
wl_event_source_remove(seat->udev_monitor_source); wl_event_source_remove(input->udev_monitor_source);
seat->udev_monitor_source = NULL; input->udev_monitor_source = NULL;
udev_seat_remove_devices(seat); udev_input_remove_devices(input);
} }
static void static void
drm_led_update(struct weston_seat *seat_base, enum weston_led leds) drm_led_update(struct weston_seat *seat_base, enum weston_led leds)
{ {
struct udev_seat *seat = (struct udev_seat *) seat_base; struct udev_input *seat = (struct udev_input *) seat_base;
struct evdev_device *device; struct evdev_device *device;
wl_list_for_each(device, &seat->devices_list, link) wl_list_for_each(device, &seat->devices_list, link)
evdev_led_update(device, leds); evdev_led_update(device, leds);
} }
struct udev_seat * struct udev_input *
udev_seat_create(struct weston_compositor *c, struct udev *udev, udev_input_create(struct weston_compositor *c, struct udev *udev,
const char *seat_id) const char *seat_id)
{ {
struct udev_seat *seat; struct udev_input *input;
seat = malloc(sizeof *seat); input = malloc(sizeof *input);
if (seat == NULL) if (input == NULL)
return NULL; return NULL;
memset(seat, 0, sizeof *seat); memset(input, 0, sizeof *input);
weston_seat_init(&seat->base, c, "default"); weston_seat_init(&input->base, c, "default");
seat->base.led_update = drm_led_update; input->base.led_update = drm_led_update;
wl_list_init(&seat->devices_list); wl_list_init(&input->devices_list);
seat->seat_id = strdup(seat_id); input->seat_id = strdup(seat_id);
if (udev_seat_enable(seat, udev) < 0) if (udev_input_enable(input, udev) < 0)
goto err; goto err;
return seat; return input;
err: err:
free(seat->seat_id); free(input->seat_id);
free(seat); free(input);
return NULL; return NULL;
} }
void void
udev_seat_destroy(struct udev_seat *seat) udev_input_destroy(struct udev_input *input)
{ {
udev_seat_disable(seat); udev_input_disable(input);
weston_seat_release(&seat->base); weston_seat_release(&input->base);
free(seat->seat_id); free(input->seat_id);
free(seat); free(input);
} }

@ -27,7 +27,7 @@
#include "compositor.h" #include "compositor.h"
struct udev_seat { struct udev_input {
struct weston_seat base; struct weston_seat base;
struct wl_list devices_list; struct wl_list devices_list;
struct udev_monitor *udev_monitor; struct udev_monitor *udev_monitor;
@ -35,11 +35,11 @@ struct udev_seat {
char *seat_id; char *seat_id;
}; };
int udev_seat_enable(struct udev_seat *seat, struct udev *udev); int udev_input_enable(struct udev_input *input, struct udev *udev);
void udev_seat_disable(struct udev_seat *seat); void udev_input_disable(struct udev_input *input);
struct udev_seat *udev_seat_create(struct weston_compositor *c, struct udev_input *udev_input_create(struct weston_compositor *c,
struct udev *udev, struct udev *udev,
const char *seat_id); const char *seat_id);
void udev_seat_destroy(struct udev_seat *seat); void udev_input_destroy(struct udev_input *input);
#endif #endif

Loading…
Cancel
Save