winit icon indicating copy to clipboard operation
winit copied to clipboard

Add Event::OpenFiles

Open jim-ec opened this issue 1 year ago • 1 comments

Emit an event when the application is opened by clicking on files in Finder or by dropping files on the Dock icon. This is macOS specific, as other OSs usually communicate that information through std::env::args().

I am not sure with the current implementation, i.e. maybe the OpenFiles event should be defined in a macOS specific event enum type?

This basically implements #1751.

To test the event, a application bundle is required:

Winit.App
- Contents
  - Info.plist
  - MacOS
    - <executable>

The Info.plist should look like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleExecutable</key>
    <string>
        <!-- Name of executable -->
    </string>
</dict>
</plist>

Also, you need to implement fn ApplicationHandler::open_files(&mut self, files: Vec<PathBuf>).

  • [ ] Tested on all platforms changed
  • [ ] Added an entry to the changelog module if knowledge of this change could be valuable to users
  • [ ] 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
  • [ ] Updated [feature matrix](https://github.com/rust-windowing/winit

jim-ec avatar May 28 '24 17:05 jim-ec

Thanks for the PR, though I'm going to resolve this in a different way, see https://github.com/rust-windowing/winit/issues/1751#issuecomment-2186560639.

madsmtm avatar Jun 24 '24 13:06 madsmtm