-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[X11] Fix drag & drop may stop receiving files in xwayland #122
Conversation
Observed on KDE Wayland, with Dolphin file manager. After dropping the first file, subsequent file drops will be rejected.
This adds checking data type at drag enter. If the dragged item isn't a file, show dropping as rejected. This prevents receiving unsupported data from dnd. In KDE Wayland, using XWayland, fixes dropping unsupported data result in dnd stuck.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
const auto sourceWindow = (::Window)event.xclient.data.l[0]; | ||
// Bit 0 = the source supports more than 3 data types | ||
// Check the property XdndTypeList on the source window for the list of all available types. | ||
const bool hasMoreTypes = event.xclient.data.l[1] & 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: implicit conversion 'long' -> 'bool' [readability-implicit-bool-conversion]
const bool hasMoreTypes = event.xclient.data.l[1] & 1; | |
const bool hasMoreTypes = (event.xclient.data.l[1] & 1) != 0; |
// Bit 0 = this window accept the drop | ||
event2.xclient.data.l[1] = 1; | ||
event2.xclient.data.l[4] = XdndActionCopy; | ||
if (g_dndType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: implicit conversion 'Atom' (aka 'unsigned long') -> 'bool' [readability-implicit-bool-conversion]
if (g_dndType) { | |
if (g_dndType != 0u) { |
// Save the X11 window from where this XdndDrop message came | ||
// from, so then we can send a XdndFinished later. | ||
g_dndSource = (::Window)event.xclient.data.l[0]; | ||
if (g_dndType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: implicit conversion 'Atom' (aka 'unsigned long') -> 'bool' [readability-implicit-bool-conversion]
if (g_dndType) { | |
if (g_dndType != 0u) { |
|
||
// Ask for the XdndSelection, we're going to receive the | ||
// dropped items in the SelectionNotify. | ||
XConvertSelection(m_display, XdndSelection, g_dndType, XdndSelection, m_window, time); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "XConvertSelection" is directly included [misc-include-cleaner]
XConvertSelection(m_display, XdndSelection, g_dndType, XdndSelection, m_window, time);
^
Hi @56789a1987, thanks for these patches, sorry that I cannot test this (I don't have a KDE desktop at hand), but just in case, the beta branch contains several changes in the DnD implementation, could you please test that branch? (and probably patch/target this PR to the beta): |
Tested the beta branch with Applying #121 fixes receiving the same file issue. Other issues: If an unsupported type (such as text) is dropped, the drop zone remains highlighted. |
Thanks @56789a1987 for the patch, I've just included 1861e3f in |
Fix 2 drag & drop issues observed on KDE Wayland, using XWayland.
Changed
XdndFinished
event to be sent to the source window.If send it to the root window, after dropping the first file, subsequent files can't be dropped.
Added handling
XdndEnter
event to check data type.If the dragged item isn't a file, then reject dropping. This gives visual cursor feedback and prevents the drop event.
Possible fix for: When an unsupported data type is dropped to the window, subsequent files can't be dropped.
Feel free to pick only the first commit. The first issue is more problematic, and the fix doesn't require too many changes.
I agree that my contributions are licensed under the MIT License.