Closed Bug 1701877 Opened 3 years ago Closed 3 years ago

[Wayland/Sway] popups with 2 axis constraints close unexpectedly

Categories

(Core :: Widget: Gtk, defect)

Firefox 87
defect

Tracking

()

RESOLVED DUPLICATE of bug 1661516

People

(Reporter: rpigott, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0

Steps to reproduce:

$ pacman -Q firefox wlroots-git sway-git
firefox 87.0-1
wlroots-git 0.12.0.r397.ga2535b80-1
sway-git r6651.1d62d6bf-1

In Firefox 87, with Wayland and WebRender, popups with 2 axis constraints close unexpectedly.

  1. Visit any page, e.g. example.com
  2. Maximize or fullscreen the firefox window such that a right-click menu popup may be constrained in both the x and y directions.
  3. Click (press and rapidly release) the right mouse button in the bottom right corner of the page. Do not move the mouse cursor while the button is held.

Actual results:

The popup menu is immediately closed and the bottom-most option is selected.

Firefox chooses to set_constraint_adjustment(60) in the xdg_positioner which forbids slides and allows reflections in the x and y directions. When used in X (i3), the popup menu instead slides in the x direction to remain in the visible area. So there is an (intentional?) behavior difference between Wayland and X here.

There is no issue if only the x or y direction is constrained, and the popup location is correctly reflected about the anchor. Also, there is no issue if you hold the right mouse button and move the cursor into the (correctly x-y reflected) popup before releasing.

There is a possible wlroots bug here, but based on the protocol messages alone sway appears to me to be doing the right thing. I tried testing on Weston, but it doesn't implement constraints. I haven't tested on KDE or GNOME.

Expected results:

The popup should remain open, with the x and y directions reflected.

The Bugbug bot thinks this bug should belong to the 'Core::Widget: Gtk' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → Widget: Gtk
Product: Firefox → Core

It turns out this bug is timing related. If the click is very rapid, the issue will not appear – you can use swaymsg seat - cursor press BTN_RIGHT && swaymsg seat - cursor release BTN_RIGHT to simulate this on sway.

Also, if you hold the button and close the context menu by switching focus to another window, no spurious selection is made.

Finally, this

there is no issue if you hold the right mouse button and move the cursor into the (correctly x-y reflected) popup before releasing.

Isn't quite right. The release of the right mouse button still makes a selection when it shouldn't.

The release of the right mouse button still makes a selection when it shouldn't.

Nevermind, I was right the first time. It seems the release of the initial right mouse button is supposed to make a selection normally. In which case this could just be a small misplacement of the popup putting the cursor inside the bottom part of the menu. If click/release is rapid enough the release comes before firefox remakes the popup (FF always destroys and re-creates constrained popups).

One more update:

If you maximize the firefox window and move the cursor as far right as possible, until it is against the boundary of the screen (and still within the maximized firefox window) and right click, firefox submits an invalid anchor rect.

e.g. on my 1920x1080 screen, the x coord of this anchor rect is 1921:

xdg_positioner@95.set_anchor_rect(1921, 1055, 1, 1)

According to xdg_shell, the anchor rect should not extend outside the window boundary:

xdg_shell>xdg_positioner>set_anchor_rect:
[...]
When the xdg_positioner object is used to position a child surface, the
anchor rectangle may not extend outside the window geometry of the
positioned child's parent surface.

In this case, sway never maps the requested popup. Anyway it seems the offset of the anchor_rect from the cursor position is also the probable cause of this issue. When the context menu popup is constrained, wlroots inverts the anchor and gravity about the origin, but since the anchor rect is still below-right of the cursor, the popup appears under the cursor and an option is selected when the cursor is released.

Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.