Tray icon: window toggle, minimize state, and geometry are unreliable on native Wayland #748

Open
opened 2026-06-05 19:06:47 +00:00 by epicleafies · 0 comments
epicleafies commented 2026-06-05 19:06:47 +00:00 (Migrated from github.com)

Summary

The desktop tray icon and window-behavior work added in #746 behaves correctly on X11/XCB, but three behaviors do not work reliably on a native Wayland session because they rely on window information Wayland does not expose to applications. This is a platform limitation, not a regression: the obscured-detection behavior is unavailable on Wayland in Core's Qt Widgets GUI as well, for the same reason. The behaviors are correct when the app runs under XCB (including XWayland).

Parent: #513

Problem

DesktopTrayIconController ports Bitcoin Core's Qt Widgets tray logic, which
determines window state with GUIUtil::isObscured() (QApplication::widgetAt()).
The QML port uses the QWindow equivalent, QGuiApplication::topLevelAt(). On
Wayland the compositor deliberately prevents apps from inspecting other apps'
windows or global stacking, so topLevelAt() always returns the app's own
window, showMinimized() does not report a Minimized visibility, and the
compositor re-applies frame margins on show(). Each of these breaks one of the
ported behaviors.

Observed vs. expected behavior

Verified by driving the running app through each window state under both
QT_QPA_PLATFORM=xcb and QT_QPA_PLATFORM=wayland:

Behavior XCB Wayland (observed) Expected
Tray-click while window is behind another app shows window hides window (needs a second click to show) shows window
Right-click tray menu label when minimized to taskbar Show Hide Show
Window size across repeated tray hide/show cycles stable grows ~6px wider per cycle stable

Reproduction

On a native Wayland session (e.g. GNOME/COSMIC Wayland), with the tray icon
enabled in Settings → Window Behavior:

  1. Obscured toggle: raise another application's window fully over the main
    window, then single-click the tray icon. The window hides instead of coming
    to the front; a second click is required to show it.
  2. Menu label: minimize the window to the taskbar, then right-click the tray
    icon. The menu action reads Hide instead of Show.
  3. Geometry drift: repeatedly hide and show the window via the tray icon.
    The window grows wider on each cycle and controls become misaligned;
    maximizing/restoring resets it.

All three behave correctly under QT_QPA_PLATFORM=xcb.

Likely cause

  • Obscured detection: QGuiApplication::topLevelAt() returns nullptr for
    points covered by another application only under XCB. On Wayland it returns the
    app's own window, so isObscured() is always false and toggleWindow()
    takes the hide branch. This is the same limitation Core's widget GUI has on
    Wayland (widgetAt() cannot see foreign windows either) and is rooted in the
    Wayland security model — see bitcoin/bitcoin#19950.
  • Minimize label: the windowVisible Binding derives the menu label from
    appWindow.visibility. On Wayland showMinimized() leaves visibility at
    Window.Windowed rather than Window.Minimized, so the binding stays true.
  • Geometry drift: QWindow::show() after hide() does not preserve geometry
    on Wayland the way QWidget::show() does; the compositor re-adds frame margins
    each cycle. Likely the same class of Wayland windowing instability as
    bitcoin/bitcoin#33432.

Work Needed

  • Document the obscured-detection limitation in code and treat it as known/upstream;
    it cannot be solved in application code on Wayland.
  • Investigate driving the menu label and toggleWindow() minimized check from an
    explicit state tracked in onVisibilityChanged rather than relying solely on
    QWindow::visibility, so the minimized case is correct on Wayland.
  • Investigate guarding the hide/show geometry drift (e.g. restoring the saved
    size on show, or suppressing transient onWidthChanged/onHeightChanged
    writes during state transitions) and confirm it does not reintroduce the XCB
    setGeometry()/WM conflict.
  • Add a documented manual test matrix run under both XCB and Wayland, since the
    offscreen QPA backend used by the unit/functional tests cannot exercise any of
    this.

Code References

  • qml/models/desktoptrayiconcontroller.cpp
    • isObscured() / checkPoint() (uses QGuiApplication::topLevelAt())
    • toggleWindow()
    • setWindowVisible()
  • qml/pages/main.qml
    • windowVisible Binding
    • onVisibilityChanged
    • guarded Settings writes (onXChanged / onYChanged / onWidthChanged / onHeightChanged) and Component.onCompleted restore
  • #513 - parent feature (Desktop Tray and Window Behavior Settings)
  • #746 - PR introducing the tray icon
  • bitcoin/bitcoin#19950 - [Linux] Add wayland support (root cause: Wayland blocks cross-app window access; release binaries are XCB-only)
  • bitcoin/bitcoin#33432 - v30 Wayland windowing instability
## Summary The desktop tray icon and window-behavior work added in #746 behaves correctly on X11/XCB, but three behaviors do not work reliably on a native Wayland session because they rely on window information Wayland does not expose to applications. This is a platform limitation, not a regression: the obscured-detection behavior is unavailable on Wayland in Core's Qt Widgets GUI as well, for the same reason. The behaviors are correct when the app runs under XCB (including XWayland). Parent: #513 ## Problem `DesktopTrayIconController` ports Bitcoin Core's Qt Widgets tray logic, which determines window state with `GUIUtil::isObscured()` (`QApplication::widgetAt()`). The QML port uses the `QWindow` equivalent, `QGuiApplication::topLevelAt()`. On Wayland the compositor deliberately prevents apps from inspecting other apps' windows or global stacking, so `topLevelAt()` always returns the app's own window, `showMinimized()` does not report a `Minimized` visibility, and the compositor re-applies frame margins on `show()`. Each of these breaks one of the ported behaviors. ## Observed vs. expected behavior Verified by driving the running app through each window state under both `QT_QPA_PLATFORM=xcb` and `QT_QPA_PLATFORM=wayland`: | Behavior | XCB | Wayland (observed) | Expected | |---|---|---|---| | Tray-click while window is behind another app | shows window | **hides window** (needs a second click to show) | shows window | | Right-click tray menu label when minimized to taskbar | `Show` | **`Hide`** | `Show` | | Window size across repeated tray hide/show cycles | stable | **grows ~6px wider per cycle** | stable | ## Reproduction On a native Wayland session (e.g. GNOME/COSMIC Wayland), with the tray icon enabled in Settings → Window Behavior: 1. **Obscured toggle:** raise another application's window fully over the main window, then single-click the tray icon. The window hides instead of coming to the front; a second click is required to show it. 2. **Menu label:** minimize the window to the taskbar, then right-click the tray icon. The menu action reads `Hide` instead of `Show`. 3. **Geometry drift:** repeatedly hide and show the window via the tray icon. The window grows wider on each cycle and controls become misaligned; maximizing/restoring resets it. All three behave correctly under `QT_QPA_PLATFORM=xcb`. ## Likely cause - **Obscured detection:** `QGuiApplication::topLevelAt()` returns `nullptr` for points covered by another application only under XCB. On Wayland it returns the app's own window, so `isObscured()` is always `false` and `toggleWindow()` takes the hide branch. This is the same limitation Core's widget GUI has on Wayland (`widgetAt()` cannot see foreign windows either) and is rooted in the Wayland security model — see bitcoin/bitcoin#19950. - **Minimize label:** the `windowVisible` `Binding` derives the menu label from `appWindow.visibility`. On Wayland `showMinimized()` leaves `visibility` at `Window.Windowed` rather than `Window.Minimized`, so the binding stays `true`. - **Geometry drift:** `QWindow::show()` after `hide()` does not preserve geometry on Wayland the way `QWidget::show()` does; the compositor re-adds frame margins each cycle. Likely the same class of Wayland windowing instability as bitcoin/bitcoin#33432. ## Work Needed - Document the obscured-detection limitation in code and treat it as known/upstream; it cannot be solved in application code on Wayland. - Investigate driving the menu label and `toggleWindow()` minimized check from an explicit state tracked in `onVisibilityChanged` rather than relying solely on `QWindow::visibility`, so the minimized case is correct on Wayland. - Investigate guarding the hide/show geometry drift (e.g. restoring the saved size on show, or suppressing transient `onWidthChanged`/`onHeightChanged` writes during state transitions) and confirm it does not reintroduce the XCB `setGeometry()`/WM conflict. - Add a documented manual test matrix run under both XCB and Wayland, since the offscreen QPA backend used by the unit/functional tests cannot exercise any of this. ## Code References - `qml/models/desktoptrayiconcontroller.cpp` - `isObscured()` / `checkPoint()` (uses `QGuiApplication::topLevelAt()`) - `toggleWindow()` - `setWindowVisible()` - `qml/pages/main.qml` - `windowVisible` `Binding` - `onVisibilityChanged` - guarded Settings writes (`onXChanged` / `onYChanged` / `onWidthChanged` / `onHeightChanged`) and `Component.onCompleted` restore ## Related - #513 - parent feature (Desktop Tray and Window Behavior Settings) - #746 - PR introducing the tray icon - bitcoin/bitcoin#19950 - `[Linux] Add wayland support` (root cause: Wayland blocks cross-app window access; release binaries are XCB-only) - bitcoin/bitcoin#33432 - v30 Wayland windowing instability
Sign in to join this conversation.
No description provided.