[PATCH weston] window: Ignore input events from subsurfaces
Ander Conselvan de Oliveira
ander.conselvan.de.oliveira at intel.com
Tue May 6 06:11:30 PDT 2014
On 05/06/2014 03:40 PM, Pekka Paalanen wrote:
> On Tue, 6 May 2014 15:25:40 +0300
> Ander Conselvan de Oliveira <conselvan2 at gmail.com> wrote:
>
>> From: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>
>>
>> Toytoolkit was not designed to handle input from subsurfaces and
>> instead it expects subsurfaces to have an empty input region. That way
>> input events for subsurfaces are generated on the main surface and
>> there is no need to convert coordinates before reporting the event to
>> the user.
>>
>> However it is possible that a subsurface has a non-empty input region,
>> but in that case those events aren't properly processed. The function
>> window_find_widget() assumes the coordinates are in the main surface
>> coordinate space, and ends up chosing the wrong widget.
>>
>> This patch changes the input code to completely ignore input events from
>> subsurfaces. This option was chosen instead of ensuring that the input
>> region on those surfaces is always empty since there's no enforcement
>> that a subsurface should completely overlap with the main surface. If
>> an event happens in the area of the surface that doesn't overlap, the
>> event could cause a completely unrelated surface to be picked.
>>
>> https://bugs.freedesktop.org/show_bug.cgi?id=78207
>> ---
>> clients/window.c | 21 ++++++++++++++++-----
>> 1 file changed, 16 insertions(+), 5 deletions(-)
>>
>> diff --git a/clients/window.c b/clients/window.c
>> index b7febed..3b57264 100644
>> --- a/clients/window.c
>> +++ b/clients/window.c
>> @@ -2605,10 +2605,15 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
>> return;
>> }
>>
>> + window = wl_surface_get_user_data(surface);
>> + if (surface != window->main_surface->surface) {
>> + DBG("Ignoring input event from subsurface %p\n", surface);
>> + return;
>
> Ignoring enter on a sub-surface, actually. I assume the explanation is
> that, that the leave on the main surface already sets pointer_focus to
> NULL, and here we just avoid setting it, so all following input events
> get ignored.
>
> Ok.
>
>> + }
>> +
>> input->display->serial = serial;
>> input->pointer_enter_serial = serial;
>> - input->pointer_focus = wl_surface_get_user_data(surface);
>> - window = input->pointer_focus;
>> + input->pointer_focus = window;
>>
>> if (window->resizing) {
>> window->resizing = 0;
>> @@ -2644,12 +2649,12 @@ pointer_handle_motion(void *data, struct wl_pointer *pointer,
>> float sx = wl_fixed_to_double(sx_w);
>> float sy = wl_fixed_to_double(sy_w);
>>
>> - input->sx = sx;
>> - input->sy = sy;
>> -
>> if (!window)
>> return;
>>
>> + input->sx = sx;
>> + input->sy = sy;
>> +
>> /* when making the window smaller - e.g. after a unmaximise we might
>> * still have a pending motion event that the compositor has picked
>> * based on the old surface dimensions
>> @@ -2979,6 +2984,12 @@ touch_handle_down(void *data, struct wl_touch *wl_touch,
>> return;
>> }
>>
>> + if (surface != input->touch_focus->main_surface->surface) {
>
> Could touch_focus somehow already be NULL?
Yeah, it's possible. If I understand correctly, in that case all touch
events are ignored.
> Like putting two fingers one after the other to the sub-surface?
>
>> + DBG("Ignoring input event from subsurface %p\n", surface);
>> + input->touch_focus = NULL;
>
> If I have a finger down on the main surface somewhere, and put another
> finger on the tooltip, won't I lose the main surface then?
>
> Sorry, I've no idea how multitouch works here.
Yeah, the main surface would lose touch focus. The behavior is to change
the focus to the last touched surface. So if they were two separate
windows, only the second window would get the touch events. At least
that's how I understood it.
Cheers,
Ander
>
>> + return;
>> + }
>> +
>> if (input->grab)
>> widget = input->grab;
>> else
>
> Thanks,
> pq
>
---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki
Business Identity Code: 0357606 - 4
Domiciled in Helsinki
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
More information about the wayland-devel
mailing list