Closed Bug 2090734 Opened 17 days ago Closed 6 days ago

[Wayland] Windows restored at startup demand attention on GNOME

Categories

(Core :: Widget: Gtk, defect)

defect

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: mmitar, Assigned: mmitar)

References

Details

Attachments

(1 external file, 1 obsolete file)

With Wayland session management (xdg_session_manager_v1, as in mutter 51) and "Open previous windows and tabs", Firefox restores its windows at startup, and the compositor places each on its workspace. On GNOME, every restored window then demands attention: GNOME Shell shows a notification for each of them, also in Do Not Disturb, keeps it in its list until the window is focused, and lists these windows first in the window switcher.

Two things ask mutter to activate the restored windows, although no event of the user is behind either, so mutter marks them as demanding attention instead:

  1. XREMain hands the activation token Firefox was launched with, for example from GNOME Shell's dock, back to GTK through DESKTOP_STARTUP_ID, and GTK 3 activates the first toplevel it maps with it. While session restore runs at startup, that is a restored window.
  2. Every restored window requests activation when it is shown, in nsWindowWaylandToplevelGtk::NativeShow(), and when session restore focuses the windows to stack them, in nsWindow::SetFocus(). Since bug 2033842, Firefox makes these requests with a token without serial and surface when none of its windows has the focus ("requesting bare token for workspace placement").

The two patches for this bug fix one each:

  1. The launch token is removed from GTK at startup and given to nsGTKToolkit, whose token nsWindow already uses for a launch passed to a running Firefox. A window restored under its saved session ID does not use it while session restore runs, and a token which no window used is dropped when session restore finishes. This also records which windows are restored from the session.
  2. A window restored from the session requests no activation while session restore runs at startup, neither when it is shown nor when it is focused.

Tested with main (ac7b5e4bc1) in a GNOME 50 session on Ubuntu 26.04, with mutter 50 patched to offer xdg_session_manager_v1, and with the patches of bug 2086801 and bug 2090663, so that logging out ends Firefox cleanly. Three windows were opened on three workspaces, the session was ended, and Firefox was launched from the dock on another workspace after logging in again:

  • main: all three restored windows demanded attention, in 2 of 2 runs.
  • main with only the second patch: one restored window demanded attention, the one GTK activated with the launch token, in 2 of 2 runs.
  • main with both patches: no restored window demanded attention, in 2 of 2 runs. The windows returned to their workspaces, and the workspace did not change.

On main, the session store restores the first saved window into the window opened for the launch (bug 2090730), so every window is restored under its saved ID. With both patches, no window then uses the launch token, nothing is activated, and the windows stay where the compositor placed them. Bug 1980162 reports that Firefox does not use the startup token on KWin. These patches change how Firefox uses it at startup, but I could not test KWin.

See Also: → 2033842, 2064100, 1980162, 2090730

At startup, XREMain hands the activation token Firefox was launched with
back to GTK through DESKTOP_STARTUP_ID, and GTK 3 activates the first
toplevel it maps with it. While session restore runs at startup, that is a
restored window, which the compositor places on its own workspace. mutter
does not activate it, and marks it as demanding attention instead.

The token is now removed from GTK at startup and given to nsGTKToolkit,
whose token nsWindow already uses for a launch passed to a running Firefox.
While session restore runs, a window restored under its saved session ID
does not use it. A token which no window used, because every window was
restored, is dropped when session restore finishes, so that a window
opened later transfers the focus to itself as usual.

Assignee: nobody → mmitar
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

A window shown while session restore runs at startup requests activation
in NativeShow(), and session restore focuses the windows it restores, to
stack them. Since bug 2033842, Firefox makes such a request with a token
without serial and surface when none of its windows has the focus. No
event of the user is behind it, so mutter marks every restored window as
demanding attention, and GNOME Shell shows a notification for each of
them.

A window restored from the session, which the compositor places itself,
now requests no activation while session restore runs at startup, neither
when it is shown nor when session restore focuses it.

Severity: -- → S3
Attachment #9677413 - Attachment description: Bug 2090734 - [Wayland] Do not activate a restored window with the launch activation token r?stransky → Bug 2090734 - [Wayland] Do not activate windows restored at startup r?stransky
Attachment #9677414 - Attachment is obsolete: true
Status: ASSIGNED → RESOLVED
Closed: 6 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: