Applications DnD under wayland does not work at times due to serial mismatch (caused by pinging)
In ubuntu we noticed that Firefox running from snaps is underling an issue that I can also 100% reproduce in my jhbuild nested dev environment with any gnome app (I suppose is time related).
Basically, trying to use DnD is denied by mutter (can do by just trying to drag a nautilus file: nothing happens).
@oSoMoN was able to isolate the issue to commit 26676a82.
Looking further I've tried to understand what was happening and basically: while we were called back by wayland on data_device_start_drag
the drag was ignored because of serial mismatching:
/../mutter/src/wayland/meta-wayland-data-device.c:684
684 if (seat->pointer->button_count == 0 ||
(gdb) print seat
$1 = (MetaWaylandSeat *) 0x5555558a6a40
(gdb) print *seat
$2 = {base_resource_list = {prev = 0x5555582abda0, next = 0x5555576e4080}, wl_display = 0x5555558a5720,
pointer = 0x5555557f2ef0, keyboard = 0x55555584d130, touch = 0x5555558a42e0, data_device = {
selection_serial = 0, selection_data_source = 0x0, dnd_data_source = 0x0, resource_list = {
prev = 0x55555914d550, next = 0x55555784b450}, focus_resource_list = {prev = 0x555557e15250,
next = 0x555557e15250}, current_grab = 0x0, focus_client = 0x55555750fce0,
selection_owner_signal_id = 23323, owners = {0x0, 0x0, 0x0}}, primary_data_device = {serial = 0,
data_source = 0x0, resource_list = {prev = 0x55555914d4c0, next = 0x5555591d8460}, focus_resource_list = {
prev = 0x555557e151c0, next = 0x555557e151c0}, focus_client = 0x55555750fce0,
selection_owner_signal_id = 23322, owner = 0x0}, primary_legacy_data_device = {serial = 0, data_source = 0x0,
resource_list = {prev = 0x5555558a6b30, next = 0x5555558a6b30}, focus_resource_list = {prev = 0x5555558a6b40,
next = 0x5555558a6b40}, focus_client = 0x55555750fce0, selection_owner_signal_id = 0, owner = 0x0},
text_input = 0x5555558a7600, capabilities = 3}
(gdb) print seat->pointer->grab_serial
$8 = 373
(gdb) print serial
$9 = 187520283
Those serials indeed looked quite different... And the reason is that apparently the event timestamp in ms (187520283
) that we have sent as pinging request is actually used after by wayland as device start-drag serial.
As per this I feel that it would be better to just use the wayland serial in this case, even though it may be always the same on drag events... But this doesn't seem to lead to practical issues.
/cc @carlosg