Skip to content

Conversation

@madsmtm
Copy link
Member

@madsmtm madsmtm commented Sep 5, 2025

Added a common interface that:

  • Uses closures instead of static functions. This should allow easier refactoring in the future.
  • Returns a handle which is invalidated on Drop. This should avoid situations where the event loop has exited, but an observer is still called because the user spawned the application later on.
  • Is properly main-thread safe.

This interface is placed in winit-common, to allow using it in both winit-appkit and winit-uikit.

  • Tested on all platforms changed
    • Tested on macOS 15.6.1 and with Mac Catalyst.
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
    • Shouldn't really be user-visible.
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality

@madsmtm madsmtm added DS - appkit Affects the AppKit/macOS backend DS - uikit Affects the UIKit backend (iOS, tvOS, watchOS, visionOS) labels Sep 5, 2025
@madsmtm madsmtm added this to the Version 0.31.0 milestone Sep 5, 2025
@madsmtm madsmtm force-pushed the madsmtm/better-observers branch 2 times, most recently from 32a9baa to e341ecd Compare September 5, 2025 20:32
Added a common interface that:
- Uses closures instead of static functions. This should allow easier
  refactoring in the future.
- Returns a handle which is invalidated on `Drop`. This should avoid
  situations where the event loop has exited, but an observer is still
  called because the user spawned the application later on.
- Is properly main-thread safe.

This interface is placed in winit-common, to allow using it in both
winit-appkit and winit-uikit.
@madsmtm madsmtm force-pushed the madsmtm/better-observers branch from e341ecd to 651c3f4 Compare September 5, 2025 20:40
@pkondzior
Copy link

Is there any chance that this fixes #1418 ?

@madsmtm
Copy link
Member Author

madsmtm commented Sep 9, 2025

No, but #4155 might.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DS - appkit Affects the AppKit/macOS backend DS - uikit Affects the UIKit backend (iOS, tvOS, watchOS, visionOS)

Development

Successfully merging this pull request may close these issues.

3 participants