Skip to content

fix(window): only record activatedBy from the declared opener - #137

Merged
PapyElGringo merged 1 commit into
mainfrom
fix/activation-declared-opener
Oct 14, 2026
Merged

PapyElGringo merged 1 commit into
mainfrom
fix/activation-declared-opener

Conversation

@PapyElGringo

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #128. Opening Firefox and Zen Browser in quick succession made a Zen window attach as a dialog of Firefox, so closing Firefox cascaded a close into Zen and left its other window unresponsive.

Root cause

The compositor's xdg_activation_v1 handler recorded activatedBy from the token's declared surface, but when the token declared none it fell back to the currently keyboard-focused surface (src/embedder/wayland/xdg.rs):

let requesting_surface = token_data
    .surface
    .clone()
    .or_else(|| focused_surface.clone());

For a programmatic window (a browser restoring its session) that turns activatedBy into "whatever was focused". The shell then takes the further-opening branch (dialogOwnerFromRelation: client parent → activatedBy → provenance → process sibling) and, since activatedBy was Firefox's window, attaches the Zen window as a dialog of Firefox — even though its pid/cgroup says it belongs to the Zen tile.

Fix

Record activatedBy only from the token's declared surface. A token with no declared opener records no relation, so the window is matched normally (its own app's tile) instead of becoming a dialog of the focused app.

  • src/embedder/wayland/xdg.rs: drop the keyboard-focus fallback (and the now-unused import).
  • src/embedder/meta_window_state/meta_window.rs: field/patch docs state the relation is the client-declared opener only.
  • docs/specifications/matching_algorithm.md: document the behavior and note that if it proves to drop useful same-application hints, the fallback should be reinstated scoped to the focused surface of the same application (not unconditionally).

No change to the matching algorithm's precedence, so same-app multi-tile dialog ownership is untouched.

Verification

  • cargo check — clean (no new warnings).
  • cargo test — 216 passed.
  • cargo fmt --check — clean.

Refs #128.

`xdg_activation_v1` `request_activation` fell back to the keyboard-focused
surface when the token declared no requesting surface. For programmatic
windows (e.g. a browser restoring its session) that recorded whatever was
focused as `activatedBy`, so the shell attached the window as a dialog of an
unrelated tile. Opening Firefox and Zen Browser together made a Zen window a
dialog of Firefox; closing Firefox then cascaded a close into Zen (#128
follow-up).

Record the relation only from the token's declared surface. A token with no
declared opener now records no relation and the window is matched normally.
Update the field/patch docs and document the decision — plus the
same-application-scoped fallback to reinstate if it proves to lose useful
hints — in the matching algorithm spec.

Refs #128.
@PapyElGringo
PapyElGringo merged commit f9e70ff into main Oct 14, 2026
2 checks passed
@PapyElGringo
PapyElGringo deleted the fix/activation-declared-opener branch October 14, 2026 08:07
@PapyElGringo PapyElGringo mentioned this pull request Oct 14, 2026
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.

1 participant