Skip to content

fix(macos): Close the windows through AppWindow.Closing when the app is asked to quit (backport #26063 to 6.7) - #26097

Merged
agneszitte merged 9 commits into
unoplatform:release/stable/6.7from
ajpinedam:dev/anpi/backport-26063-6.7
Nov 6, 2026
Merged

agneszitte merged 9 commits into
unoplatform:release/stable/6.7from
ajpinedam:dev/anpi/backport-26063-6.7

Conversation

@ajpinedam

Copy link
Copy Markdown
Contributor

GitHub Issue: related to #26075, which #26063 closes on master

PR Type:

🐞 Bugfix

What changed? 🚀

Manual release/stable/6.7 backport of #26063, synced to its head bb777cabc6. It carries the same commits as the servicing/6.8 backport, #26064, and is synced again if #26063 changes.

What it fixes (same as the master PR): on macOS, Cmd+Q, the application menu's Quit and the Dock's Quit end the app without raising AppWindow.Closing or Window.Closed. Now:

  • Such a quit closes the windows the user can see as the user would, front to back: AppWindow.Closing first, which can cancel the quit, then Closed. If one window cancels, the windows asked before it are closed; it and the windows behind it stay open.
  • Once they are closed, the app exits, whatever DispatcherShutdownMode is. OnExplicitShutdown still keeps the app running after the user closes its last window, and a later Quit still ends it.
  • Hidden windows are not asked. The quit is refused while a modal panel (a file picker) or a sheet is up.
  • A logout, restart or shutdown is never refused: it ends the app without Closing or Closed, as before and as on Windows.
  • Application.Exit() now matches WinUI's FrameworkApplication::ExitImpl: it closes every window as Window.Close() does, raising Window.Closed but not AppWindow.Closing, then exits. A Closed handler that sets Handled keeps its window open, and with OnLastWindowClose that keeps the app running.
  • A Closing handler that throws logs an Error; a cancelled close and OnExplicitShutdown keeping the app running log at Debug.
  • doc/articles/features/app-close-handler.md gains a macOS section, and the manual sample Windowing/AppWindow_QuitClosesWindows covers the scenarios.

The behaviour changes and the manual test steps are in #26063.

Why not a Mergify backport: files moved for 7.0. On 6.7 the macOS host is Uno.UI.Runtime.Skia.MacOS (not Uno.UI.Runtime.MacOS), and the sample folder is Microsoft_UI_Windowing (not Microsoft/UI/Windowing), as on 6.8. The six files the fix touches are identical on release/stable/6.7 and servicing/6.8, so the commits are #26064's, cherry-picked unchanged; the net diff is line for line the same as #26064's and master's.

Same 6.8 difference, harmless here too: a closed window leaves the windows set only when it is deallocated, not when it closes. It is no longer visible, so a quit does not ask it.

Validated on this branch (macOS 27, Apple silicon): SamplesApp.Skia.Generic builds in Release, including libUnoNativeMac (with MACOSX_DEPLOYMENT_TARGET=12.0, since Xcode 27 refuses the project's 10.15 target). The library exports uno_windows_close_for_quit. The sample Windowing/AppWindow_QuitClosesWindows was run, and quits were sent as the Dock's quit request:

Case Result
Quit AppWindow.Closing → Window.Closed → exits (0)
Logout (quit carrying kAEReallyLogOut) exits (0), no Closing, no Closed

The other behaviours (cancel, front-to-back order, hidden windows, file picker, throwing handler, OnExplicitShutdown, Exit() parity) were checked on master with SamplesApp; see #26063. The 6.8 backport, which has the same code, was also validated with Studio Live, the downstream app that needs this; see #26064.

PR Checklist ✅

@ajpinedam ajpinedam self-assigned this Nov 5, 2026
@github-actions github-actions Bot added area/automation Categorizes an issue or PR as relevant to project automation kind/documentation labels Nov 5, 2026
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@unodevops

Copy link
Copy Markdown
Contributor

@mergify

mergify Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@agneszitte
agneszitte disabled auto-merge November 6, 2026 14:24
@agneszitte
agneszitte merged commit 451cbc0 into unoplatform:release/stable/6.7 Nov 6, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation kind/documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants