Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use objc2-foundation and objc2-app-kit #37

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

madsmtm
Copy link

@madsmtm madsmtm commented May 15, 2024

The objc2 project is the successor to objc, and contains automatically generated bindings to the Foundation and AppKit frameworks (and many other frameworks), while ensuring that memory management rules are upheld.

This allows dark-light to reduce the amount of complex unsafe code, as well as making it easier for you to in the future change subscribe to listen for theme change notifications instead of the busy loop.

@jacksongoode
Copy link

making it easier for you to in the future change subscribe to listen for theme change notifications instead of the busy loop

How would this upgrade enable that specifically?

@madsmtm
Copy link
Author

madsmtm commented May 21, 2024

making it easier for you to in the future change subscribe to listen for theme change notifications instead of the busy loop

How would this upgrade enable that specifically?

There's two ways to listen for changes to the appearance that I know of:

  • Subscribing to the "AppleInterfaceThemeChangedNotification" notification using [NSDistributedNotificationCenter] (undocumented) example.
  • Using Key-Value Observing on -[NSApplication effectiveAppearance], as documented (in Swift) here.

objc2-foundation/objc2-app-kit provides you the tools to use either of these, by using the generated interfaces to NSDistributedNotificationCenter or to key-value observing categories.

Using these are possible without objc2, but it's a lot harder, as you also have to consider a bunch of memory management, and ensuring you get the method signatures correct.

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.

None yet

2 participants