Closed Bug 1895036 Opened 6 months ago Closed 6 months ago

[wayland] XULPopupElement::GetOuterScreenRect returns location { x: 0, y: 0 } for unanchored arrow panel

Categories

(Core :: Widget: Gtk, defect)

defect

Tracking

()

RESOLVED INVALID

People

(Reporter: nordzilla, Unassigned)

References

Details

Attachments

(1 file)

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

  1. Build and run Firefox on Linux using Wayland export MOZ_ENABLE_WAYLAND=1.

  2. Open about:support and confirm that the Window Protocol row says wayland.

  3. Open the Browser Toolbox and Disable Popup Auto-Hide.

  4. Navigate to any web page, e.g. https://es.wikipedia.org.

  5. Select some text on the page and open the right-click content context menu.

  6. Click the context-menu item that says "Translate Selection to {language}".

  7. Wait for the panel to open and complete its translation.

  8. Use the Browser Toolbox to select the open panel and navigate to the <panel id="select-translations-panel"> element.

  9. Right click the <panel id="select-translations-panel"> element in the Browser Toolbox and click "Use in Console".

  10. When the temp0 variable appears in the console, run temp0.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 }
Flags: needinfo?(emilio)

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.

Flags: needinfo?(emilio) → needinfo?(stransky)

: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.

Flags: needinfo?(emilio)

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.

Flags: needinfo?(emilio)
See Also: → 1894575

(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 to getBoundingClientRect() 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.

Flags: needinfo?(stransky)

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.

Status: NEW → RESOLVED
Closed: 6 months ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: