Repository navigation
feat(linux): set window levels on X11 and report window stacking and placement - #583
Merged
Merged
Conversation
…placement in Env SetWindowLevel now asks an X11 window manager for _NET_WM_STATE_ABOVE or _NET_WM_STATE_BELOW through EWMH's client message, again each time the window maps, as GTK 4 has no keep-above. Env.CanSetWindowLevel and Env.CanPlaceWindows, with desktop.CanSetWindowLevel and desktop.CanPlaceWindows, tell an app whether the level and SetWindowFrame's position take effect: both on macOS and Windows, only the level on Linux under X11, neither on Wayland or for an embedded view. Fixes #573
… the surface's own Linux and Windows now report CanSetWindowLevel and CanPlaceWindows false for the app's own hidden surface and a tray icon's, as macOS does, so the app function's scope gets the same answer everywhere. Narrow the capability's comments to desktop windows, since an Android overlay is placed by mobile and reports false, and record in the roadmap that TSX's nsgo/desktop does not report the capabilities yet.
…11 level was checked under SetWindowFrame moves an Android overlay (Overlays.java keeps it on the screen), so CanPlaceWindows is true for one on Android and in nsgotest, rather than false as the docs said. The roadmap now says the X11 level was checked under Xvfb with no window manager, not only built.
8 tasks done
5 of 7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #573.
SetWindowLevelnow works on Linux under X11: GTK 4 has no keep-above, so NSGo asks the window manager for_NET_WM_STATE_ABOVEor_NET_WM_STATE_BELOWthrough the EWMH client message, and sends the request again each time the window maps (the GtkWindow "map" signal), so a level set while the window is hidden still takes effect.Env.CanSetWindowLevelandEnv.CanPlaceWindows, withdesktop.CanSetWindowLevelanddesktop.CanPlaceWindows, tell an app whether the window level andSetWindowFrame's position take effect:Docs (
docs/architecture/services.md, public components docs in English and Chinese), the roadmap (TSX'snsgo/desktopdoes not report the capabilities yet) and the changelog are updated.Targets
GDK_BACKEND=x11, where no window manager answers the requests; not yet checked under GNOME on Xorg or KDE.check -target all), not run.core/desktop/nsgotest: tests run on Ubuntu.CanPlaceWindows; compiled and vetted only, checked throughnsgotest.Screenshots
None: no visual change. This sets window-manager stacking hints and reports capabilities; it does not change how anything is drawn.
Verification
All commands were run from the branch's worktree.
ubuild mise exec [email protected] -- go tool nsgo check -target linux_x64,linux_arm64,windows_x64,windows_arm64,web,android_arm64: all vetted, exit 0.rbuild mise exec [email protected] -- go tool nsgo check -target all: catalogs, vet, dev client and every listed target (macOS arm64/x64, Windows, Linux, iOS and simulator, tvOS and simulator, watchOS and simulator, android_arm64, web) vetted, exit 0.ubuild ... nsgo check -target linux_x64,windows_x64: exit 0.ubuild ... nsgo test ./core: 663 passed, 0 failed. This includes the newTestEnvironmentWindowCapabilitiesand the existingTestWindowFrameAndLevel.ubuild ... nsgo test ./desktop: 2 passed, including the newTestWindowLevelAndPlacementFollowTheEnvironment.ubuild ... nsgo test ./nsgotest: 70 passed.ubuild ... nsgo test ./internal/driver: 133 passed.ubuild ... nsgo test ./internal/moduletest(layering, skill and docs checks): 9 passed.ubuild env GDK_BACKEND=x11 xvfb-run -a mise exec [email protected] -- go tool nsgo test ./internal/platform/linux -- -run TestWindowLevelAsksTheWindowManager -count=3: 3 passed.ubuild xvfb-run -a ... -run TestWindowLevelAsksTheWindowManageron the default backend (Wayland on that host): passed. On Wayland it checks that both capabilities are false.ubuild env GDK_BACKEND=x11 xvfb-run -a ... nsgo test ./internal/platform/linux: 133 passed, 0 failed, 1 skipped.notify::mappedsignal, which never fired when the window was hidden and shown again. It now uses the GtkWindow "map" signal.After review fixes (second commit: capabilities false for the app's own surface and tray scope on Linux and Windows):
go tool nsgo check -target windows_x64,windows_arm64and-target windows_x64,linux_x64on Ubuntu: passed. This vets the Windows code and test files; they were only compiled.go tool nsgo test ./core/...(663 tests) and./desktop/...: passed../internal/platform/linux,-run 'WindowLevel|AppSurfaceHasNoWindowLevel': both tests passed. These runs were on the default backend, so they do not prove anything about X11: with the Linux fix temporarily reverted,TestAppSurfaceHasNoWindowLevelstill passed becausedrawsOnX11()is false there, andTestWindowLevelAsksTheWindowManagermost likely took its early return for a non-X11 window. Both need a real X11 session (GDK_BACKEND=x11) to be meaningful.gofmt -lis clean on every changed file.After the review fix (third commit: an Android overlay reports
CanPlaceWindowstrue, asSetWindowFrameplaces it; docs and roadmap corrected):rbuild mise exec [email protected] -- go tool nsgo check -target all: every target vetted, exit 0.ubuild ... nsgo check -target linux_x64,linux_arm64,windows_x64,windows_arm64,android_arm64,web: exit 0. The Android change is compiled and vetted only, not run on a device.ubuild ... nsgo test ./nsgotest(70 passed, includingTestOverlayMovesHidesAndCloses, which now checks the overlay's content seesCanPlaceWindows),./desktop(2),./core(663),./internal/moduletest(9).ubuild env GDK_BACKEND=x11 xvfb-run -a ... nsgo test ./internal/platform/linux -- -run 'WindowLevel|AppSurfaceHasNoWindowLevel' -count=2: 4 passed.Failures not caused by this change:
TestTheWindowClassIsTheAppIDcrashes with SIGSEGV inXGetClassHint; this branch does not touch it.nsgo test .on Ubuntu fails GUI tests in other packages for lack of a display.Checklist