[wayland] XULPopupElement::GetOuterScreenRect returns location { x: 0, y: 0 } for unanchored arrow panel
Categories
(Core :: Widget: Gtk, defect)
Tracking
()
People
(Reporter: nordzilla, Unassigned)
References
Details
Attachments
(1 file)
3.64 MB,
image/png
|
Details |
Description
I noticed while implementing the Select Translations Panel that calling panel.getOuterScreenRect()
while using Wayland returns the { x: 0, y: 0 }
location of the panel every time, compared to X11 which returns the correct location.
Steps to Reproduce
-
Build and run Firefox on Linux using Wayland
export MOZ_ENABLE_WAYLAND=1
. -
Open
about:support
and confirm that theWindow Protocol
row sayswayland
. -
Open the Browser Toolbox and Disable Popup Auto-Hide.
-
Navigate to any web page, e.g. https://es.wikipedia.org.
-
Select some text on the page and open the right-click content context menu.
-
Click the context-menu item that says "Translate Selection to {language}".
-
Wait for the panel to open and complete its translation.
-
Use the Browser Toolbox to select the open panel and navigate to the
<panel id="select-translations-panel">
element. -
Right click the
<panel id="select-translations-panel">
element in the Browser Toolbox and click "Use in Console". -
When the
temp0
variable appears in the console, runtemp0.getOuterScreenRect()
.
Expected Behavior
The resulting DOMRect
object has the correct dimensions and location of the panel.
Actual Behavior
The resulting DOMRect
has correct dimensions, but the location is set to { x: 0, y: 0 }
DOMRect { x: 0, y: 0, width: 455, height: 447, top: 0, right: 455, bottom: 447, left: 0 }
Comment 1•6 months ago
|
||
So there are two issues. The first one which is known, is that screen coordinates on Wayland are not a thing.
That said, maybe for popups we can / should return top-level-window-relative coordinates? That's probably going to confuse less code... WDYT Martin?
Assuming it sounds reasonable, feel free to ni? me back and I can try to hack up something.
Reporter | ||
Comment 2•6 months ago
|
||
:emilio,
I just want to clarify what you mean by "top-level-window-relative coordinates."
To me that phrasing would imply that it is the coordinates relative to the Firefox window, which is already what getBoundingClientRect()
retrieves.
I don't have my Linux machine available to me right now, but I have my MacBook laptop available (regarding the screenshot).
What I would really need from getOuterScreenRect()
on Wayland is for it to tell me the position relative to the whole screen, as opposed to getBoundingClientRect()
which returns the panel position relative to the open Firefox window.
As shown in the screenshot, the y
, top
, and bottom
values differ because the Firefox window itself is not, itself, positioned at the top of the screen.
Comment 3•6 months ago
|
||
Whole-screen coordinates are just not a thing on Wayland, and that's by design, see what window.screenX
etc return. But arguably the "screen" coordinate space should be shared for popups and the top level window they belong to.
Comment 4•6 months ago
|
||
(In reply to Erik Nordin [:nordzilla] from comment #2)
What I would really need from
getOuterScreenRect()
on Wayland is for it to tell me the position relative to the whole screen, as opposed togetBoundingClientRect()
which returns the panel position relative to the open Firefox window.
Yes, getOuterScreenRect() doesn't work on Wayland. Wayland behaves like your application is placed somewhere on the workspace and its position is under control of wayland compositor. You can't place application on the workspace or get info about its position. That's one of Wayland feature and it's intended behavior.
Reporter | ||
Comment 5•6 months ago
|
||
Thank you for all of the context and help.
I've learned a lot through this investigation, and I believe that I've also found a workaround on Wayland for my use case, which is to keep my panel bounded within the Firefox window's dimensions instead of within the screen's dimensions using getOuterScreenRect()
.
I'm going to go ahead and mark this as resolved.
Description
•