Bug 437406 - Cannot drag-and-drop between Wayland and Xwayland apps
Summary: Cannot drag-and-drop between Wayland and Xwayland apps
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: git master
Platform: Neon Linux
: HI normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2021-05-20 12:32 UTC by Patrick Silva
Modified: 2021-09-02 15:56 UTC (History)
8 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.23


Attachments
kwin master crash on D&D onto Thunderbird attachment (2.38 KB, text/plain)
2021-05-21 12:44 UTC, Andrey
Details
kwin crash under valgrind (13.58 KB, text/x-log)
2021-05-21 16:27 UTC, Andrey
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Silva 2021-05-20 12:32:06 UTC
STEPS TO REPRODUCE
1. drag a jpg file from Dolphin and try to drop it on Firefox running on Xwayland
2. 
3. 

OBSERVED RESULT
Firefox does not open the jpg file

EXPECTED RESULT
Firefox opens the jpg file

SOFTWARE/OS VERSIONS
Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.22.80
KDE Frameworks Version: 5.83.0
Qt Version: 5.15.2
Graphics Platform: Wayland

ADDITIONAL INFORMATION
also reproducible with Opera internet browser
Comment 1 Nate Graham 2021-05-20 18:46:28 UTC
Can reproduce.
Comment 2 David Edmundson 2021-05-20 23:29:03 UTC
Spend some time investigating

XVisit::drop never happens
Comment 3 David Edmundson 2021-05-20 23:34:11 UTC
And that's because kwin never considers the drag as accepted
Comment 4 Andrey 2021-05-21 12:44:15 UTC
Created attachment 138638 [details]
kwin master crash on D&D onto Thunderbird attachment

Dragged .pdf document from Files to XWayland Thunderbird,
kwin commit 22f2e3e43c47433ac4eb185a2cd864625d5116d9 (HEAD -> master, origin/master, origin/HEAD)
Comment 5 Bug Janitor Service 2021-05-21 14:17:54 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/1020
Comment 6 Andrey 2021-05-21 16:27:56 UTC
Created attachment 138655 [details]
kwin crash under valgrind

Could reproduce the crash with following command for Valgrind:
dbus-run-session valgrind --log-file=kwinxwayland.log kwin_wayland --exit-with-session=konsole --xwayland

Then, run thunderbird and nautilus from opened konsole in nested session, then try d&d a .pdf file
Comment 7 David Edmundson 2021-05-24 14:07:01 UTC
Git commit 8a699ef1877e28927fc7227742d254deed69d9e9 by David Edmundson.
Committed on 24/05/2021 at 14:06.
Pushed by davidedmundson into branch 'master'.

[xwl] Notify wayland that our data offer is accepted

kwayland-server was updated to follow the result of whether the data
offer was accepted before calling drop.

Our bridge was not updated.

We don't have enough data to know which mimeType the XWayland client
actually has accepted, as that doesn't exist at an X11 level, but it
doesn't have a big actual impact. Despite which mime type gets accepted
any mimetype can be retrieved in the drop event.

Tested against "dropsite" from QtBase widget examples forced into xcb
mode using dolphin as a source.

M  +4    -0    src/xwl/drag_wl.cpp

https://invent.kde.org/plasma/kwin/commit/8a699ef1877e28927fc7227742d254deed69d9e9
Comment 8 David Edmundson 2021-05-24 14:08:26 UTC
Git commit 297d88b10b5359796a0ee260e9484876bd42faa3 by David Edmundson.
Committed on 24/05/2021 at 14:08.
Pushed by davidedmundson into branch 'Plasma/5.22'.

[xwl] Notify wayland that our data offer is accepted

kwayland-server was updated to follow the result of whether the data
offer was accepted before calling drop.

Our bridge was not updated.

We don't have enough data to know which mimeType the XWayland client
actually has accepted, as that doesn't exist at an X11 level, but it
doesn't have a big actual impact. Despite which mime type gets accepted
any mimetype can be retrieved in the drop event.

Tested against "dropsite" from QtBase widget examples forced into xcb
mode using dolphin as a source.


(cherry picked from commit 8a699ef1877e28927fc7227742d254deed69d9e9)

M  +4    -0    src/xwl/drag_wl.cpp

https://invent.kde.org/plasma/kwin/commit/297d88b10b5359796a0ee260e9484876bd42faa3
Comment 9 David Edmundson 2021-05-24 14:43:29 UTC
There's a bit more left to fix, reopening
Comment 10 David Edmundson 2021-05-24 14:46:54 UTC
Second bug is, we stop XVisit when wayland says the drag ends, which in theory is after the drop event gets sent to the client.

#0  KWin::Xwl::Xvisit::doFinish() (this=0x55555625f6e0)
    at /home/david/projects/kde5/src/kde/workspace/kwin/src/xwl/drag_wl.cpp:444
#1  0x000055555559197e in KWin::Xwl::Xvisit::leave() (this=0x55555625f6e0)
    at /home/david/projects/kde5/src/kde/workspace/kwin/src/xwl/drag_wl.cpp:265
#2  0x0000555555591b9e in KWin::Xwl::WlToXDrag::end() (this=0x5555560d53a0)
    at /home/david/projects/kde5/src/kde/workspace/kwin/src/xwl/drag_wl.cpp:91
#3  0x000055555558e53a in KWin::Xwl::Dnd::endDrag() (this=0x555555f28760)
    at /home/david/projects/kde5/src/kde/workspace/kwin/src/xwl/dnd.cpp:203
#4  0x000055555558fd01 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (KWin::Xwl::Dnd::*)()>::call(void (KWin::Xwl::Dnd::*)(), KWin::Xwl::Dnd*, void**)
    (f=(void (KWin::Xwl::Dnd::*)(KWin::Xwl::Dnd * const)) 0x55555558e4e0 <KWin::Xwl::Dnd::endDrag()>, o=0x555555f28760, arg=0x7fffffffc0c0) at /opt/qt5/include/QtCore/qobjectdefs_impl.h:152
#5  0x000055555558fc68 in QtPrivate::FunctionPointer<void (KWin::Xwl::Dnd::*)()>::call<QtPrivate::List<>, void>(void (KWin::Xwl::Dnd::*)(), KWin::Xwl::Dnd*, void**)
    (f=(void (KWin::Xwl::Dnd::*)(KWin::Xwl::Dnd * const)) 0x55555558e4e0 <KWin::Xwl::Dnd::endDrag()>, o=0x555555f28760, arg=0x7fffffffc0c0) at /opt/qt5/include/QtCore/qobjectdefs_impl.h:185
#6  0x000055555558fb95 in QtPrivate::QSlotObject<void (KWin::Xwl::Dnd::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*)
    (which=1, this_=0x555555f251d0, r=0x555555f28760, a=0x7fffffffc0c0, ret=0x0)
    at /opt/qt5/include/QtCore/qobjectdefs_impl.h:418
#7  0x00007ffff43e696d in QtPrivate::QSlotObjectBase::call(QObject*, void**)
    (a=0x7fffffffc0c0, r=0x555555f28760, this=0x555555f251d0)
    at ../../include/QtCore/../../../../../src/Qt5/qtbase/src/corelib/kernel/qobjectdefs_impl.h:398
#8  doActivate<false>(QObject*, int, void**) (sender=0x5555556bb810, signal_index=13, argv=0x7fffffffc0c0)
    at /home/david/projects/kde5/src/Qt5/qtbase/src/corelib/kernel/qobject.cpp:3886
#9  0x00007ffff43ddd6b in QMetaObject::activate(QObject*, QMetaObject const*, int, void**)
    (sender=<optimized out>, m=<optimized out>, local_signal_index=<optimized out>, argv=<optimized out>)
    at /home/david/projects/kde5/src/Qt5/qtbase/src/corelib/kernel/qobject.cpp:3946
#10 0x00007ffff4f514d8 in KWaylandServer::SeatInterface::dragEnded() (this=0x5555556bb810)
    at src/server/KWaylandServer_autogen/EWIEGA46WW/moc_seat_interface.cpp:420
#11 0x00007ffff4fbf1ae in KWaylandServer::SeatInterfacePrivate::endDrag(unsigned int) (this=
    0x555555709520, serial=27)
#12 0x00007ffff4fc21b3 in KWaylandServer::SeatInterface::notifyPointerButton(unsigned int, KWaylandServer::PointerButtonState) (this=0x5555556bb810, button=272, state=KWaylandServer::PointerButtonState::Released)
    at /home/david/projects/kde5/src/kde/workspace/kwayland-server/src/server/seat_interface.cpp:756
#13 0x00007ffff7890362 in KWin::DragAndDropInputFilter::pointerEvent(QMouseEvent*, unsigned int)
    (this=0x555555a0e460, event=0x7fffffffc938, nativeButton=272)
    at /home/david/projects/kde5/src/kde/workspace/kwin/src/input.cpp:1956


But because the drop event goes through KWayland::Client it is obviously async, but delivery of the end isnt. We either need to send both things through kwayland::client or none.
Comment 11 David Edmundson 2021-06-12 12:42:53 UTC
The above issue should now be fixed. This is currently only in master/5.23. I will backport sometime
Comment 12 Nate Graham 2021-06-12 14:46:23 UTC
Then it needs to be marked as RESOLVED :)
Comment 13 David Edmundson 2021-06-12 21:22:24 UTC
I said it fixes what was mentioned in the comment above, not the whole bug. I think there are still some issues left.
Comment 14 Nate Graham 2021-06-14 15:50:49 UTC
Yeah you're right, there are still unresolved cases. Dragging a file form Dolphin (Wayland) to Discord (XWayland), for example.
Comment 15 Bug Janitor Service 2021-09-02 09:23:45 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/1362
Comment 16 David Redondo 2021-09-02 09:26:53 UTC
Git commit c562a5c04fed1cad1c47cb59f57a99513d5ff9dc by David Redondo.
Committed on 02/09/2021 at 09:17.
Pushed by davidre into branch 'master'.

DragWlToX: Do not send position before enter

According to the spec, enter has to be send before position.
Sending position first seems to confuse clients, before this
change X windows only seemed to get data when the pointer left and
entered them for a second time. Now it works straight away.

M  +1    -1    src/xwl/drag_wl.cpp

https://invent.kde.org/plasma/kwin/commit/c562a5c04fed1cad1c47cb59f57a99513d5ff9dc