winit icon indicating copy to clipboard operation
winit copied to clipboard

feat: `Event::Reopen` support for macOS

Open I-Info opened this issue 1 year ago • 5 comments

  • [x] Tested on all platforms changed
  • [x] Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • [x] Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • [x] Created or updated an example program if it would help users understand this functionality
  • [x] Updated feature matrix, if new features were added or implemented

Description

This event is typically used to handle dock icon clicking event on macOS and uses applicationShouldHandleReopen:hasVisibleWindows: callback from AppKit Framework.

Use case

It will make it possible to keep application running in backgound when all windows are closed, and create new window after dock icon clicked (application reopen callback).

I-Info avatar Feb 18 '24 04:02 I-Info

And what should we do with all of that on other platforms? The event is macOS specific, but it bleeds into other backend and people will demand its handling, while in reality such event doesn't exist for them.

You should never trade quality for short term wins, this is just straight reduces overall quality because the event is not tied to window in particular and leaves the impression that such thing should be handled.

kchibisov avatar Mar 01 '24 10:03 kchibisov

And what should we do with all of that on other platforms? The event is macOS specific, but it bleeds into other backend and people will demand its handling, while in reality such event doesn't exist for them.

I think the event is well documented as "Unsupported", which we already have precedent for, I don't see the issue with adding another one.

In the end it won't really matter, since we're going to be changing things for 0.31 anyways. But like I said, in the months until that happens, this is a useful feature.

madsmtm avatar Mar 01 '24 10:03 madsmtm

In the end it won't really matter, since we're going to be changing things for 0.31 anyways. But like I said, in the months until that happens, this is a useful feature.

No it's not, because it'll assume porting it to other backends as a top-level event. If you want this feature, require the new application trait for that and wire the vtable like we've discussed, so it won't bleed into any other backend.

kchibisov avatar Mar 01 '24 10:03 kchibisov

All Event stuff is cross platform and has special semantics. WindowEvent stuff has specifics, but not the Event.

As I said, the solution is already here even for 0.30, if you want I can write it myself for macOS.

kchibisov avatar Mar 02 '24 14:03 kchibisov

Instead of exposing this through Winit, https://github.com/rust-windowing/winit/pull/3758 is going to allow listening to NSApplicationDelegate events outside of Winit using objc2::declare_class!, Objective-C, Swift, or similar.

madsmtm avatar Jun 24 '24 13:06 madsmtm