Skip to content

[GTK] Anchor Wayland display coordinates to the monitor of the window - #3541

Open
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:wayland-monitor-coordinates
Open

vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:wayland-monitor-coordinates

Conversation

@vogella

@vogella vogella commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

On Wayland a client is never told where its window is, so SWT returned window relative display coordinates while Monitor geometry stayed global. Anything that clips a location against a monitor was therefore mixing two coordinate spaces, which the JFace information controls do: on a multi-monitor layout whose client areas do not start near y=0, every candidate position is rejected, so javadoc hovers came up empty and the content assist javadoc popup opened on a different monitor.

Wayland does tell us which monitor a surface is on, so display coordinates are now anchored to that monitor origin and the offset is removed again when a window or menu is positioned. A whole shell tree uses the monitor of its root toplevel as the one anchor, since child shells are positioned relative to their parent and a hidden or edge-straddling popup reports no or a different monitor of its own. Display.getCursorLocation() is anchored the same way, since callers compare it against Control.toDisplay().

Fixes #3539
Fixes #538

The reporter of #3539 confirmed both the empty hovers and the misplaced content assist popup are gone on their three monitor setup. #538 is the same root cause reported from several setups, all of them with a second monitor whose top edge is not aligned with the primary, and all of them worked around by aligning the monitors. The window position within its monitor is still unknown, but popups are placed relative to their parent and unaffected by that. X11 and GTK4 are unchanged.

The first commit is the independent size clamp from #3590 and goes away once that is merged.

@vogella
vogella requested a review from akurtakov August 26, 2026 16:37
@vogella

vogella commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

@akurtakov in case you have time, please review, its in two commits to separate the two different changes, the first one is a protection against bad callers, the second the fix for the issue.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Anchors GTK3 Wayland coordinates to monitor origins and prevents invalid negative shell allocations.

Changes:

  • Aligns shell, control, cursor, and menu coordinates with monitor geometry.
  • Converts display coordinates back before native positioning.
  • Clamps shell content allocations to non-negative sizes.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
Shell.java Anchors shell coordinates and hardens allocation sizing.
Menu.java Converts popup positions to shell-relative coordinates.
Display.java Anchors cursor coordinates to a monitor.
Control.java Adds monitor-aware coordinate conversion.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java Outdated
Comment thread bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java Outdated
@vogella
vogella force-pushed the wayland-monitor-coordinates branch from fdfe5fb to 11e33fc Compare August 26, 2026 16:59
@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Test Results

  212 files  ± 0    212 suites  ±0   30m 32s ⏱️ + 1m 9s
4 967 tests + 2  4 940 ✅ +2   27 💤 ± 0  0 ❌ ±0 
7 210 runs  +12  7 009 ✅ +2  201 💤 +10  0 ❌ ±0 

Results for commit 4b6d43a. ± Comparison against base commit 2fb03ab.

♻️ This comment has been updated with latest results.

@vogella
vogella force-pushed the wayland-monitor-coordinates branch from c9af240 to cae94f1 Compare August 26, 2026 18:22
@akurtakov
akurtakov force-pushed the wayland-monitor-coordinates branch from cae94f1 to 14721d1 Compare August 31, 2026 21:07
@vogella
vogella force-pushed the wayland-monitor-coordinates branch 2 times, most recently from 785e864 to 02d3bf8 Compare September 15, 2026 13:27
@akurtakov

Copy link
Copy Markdown
Member

Needs manual rebase.

Wayland never tells a client where its window is, so gdk_window_get_origin
returns window relative values while Monitor geometry is global. Code that
clips a location against a monitor then mixes two coordinate spaces.

The JFace information controls do exactly that. With a monitor layout whose
client areas do not start near y=0, every anchor is rejected: hovers come up
empty and the content assist javadoc popup lands on a different monitor.

Wayland does report which monitor a surface is on. Anchor display coordinates
to that origin, and remove it again when positioning a window or a menu.
Display.getCursorLocation() and the MenuDetect event get the same treatment,
since callers compare them against Control.toDisplay() and pass them to
Menu.setLocation().

A shell tree shares one anchor, the monitor of its root toplevel: child
shells are positioned relative to their parent, and a popup that is hidden
or straddles a monitor edge reports no or a different monitor of its own.

The window's position within its monitor is still unknown. Popups are placed
relative to their parent and unaffected by that remaining error.

X11 and GTK4 are unchanged.

The two tests pass on a single monitor whose origin is 0,0, so they only bite
on a multi-monitor Wayland session, but test_popupLocationRoundTrip covers the
reuse cycle that JFace performs, which is where a wrong anchor shows up. Both
are GTK3 only, since GTK4 toDisplay() is still shell relative.

Fixes eclipse-platform#3539
Fixes eclipse-platform#538

Assisted-by: multiple AI agents and layers of automated tooling 🤖
@vogella
vogella force-pushed the wayland-monitor-coordinates branch from 02d3bf8 to 4b6d43a Compare September 21, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty content in popup/info windows using Wayland (Forcing X11 backend cause Eclipse IDE to hang) Tooltip popup locations are wrong (dual monitor)

3 participants