input: Fix errors due to initializing input before creating outputs
Make sure that we don't map a device to an invalid output pointer and intead remap devices when an output is created. v2: fix the error with libinput too.
This commit is contained in:
committed by
Kristian Høgsberg
parent
ae826cead7
commit
a7caef964b
+1
-1
@@ -601,7 +601,7 @@ notify_output_destroy(struct wl_listener *listener, void *data)
|
|||||||
struct weston_compositor *c = device->seat->compositor;
|
struct weston_compositor *c = device->seat->compositor;
|
||||||
struct weston_output *output;
|
struct weston_output *output;
|
||||||
|
|
||||||
if (!device->output_name) {
|
if (!device->output_name && !wl_list_empty(&c->output_list)) {
|
||||||
output = container_of(c->output_list.next,
|
output = container_of(c->output_list.next,
|
||||||
struct weston_output, link);
|
struct weston_output, link);
|
||||||
evdev_device_set_output(device, output);
|
evdev_device_set_output(device, output);
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ notify_output_destroy(struct wl_listener *listener, void *data)
|
|||||||
struct weston_compositor *c = device->seat->compositor;
|
struct weston_compositor *c = device->seat->compositor;
|
||||||
struct weston_output *output;
|
struct weston_output *output;
|
||||||
|
|
||||||
if (!device->output_name) {
|
if (!device->output_name && !wl_list_empty(&c->output_list)) {
|
||||||
output = container_of(c->output_list.next,
|
output = container_of(c->output_list.next,
|
||||||
struct weston_output, link);
|
struct weston_output, link);
|
||||||
evdev_device_set_output(device, output);
|
evdev_device_set_output(device, output);
|
||||||
|
|||||||
+6
-2
@@ -84,7 +84,7 @@ device_added(struct udev_input *input, struct libinput_device *libinput_device)
|
|||||||
wl_list_for_each(output, &c->output_list, link)
|
wl_list_for_each(output, &c->output_list, link)
|
||||||
if (strcmp(output->name, device->output_name) == 0)
|
if (strcmp(output->name, device->output_name) == 0)
|
||||||
evdev_device_set_output(device, output);
|
evdev_device_set_output(device, output);
|
||||||
} else if (device->output == NULL) {
|
} else if (device->output == NULL && !wl_list_empty(&c->output_list)) {
|
||||||
output = container_of(c->output_list.next,
|
output = container_of(c->output_list.next,
|
||||||
struct weston_output, link);
|
struct weston_output, link);
|
||||||
evdev_device_set_output(device, output);
|
evdev_device_set_output(device, output);
|
||||||
@@ -314,11 +314,15 @@ notify_output_create(struct wl_listener *listener, void *data)
|
|||||||
struct evdev_device *device;
|
struct evdev_device *device;
|
||||||
struct weston_output *output = data;
|
struct weston_output *output = data;
|
||||||
|
|
||||||
wl_list_for_each(device, &seat->devices_list, link)
|
wl_list_for_each(device, &seat->devices_list, link) {
|
||||||
if (device->output_name &&
|
if (device->output_name &&
|
||||||
strcmp(output->name, device->output_name) == 0) {
|
strcmp(output->name, device->output_name) == 0) {
|
||||||
evdev_device_set_output(device, output);
|
evdev_device_set_output(device, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (device->output_name == NULL && device->output == NULL)
|
||||||
|
evdev_device_set_output(device, output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct udev_seat *
|
static struct udev_seat *
|
||||||
|
|||||||
+6
-2
@@ -125,7 +125,7 @@ device_added(struct udev_device *udev_device, struct udev_input *input)
|
|||||||
wl_list_for_each(output, &c->output_list, link)
|
wl_list_for_each(output, &c->output_list, link)
|
||||||
if (strcmp(output->name, device->output_name) == 0)
|
if (strcmp(output->name, device->output_name) == 0)
|
||||||
evdev_device_set_output(device, output);
|
evdev_device_set_output(device, output);
|
||||||
} else if (device->output == NULL) {
|
} else if (device->output == NULL && !wl_list_empty(&c->output_list)) {
|
||||||
output = container_of(c->output_list.next,
|
output = container_of(c->output_list.next,
|
||||||
struct weston_output, link);
|
struct weston_output, link);
|
||||||
evdev_device_set_output(device, output);
|
evdev_device_set_output(device, output);
|
||||||
@@ -357,11 +357,15 @@ notify_output_create(struct wl_listener *listener, void *data)
|
|||||||
struct evdev_device *device;
|
struct evdev_device *device;
|
||||||
struct weston_output *output = data;
|
struct weston_output *output = data;
|
||||||
|
|
||||||
wl_list_for_each(device, &seat->devices_list, link)
|
wl_list_for_each(device, &seat->devices_list, link) {
|
||||||
if (device->output_name &&
|
if (device->output_name &&
|
||||||
strcmp(output->name, device->output_name) == 0) {
|
strcmp(output->name, device->output_name) == 0) {
|
||||||
evdev_device_set_output(device, output);
|
evdev_device_set_output(device, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (device->output_name == NULL && device->output == NULL)
|
||||||
|
evdev_device_set_output(device, output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct udev_seat *
|
static struct udev_seat *
|
||||||
|
|||||||
Reference in New Issue
Block a user