[PATCH weston 05/10] udev-seat: Rename udev_seat to udev_input

Rob Bradford robert.bradford at intel.com
Fri May 31 10:09:54 PDT 2013


From: Rob Bradford <rob at linux.intel.com>

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.
---
 src/compositor-drm.c   |  22 +++++-----
 src/compositor-fbdev.c |  18 ++++----
 src/udev-seat.c        | 114 ++++++++++++++++++++++++-------------------------
 src/udev-seat.h        |  10 ++---
 4 files changed, 82 insertions(+), 82 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index a6d8348..1845978 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -2228,10 +2228,10 @@ static void
 drm_destroy(struct weston_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)
-		udev_seat_destroy(seat);
+	wl_list_for_each_safe(input, next, &ec->seat_list, base.link)
+		udev_input_destroy(input);
 
 	wl_event_source_remove(d->udev_drm_source);
 	wl_event_source_remove(d->drm_source);
@@ -2288,7 +2288,7 @@ static void
 vt_func(struct weston_compositor *compositor, int event)
 {
 	struct drm_compositor *ec = (struct drm_compositor *) compositor;
-	struct udev_seat *seat;
+	struct udev_input *input;
 	struct drm_sprite *sprite;
 	struct drm_output *output;
 
@@ -2303,13 +2303,13 @@ vt_func(struct weston_compositor *compositor, int event)
 		compositor->state = ec->prev_state;
 		drm_compositor_set_modes(ec);
 		weston_compositor_damage_all(compositor);
-		wl_list_for_each(seat, &compositor->seat_list, base.link)
-			udev_seat_enable(seat, ec->udev);
+		wl_list_for_each(input, &compositor->seat_list, base.link)
+			udev_input_enable(input, ec->udev);
 		break;
 	case TTY_LEAVE_VT:
 		weston_log("leaving VT\n");
-		wl_list_for_each(seat, &compositor->seat_list, base.link)
-			udev_seat_disable(seat);
+		wl_list_for_each(input, &compositor->seat_list, base.link)
+			udev_input_disable(input);
 
 		compositor->focus = 0;
 		ec->prev_state = compositor->state;
@@ -2437,7 +2437,7 @@ drm_compositor_create(struct wl_display *display,
 	struct drm_compositor *ec;
 	struct udev_device *drm_device;
 	struct wl_event_loop *loop;
-	struct udev_seat *udev_seat, *next;
+	struct udev_input *udev_input, *next;
 	const char *path;
 	uint32_t key;
 
@@ -2569,8 +2569,8 @@ err_udev_monitor:
 	udev_monitor_unref(ec->udev_monitor);
 err_drm_source:
 	wl_event_source_remove(ec->drm_source);
-	wl_list_for_each_safe(udev_seat, next, &ec->base.seat_list, base.link)
-		udev_seat_destroy(udev_seat);
+	wl_list_for_each_safe(udev_input, next, &ec->base.seat_list, base.link)
+		udev_input_destroy(udev_input);
 err_sprite:
 	ec->base.renderer->destroy(&ec->base);
 	gbm_device_destroy(ec->gbm);
diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
index 898933f..43897da 100644
--- a/src/compositor-fbdev.c
+++ b/src/compositor-fbdev.c
@@ -751,11 +751,11 @@ static void
 fbdev_compositor_destroy(struct weston_compositor *base)
 {
 	struct fbdev_compositor *compositor = to_fbdev_compositor(base);
-	struct udev_seat *seat, *next;
+	struct udev_input *input, *next;
 
 	/* Destroy all inputs. */
-	wl_list_for_each_safe(seat, next, &compositor->base.seat_list, base.link)
-		udev_seat_destroy(seat);
+	wl_list_for_each_safe(input, next, &compositor->base.seat_list, base.link)
+		udev_input_destroy(input);
 
 	/* Destroy the output. */
 	weston_compositor_shutdown(&compositor->base);
@@ -771,7 +771,7 @@ static void
 vt_func(struct weston_compositor *base, int event)
 {
 	struct fbdev_compositor *compositor = to_fbdev_compositor(base);
-	struct udev_seat *seat;
+	struct udev_input *input;
 	struct weston_output *output;
 
 	switch (event) {
@@ -786,13 +786,13 @@ vt_func(struct weston_compositor *base, int event)
 
 		weston_compositor_damage_all(&compositor->base);
 
-		wl_list_for_each(seat, &compositor->base.seat_list, base.link)
-			udev_seat_enable(seat, compositor->udev);
+		wl_list_for_each(input, &compositor->base.seat_list, base.link)
+			udev_input_enable(input, compositor->udev);
 		break;
 	case TTY_LEAVE_VT:
 		weston_log("leaving VT\n");
-		wl_list_for_each(seat, &compositor->base.seat_list, base.link)
-			udev_seat_disable(seat);
+		wl_list_for_each(input, &compositor->base.seat_list, base.link)
+			udev_input_disable(input);
 
 		wl_list_for_each(output, &compositor->base.output_list, link) {
 			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)
 		goto out_pixman;
 
-	udev_seat_create(&compositor->base, compositor->udev, seat);
+	udev_input_create(&compositor->base, compositor->udev, seat);
 
 	return &compositor->base;
 
diff --git a/src/udev-seat.c b/src/udev-seat.c
index 93dea2a..8c30643 100644
--- a/src/udev-seat.c
+++ b/src/udev-seat.c
@@ -33,7 +33,7 @@
 static const char default_seat[] = "seat0";
 
 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 evdev_device *device;
@@ -46,10 +46,10 @@ device_added(struct udev_device *udev_device, struct udev_seat *master)
 	if (!device_seat)
 		device_seat = default_seat;
 
-	if (strcmp(device_seat, master->seat_id))
+	if (strcmp(device_seat, input->seat_id))
 		return 0;
 
-	c = master->base.compositor;
+	c = input->base.compositor;
 	devnode = udev_device_get_devnode(udev_device);
 
 	/* 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 -1;
 	}
 
-	device = evdev_device_create(&master->base, devnode, fd);
+	device = evdev_device_create(&input->base, devnode, fd);
 	if (device == EVDEV_UNHANDLED_DEVICE) {
 		close(fd);
 		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]);
 	}
 
-	wl_list_insert(master->devices_list.prev, &device->link);
+	wl_list_insert(input->devices_list.prev, &device->link);
 
 	return 0;
 }
 
 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_list_entry *entry;
@@ -120,7 +120,7 @@ udev_seat_add_devices(struct udev_seat *seat, struct udev *udev)
 			continue;
 		}
 
-		if (device_added(device, seat) < 0) {
+		if (device_added(device, input) < 0) {
 			udev_device_unref(device);
 			udev_enumerate_unref(e);
 			return -1;
@@ -130,9 +130,9 @@ udev_seat_add_devices(struct udev_seat *seat, struct udev *udev)
 	}
 	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(
 			"warning: no input devices on entering Weston. "
 			"Possible causes:\n"
@@ -148,13 +148,13 @@ udev_seat_add_devices(struct udev_seat *seat, struct udev *udev)
 static int
 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 evdev_device *device, *next;
 	const char *action;
 	const char *devnode;
 
-	udev_device = udev_monitor_receive_device(seat->udev_monitor);
+	udev_device = udev_monitor_receive_device(input->udev_monitor);
 	if (!udev_device)
 		return 1;
 
@@ -166,11 +166,11 @@ evdev_udev_handler(int fd, uint32_t mask, void *data)
 		goto out;
 
 	if (!strcmp(action, "add")) {
-		device_added(udev_device, seat);
+		device_added(udev_device, input);
 	}
 	else if (!strcmp(action, "remove")) {
 		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)) {
 				weston_log("input device %s, %s removed\n",
 					   device->devname, device->devnode);
@@ -186,112 +186,112 @@ out:
 }
 
 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 weston_compositor *c = seat->base.compositor;
+	struct weston_compositor *c = input->base.compositor;
 	int fd;
 
-	seat->udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
-	if (!seat->udev_monitor) {
+	input->udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
+	if (!input->udev_monitor) {
 		weston_log("udev: failed to create the udev monitor\n");
 		return -1;
 	}
 
-	udev_monitor_filter_add_match_subsystem_devtype(seat->udev_monitor,
+	udev_monitor_filter_add_match_subsystem_devtype(input->udev_monitor,
 			"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");
-		udev_monitor_unref(seat->udev_monitor);
+		udev_monitor_unref(input->udev_monitor);
 		return -1;
 	}
 
 	loop = wl_display_get_event_loop(c->wl_display);
-	fd = udev_monitor_get_fd(seat->udev_monitor);
-	seat->udev_monitor_source =
+	fd = udev_monitor_get_fd(input->udev_monitor);
+	input->udev_monitor_source =
 		wl_event_loop_add_fd(loop, fd, WL_EVENT_READABLE,
-				     evdev_udev_handler, seat);
-	if (!seat->udev_monitor_source) {
-		udev_monitor_unref(seat->udev_monitor);
+				     evdev_udev_handler, input);
+	if (!input->udev_monitor_source) {
+		udev_monitor_unref(input->udev_monitor);
 		return -1;
 	}
 
-	if (udev_seat_add_devices(seat, udev) < 0)
+	if (udev_input_add_devices(input, udev) < 0)
 		return -1;
 
 	return 0;
 }
 
 static void
-udev_seat_remove_devices(struct udev_seat *seat)
+udev_input_remove_devices(struct udev_input *input)
 {
 	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);
 
-	if (seat->base.keyboard)
-		notify_keyboard_focus_out(&seat->base);
+	if (input->base.keyboard)
+		notify_keyboard_focus_out(&input->base);
 }
 
 void
-udev_seat_disable(struct udev_seat *seat)
+udev_input_disable(struct udev_input *input)
 {
-	if (!seat->udev_monitor)
+	if (!input->udev_monitor)
 		return;
 
-	udev_monitor_unref(seat->udev_monitor);
-	seat->udev_monitor = NULL;
-	wl_event_source_remove(seat->udev_monitor_source);
-	seat->udev_monitor_source = NULL;
+	udev_monitor_unref(input->udev_monitor);
+	input->udev_monitor = NULL;
+	wl_event_source_remove(input->udev_monitor_source);
+	input->udev_monitor_source = NULL;
 
-	udev_seat_remove_devices(seat);
+	udev_input_remove_devices(input);
 }
 
 static void
 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;
 
 	wl_list_for_each(device, &seat->devices_list, link)
 		evdev_led_update(device, leds);
 }
 
-struct udev_seat *
-udev_seat_create(struct weston_compositor *c, struct udev *udev,
+struct udev_input *
+udev_input_create(struct weston_compositor *c, struct udev *udev,
 		const char *seat_id)
 {
-	struct udev_seat *seat;
+	struct udev_input *input;
 
-	seat = malloc(sizeof *seat);
-	if (seat == NULL)
+	input = malloc(sizeof *input);
+	if (input == NULL)
 		return NULL;
 
-	memset(seat, 0, sizeof *seat);
-	weston_seat_init(&seat->base, c, "default");
-	seat->base.led_update = drm_led_update;
+	memset(input, 0, sizeof *input);
+	weston_seat_init(&input->base, c, "default");
+	input->base.led_update = drm_led_update;
 
-	wl_list_init(&seat->devices_list);
-	seat->seat_id = strdup(seat_id);
-	if (udev_seat_enable(seat, udev) < 0)
+	wl_list_init(&input->devices_list);
+	input->seat_id = strdup(seat_id);
+	if (udev_input_enable(input, udev) < 0)
 		goto err;
 
-	return seat;
+	return input;
 
  err:
-	free(seat->seat_id);
-	free(seat);
+	free(input->seat_id);
+	free(input);
 	return NULL;
 }
 
 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);
-	free(seat->seat_id);
-	free(seat);
+	weston_seat_release(&input->base);
+	free(input->seat_id);
+	free(input);
 }
diff --git a/src/udev-seat.h b/src/udev-seat.h
index 0cfafd9..dbc6269 100644
--- a/src/udev-seat.h
+++ b/src/udev-seat.h
@@ -27,7 +27,7 @@
 
 #include "compositor.h"
 
-struct udev_seat {
+struct udev_input {
 	struct weston_seat base;
 	struct wl_list devices_list;
 	struct udev_monitor *udev_monitor;
@@ -35,11 +35,11 @@ struct udev_seat {
 	char *seat_id;
 };
 
-int udev_seat_enable(struct udev_seat *seat, struct udev *udev);
-void udev_seat_disable(struct udev_seat *seat);
-struct udev_seat *udev_seat_create(struct weston_compositor *c,
+int udev_input_enable(struct udev_input *input, struct udev *udev);
+void udev_input_disable(struct udev_input *input);
+struct udev_input *udev_input_create(struct weston_compositor *c,
 				   struct udev *udev,
 				   const char *seat_id);
-void udev_seat_destroy(struct udev_seat *seat);
+void udev_input_destroy(struct udev_input *input);
 
 #endif
-- 
1.8.1.4



More information about the wayland-devel mailing list