[Wayland] Tab drag opens a new window with multiple seats
Categories
(Core :: Widget: Gtk, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox162 | --- | fixed |
People
(Reporter: gabriel, Assigned: sinker)
References
(Blocks 2 open bugs)
Details
(Keywords: helpwanted)
Attachments
(2 files, 1 external file)
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:156.0) Gecko/20100101 Firefox/156.0
Steps to reproduce
- Start a Hyprland 0.56.2 session with the Cua Hyprland plugin loaded (https://github.com/trycua/cua, libs/cua-driver/hyprland-plugin). The plugin adds two
wl_seatglobals, "Cua-Agent" and "Cua-Agent-2", after Hyprland's own seat, sowayland-infolists threewl_seatglobals. The physical mouse and keyboard stay on Hyprland's seat, which is advertised first - Start Firefox with a fresh profile:
firefox --new-instance --profile "$(mktemp -d)" - Open at least two tabs
- Press the mouse button on a tab and drag it a short distance sideways along the tab strip
Also reproduces in Troubleshoot Mode (--safe-mode) with a fresh profile.
Actual results
As soon as the pointer moves, the tab is detached into a new browser window, as if it had been dragged outside the tab strip. The tab can never be reordered within the strip.
The drag log (MOZ_LOG=WidgetDrag:5,WidgetDragService:5, attached) shows the session failing immediately, before gtk_drag_begin is reached:
nsDragSessionSource::InvokeDragSession
InvokeDragSession | rv: NS_ERROR_FAILURE | Ending drag session due to internal error
WAYLAND_DEBUG=1 shows no wl_data_device.start_drag. Same session: GTK4 (Nautilus) and Chromium drag tabs and files fine. Tab drag works when only one wl_seat is visible to the browser.
Expected results
The tab is reordered within the tab strip, as it is when the compositor advertises only one wl_seat.
| Reporter | ||
Comment 1•1 month ago
|
||
| Reporter | ||
Comment 2•1 month ago
|
||
The "InvokeDragSessionImpl() originGdkWindow" log line never appears, so the early return on a missing origin GdkWindow is the likely failure point:
- GdkGetPointer() (widget/gtk/WidgetUtilsGtk.cpp) calls the deprecated gdk_device_manager_get_client_pointer().
- GTK3's Wayland backend returns the master pointer of the first entry in its device list, but prepends each seat's devices as they are added. With several seats this is the pointer of the LAST advertised seat, not the one the user is using.
- nsDragSessionSource::InvokeDragSessionImpl() calls
gdk_device_get_window_at_position()on that pointer, getsNULL, and returnsNS_ERROR_FAILURE. Nowl_data_device.start_dragis sent (confirmed with WAYLAND_DEBUG=1), and the tabbrowser falls back to detaching the tab.
Checks:
- Reproduced with stock Firefox 156.0 (fresh profile, also in Troubleshoot Mode) and with Zen (Gecko-based).
- Same session: GTK4 (Nautilus) and Chromium drag tabs and files fine.
- Zen nested in a single-seat compositor (cage): tab drag works.
- Zen with an
LD_PRELOADshim that hides everywl_seatafter the first from allwl_registrylisteners (GTK's and Gecko's): tab drag works.
Suggested fix: take the pointer from GTK's default seat, which is the first seat added, e.g. gdk_seat_get_pointer(gdk_display_get_default_seat(display)).
Better still, use the device that delivered the triggering button press.
Separately, nsWaylandDisplay::SetSeat() overwrites mSeat for every wl_seat announced, so Gecko's own Wayland code also ends up on the last seat.
Possibly related: bug 1719036 (multiseat paste uses the wrong seat), bug 1978847 (same tab drag symptom on a multi-seat sway setup, closed by
the reporter with a different explanation).
Comment 3•1 month ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Widget: Gtk' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
| Assignee | ||
Updated•1 month ago
|
Updated•28 days ago
|
Comment 4•28 days ago
|
||
It's a bit corner case so patches welcome - I may not work on that.
| Assignee | ||
Comment 5•21 days ago
|
||
On Wayland, nsDragSessionSource::InvokeDragSessionImpl() finds the origin
window with gdk_device_get_window_at_position() on GdkGetPointer(). That
returns the window the device's seat last entered. GdkGetPointer() returns
gdk_device_manager_get_client_pointer(), which GTK picks from the seat that
added a device most recently (gdk_wayland_device_manager_get_client_pointer()).
When the compositor announces more than one wl_seat, that is usually not the
seat the user is dragging with. If that seat's pointer is not over a Firefox
window, the lookup returns NULL and the drag is aborted.
Take the device from the saved button press (GetLastPointerDownEvent()) when
there is one. That is the device gtk_drag_begin_with_coordinates() drags with,
since it gets the device from the same event, and its pointer is over the
window that was pressed.
Callers with no press to go by have the same wrong-seat problem, so
GdkGetPointer() now returns the pointer of gdk_display_get_default_seat(),
which on Wayland is the first seat announced. On X11, GTK's default seat is
the seat of the X client pointer, so nothing changes there. The seat API is
GTK 3.20, so it is looked up with dlsym() and the old call stays as the
fallback.
Updated•21 days ago
|
Comment 7•12 days ago
|
||
| bugherder | ||
Description
•