Skip to content

Add OSXOnShouldTerminate and OSXOnWillTerminate quit hooks - #189

Open
trypsynth wants to merge 2 commits into
AllenDang:mainfrom
trypsynth:app-quit-hooks
Open

Add OSXOnShouldTerminate and OSXOnWillTerminate quit hooks#189
trypsynth wants to merge 2 commits into
AllenDang:mainfrom
trypsynth:app-quit-hooks

Conversation

@trypsynth

Copy link
Copy Markdown
Contributor

Summary

  • Adds wxd_App_AddMacShouldTerminateHandler and wxd_App_AddMacWillTerminateHandler, following the same multi-handler callback-vector pattern already used for MacOpenFiles, MacReopenApp, MacPrintFiles, and so on.
  • OSXOnShouldTerminate is vetoable: if any registered handler returns false, termination is vetoed, matching the semantics of the underlying wxWidgets virtual.
  • Adds on_should_terminate and on_will_terminate to the Rust AppEvents trait, following the same shape as the existing on_reopen_app/on_print_files methods (compiles on all platforms, no-op outside macOS).

Motivation

wxApp::OSXOnShouldTerminate/OSXOnWillTerminate are the standard hooks for reacting to application termination on macOS (Cmd-Q, the dock menu's Quit item, system shutdown/log out). An app that needs to confirm a destructive in-progress action before quitting, or do last-chance cleanup, currently has no way to hook into this through wxDragon; only wxEVT_CLOSE_WINDOW on individual frames is available, which does not cover this path. wxWidgets already exposes both virtuals on the Cocoa port, they were just not wired up in the C or Rust binding layers yet.

Test plan

  • cargo build -p wxdragon succeeds locally.

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