Igalia / cog

WPE launcher and webapp container
MIT License
241 stars 61 forks source link

Popup menu not opened when selecting HTML select element #503

Open NikoDelarich opened 2 years ago

NikoDelarich commented 2 years ago

Hello,

when tapping on a HTML <select> element on a touchscreen, the popup menu does not open.

I've narrowed the problem down to xdg_popup_grab() in create_popup(): https://github.com/Igalia/cog/blob/32c1d9533bcdc22cbc01d02bf2e6ac0d4bda2dc2/platform/wayland/cog-platform-wl.c#L2312-L2316

xdg_popup_grab() eventually ends up in weston_desktop_surface_popup_grab() in weston where the popup is immediately dismissed, because the passed serial does not match the original "grab_serial" of the touch_down event:

    if ((keyboard == NULL || keyboard->grab_serial != serial) &&
        (pointer == NULL || pointer->grab_serial != serial) &&
        (touch == NULL || touch->grab_serial != serial)) {
        return false;
    }

This behaviour is documented here:

If the compositor denies the grab, the popup will be immediately dismissed.

I think cog would need to pass the serial of the touch down event instead. Simply removing the whole xdg_popup_grab line worked for me as well.

For reference: I'm using cog 0.14.1 with the wl backend & weston 10.0.1. There's no way to attach a keyboard or mouse to my device, so I'm not sure if this is a touch-only issue.

Here's a test page, if needed: https://russmaxdesign.github.io/accessible-forms/02-select.html

griloHBG commented 2 years ago

I am able to reproduce the same issue (although using cog 0.12.0 and weston 9.0.0 from NXP) on an i.MX 8M Mini.

Removing the line xdg_popup_grab from cog/platform/wayland/cog-platform-wl.c indeed made the popup menu to work.

Thanks for sharing this quick fix! :)

There's no way to attach a keyboard or mouse to my device, so I'm not sure if this is a touch-only issue.

It seems to be a touch-only issue. At least with the versions that I am using mouse works well with the popup menu.