Repository navigation
wip: wayland: Add xdg-toplevel-drag support - #702
Merged
Merged
Conversation
iamsergio
force-pushed
the
pr/xdg_toplevel_drag
branch
from
May 1, 2026 13:28
25ed37d to
7cc7ae1
Compare
iamsergio
marked this pull request as draft
September 24, 2026 21:00
|
Can you provide any updates/ETA on this? It would be great to have better wayland integration :) |
Contributor
Author
I'm on it now |
Test with: ./bin/qtwidgets_dockwidgets -platform wayland --wayland-toplevel-drag Change-Id: Ic5043a6c66b7a9aa629d89b4b9c824140a310a83
So tst_wayland can test Config::Flag_WaylandToplevelDrag. QtWaylandCompositor doesn't implement it, and Qt's client silently falls back to a regular drag when the compositor lacks it. The attached toplevel follows the pointer during the drag and, like desktop compositors do, isn't picked as the drag target. --no-toplevel-drag disables it, to test the fallback. Change-Id: I9f3d6a3bf77096a52de1ec249e15c54cbd1d7732
The dragging state was picked when creating the DragController. QtQuick's Platform creates it, so the flag, which can only be set after that, had no effect with QtQuick. Neither did it after changing the flags at runtime. Also shares the QDrag code with pixmap drags, so toplevel drags get the fix from PR #766 too: a drop accepted by another application left the DragController stuck in its dragging state. Change-Id: If84a74e324794f6b2887c2c4656560f6b182b53e
Each frontend now runs the tests in both drag modes. KDDW_TEST_DRAG_MODE=pixmap or toplevel runs only one. With xdg-toplevel-drag a tab becomes a floating window as soon as its drag starts, so tests that release it outside KDDW expect it to stay floating, and tst_dragDockWidgetOntoAnother drops onto where dock2 is after dock1 left. tst_dragTabToEmptySpaceKeepsItDocked is now tst_dragTabToEmptySpace. Change-Id: I8daa259a22b9f422b3ccf8e784c615445a6eeed5
Only tst_cancelledTabReorderDragResetsTabBar stays QtWidgets only, as QtQuick can't reorder tabs by dragging them. tst_tabDroppedOntoForeignWindowResetsTabBar drags the tab off instead there. QtQuick's TitleBar and TabBar views aren't the items that are shown, so the tests get positions from their QML items. DropAcceptingWindow is now a QRasterWindow, as QtQuick doesn't create a QApplication. Change-Id: I6e17600b748570a521f76f46d4e57d5f9ac193b2
…inter One drags a tab out of a group on the right of the main window, the other a floating window by KDDW's title bar. Both fail: the offset given to xdg-toplevel-drag is the cursor position when the drag started, not where the window was grabbed, so the window drifts by the drag distance, and can end up not under the pointer at all. Change-Id: I23435aad0d93f409d8aa1b87c2ce687672f090b6
It was QCursor::pos() when the drag started, after the pointer already moved past the drag threshold, so dragged windows drifted by that much. And when a tab was further right than the new window is wide, the window wasn't under the pointer at all. Now it's where the window was grabbed, kept within the new window like StateDragging does. It's computed from the global press position, as Draggable::mapToWindow() doesn't account for the margins QtQuick's floating windows have. Change-Id: I5f06d8da883fddbbf85d2f6a6287c6b5c182ab55
Without it Qt silently falls back to a regular drag, but the native title bar isn't forced anymore, so floating windows can't be moved. Fails when run with KDDW_TEST_COMPOSITOR_ARGS=--no-toplevel-drag. Change-Id: I807c5085d986adb6ce840ea9a483e7e6eb895fc1
Without compositor support, Qt silently falls back to a regular drag, but the native title bar wasn't forced anymore, so floating windows couldn't be moved. Whether the compositor supports it comes from Qt's private Wayland client API. Qt supports xdg-toplevel-drag since 6.8, so with older Qt, or without Qt6WaylandClientPrivate, the code isn't built and the flag is always ignored. tst_wayland_no_toplevel_drag runs tst_wayland with the flag against a compositor without support. Change-Id: I222cf410272bbad186fd6bd470a3ee9daa24146d
With xdg-toplevel-drag the new window isn't under the pointer: the offset's y is relative to the main window, and only x is kept within the new window. Change-Id: I5a1699b251f1b36309bb1857472a1825c5cf525e
It was where the main window was pressed, so a dock widget dragged out from low in a tall window ended up above the pointer. Like StateDragging, it's now where the title bar or tab bar was pressed, kept within the new window in both directions. Dragging a floating window still keeps the pointer where it was pressed. Change-Id: Iec20183dbb1a270c62b5b24c969aa926c944f7f8
Supporting Flag_WaylandToplevelDrag links to QtWaylandClient, even for applications which only run on X11. The option allows opting out. Also checks that the private headers exist. Before Qt 6.10 the Qt6::WaylandClientPrivate target exists even if they're packaged separately and not installed. Change-Id: Ie7ae499a6ac144df080c3ee95be5fed073a8fc20
…positor Clients only destroy xdg_toplevel_drag_v1 on dnd_finished or cancelled, and QtWaylandCompositor doesn't send dnd_finished after a successful drop, so the toplevel stayed attached. The next drag would have moved it, unless it attached another one. Change-Id: Id51eca3eb8e128bb97eee7f2b18a69141c67b05c
tst_toplevelDragNeedsSupport looked at KDDW_TEST_COMPOSITOR_ARGS, which isn't set when running 'kddw_test_compositor --no-toplevel-drag -- tst_wayland', so it failed there. Now it checks the registry. Change-Id: I3233f91ca02c47b242a88aa328793dfd6fe485a0
Like StateDragging::onEntry() does. Both pixmap and toplevel drags use the draggable right away. Change-Id: I540942fad172b0ffd9486640d47771027a59081b
iamsergio
force-pushed
the
pr/xdg_toplevel_drag
branch
from
November 16, 2026 15:43
7cc7ae1 to
b9c095a
Compare
iamsergio
marked this pull request as ready for review
November 16, 2026 15:43
Contributor
Author
|
@septatrix give it a go |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test with:
./bin/qtwidgets_dockwidgets -platform wayland --wayland-toplevel-drag
Known bugs: