Skip to content

service/tray: forward Wayland activation tokens on primary clicks - #1166

Open
domenkozar wants to merge 1 commit into
quickshell-mirror:masterfrom
domenkozar:fix/tray-activation-token
Open

domenkozar wants to merge 1 commit into
quickshell-mirror:masterfrom
domenkozar:fix/tray-activation-token

Conversation

@domenkozar

@domenkozar domenkozar commented Sep 20, 2026 •

Copy link
Copy Markdown

Tray clicks currently send only Activate(0, 0). A native Wayland application cannot use the panel's input event to request focus, so compositors such as niri may leave its existing window unfocused.

Request a token through QWaylandWindow::requestXdgActivationToken() using Qt's last input serial and window, then deliver it with ProvideXdgActivationToken before calling Activate. Implement the corresponding layer-shell override so this works for panels as well as ordinary Qt windows. The activation protocol implementation belongs to layer-shell, and the tray service uses Qt's window API.

The existing SystemTrayItem.activate() QML API is unchanged. Missing input context, unavailable activation support, a one-second timeout, and applications that reject the optional token method all preserve ordinary activation. Ignore callbacks after the tray item disappears. Allow only one pending tray token request per window, so a late response cannot be reused for another tray click; overlapping clicks use ordinary activation.

Validation:

  • Full debug build with precompiled headers disabled and tests enabled; all 9 tests pass with QT_QPA_PLATFORM=wayland. The popup-positioning test fails with Qt's offscreen/minimal backends.
  • Formatting and clang-tidy with the repository's tidyfox plugin pass for the changed code.
  • Tray module builds with Wayland disabled; configuration also succeeds with layer-shell disabled.
  • Temporary lifecycle harness checks token delivery, single completion, timeout, late responses, tray context and window destruction, and a callback that destroys its window.
  • Live niri layer-shell pointer clicks: both token-aware and legacy mock tray items receive a nonempty token followed by Activate; the legacy item rejects the unsupported token method and still activates.

Prepared with AI assistance for human review.

@outfoxxed

Copy link
Copy Markdown
Member

Do you have a reason to avoid QWaylandWindow::requestXdgActivationToken?

@domenkozar

Copy link
Copy Markdown
Author

I used the protocol directly because Qt’s method needs support from Quickshell’s layer-shell implementation, which currently just emits an empty token.

We could add that support and then use QWaylandWindow::requestXdgActivationToken() in the tray code.

@outfoxxed

Copy link
Copy Markdown
Member

We could add that support and then use QWaylandWindow::requestXdgActivationToken() in the tray code.

Please do

@domenkozar
domenkozar force-pushed the fix/tray-activation-token branch from 8cdc568 to c98e2fb Compare September 22, 2026 00:27
@domenkozar

Copy link
Copy Markdown
Author

CI failed unrelatedly

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not use QWaylandXdgShell::activation()?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Qt doesn’t install the client headers needed for QWaylandXdgShell::activation(), which xdgshell.hpp already notes. I’ve consolidated activation support into a shared Wayland helper used by the tray and layer-shell. Is that approach acceptable, or is there an access path to Qt’s activation helper I’ve missed?

/// Primary activation action, generally triggered via a left click.
/// On Wayland, forwards an activation token from the most recent input event
/// when supported. Call directly from the input handler to preserve its context.
Q_INVOKABLE void activate();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not a helpful user level doc

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Now duplicates LayerSurface::requestXdgActivationToken

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

@outfoxxed
outfoxxed force-pushed the master branch 2 times, most recently from 72a1ce2 to 11ca60b Compare October 6, 2026 04:21
@domenkozar
domenkozar force-pushed the fix/tray-activation-token branch 2 times, most recently from f457ca9 to 0409ad6 Compare October 9, 2026 08:42
@domenkozar
domenkozar force-pushed the fix/tray-activation-token branch from 0409ad6 to 657e3fa Compare October 9, 2026 09:08
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.

2 participants