[PATCH weston 4/4] input: Fix errors due to initializing input before creating outputs
Ander Conselvan de Oliveira
conselvan2 at gmail.com
Thu Apr 24 05:13:07 PDT 2014
On 04/23/2014 06:36 PM, Neil Roberts wrote:
> I think we accientally wrote nearly identical patches at the same time:
>
> http://lists.freedesktop.org/archives/wayland-devel/2014-April/014392.html
>
> However, I still get the crash with Ander's patch because it looks like
> it is missing the check for wl_list_empty in the libinput-seat.c version
> of device_added.
>
> I think it would make sense to fix this patch and use it rather than my
> version because my one assumes the old behaviour where if we can't find
> an output with the right name for a seat then we default to using any
> output. This is changed in patch 1 of Ander's series. I think Ander's
> approach is more robust. Ie, if we can't find an output for a seat that
> has an explicit output name then we just ignore events for it.
>
> However I notice that patch 1 of the series also doesn't make this
> revert for the libinput-seat.c version of device_added so that will
> still maintain the behaviour of resorting to a default output from this
> commit:
Shoot, I forgot libinput-seat again. /o\
I'm sending fixed patches now.
Thanks,
Ander
> http://cgit.freedesktop.org/wayland/weston/commit/?id=161c6c56944cdfbda
>
> - Neil
>
> Ander Conselvan de Oliveira <conselvan2 at gmail.com> writes:
>
>> From: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>
>>
>> Make sure that we don't map a device to an invalid output pointer and
>> intead remap devices when an output is created.
>> ---
>> src/evdev.c | 2 +-
>> src/libinput-device.c | 2 +-
>> src/libinput-seat.c | 6 +++++-
>> src/udev-seat.c | 8 ++++++--
>> 4 files changed, 13 insertions(+), 5 deletions(-)
>>
>> diff --git a/src/evdev.c b/src/evdev.c
>> index ff951d3..888dfbd 100644
>> --- a/src/evdev.c
>> +++ b/src/evdev.c
>> @@ -601,7 +601,7 @@ notify_output_destroy(struct wl_listener *listener, void *data)
>> struct weston_compositor *c = device->seat->compositor;
>> 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,
>> struct weston_output, link);
>> evdev_device_set_output(device, output);
>> diff --git a/src/libinput-device.c b/src/libinput-device.c
>> index 753583a..4605a76 100644
>> --- a/src/libinput-device.c
>> +++ b/src/libinput-device.c
>> @@ -264,7 +264,7 @@ notify_output_destroy(struct wl_listener *listener, void *data)
>> struct weston_compositor *c = device->seat->compositor;
>> 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,
>> struct weston_output, link);
>> evdev_device_set_output(device, output);
>> diff --git a/src/libinput-seat.c b/src/libinput-seat.c
>> index 8bf538c..e900744 100644
>> --- a/src/libinput-seat.c
>> +++ b/src/libinput-seat.c
>> @@ -316,11 +316,15 @@ notify_output_create(struct wl_listener *listener, void *data)
>> struct evdev_device *device;
>> 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 &&
>> strcmp(output->name, device->output_name) == 0) {
>> evdev_device_set_output(device, output);
>> }
>> +
>> + if (device->output_name == NULL && device->output == NULL)
>> + evdev_device_set_output(device, output);
>> + }
>> }
>>
>> static struct udev_seat *
>> diff --git a/src/udev-seat.c b/src/udev-seat.c
>> index dfeb17f..93984e1 100644
>> --- a/src/udev-seat.c
>> +++ b/src/udev-seat.c
>> @@ -125,7 +125,7 @@ device_added(struct udev_device *udev_device, struct udev_input *input)
>> wl_list_for_each(output, &c->output_list, link)
>> if (strcmp(output->name, device->output_name) == 0)
>> 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,
>> struct weston_output, link);
>> evdev_device_set_output(device, output);
>> @@ -357,11 +357,15 @@ notify_output_create(struct wl_listener *listener, void *data)
>> struct evdev_device *device;
>> 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 &&
>> strcmp(output->name, device->output_name) == 0) {
>> evdev_device_set_output(device, output);
>> }
>> +
>> + if (device->output_name == NULL && device->output == NULL)
>> + evdev_device_set_output(device, output);
>> + }
>> }
>>
>> static struct udev_seat *
>> --
>> 1.8.3.2
>>
>> _______________________________________________
>> wayland-devel mailing list
>> wayland-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list