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

Add Event::OpenFiles #3713

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

Add Event::OpenFiles #3713

wants to merge 1 commit into from

Conversation

jim-ec
Copy link
Contributor

@jim-ec jim-ec commented May 28, 2024

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 jim-ec requested a review from madsmtm as a code owner May 28, 2024 17:11
Copy link
Member

@kchibisov kchibisov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be on its own trait as it was requested multiple times. The Event will be gone soon, so no need to add anything into it.

@madsmtm
Copy link
Member

madsmtm commented Jun 24, 2024

Thanks for the PR, though I'm going to resolve this in a different way, see #1751 (comment).

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

Successfully merging this pull request may close these issues.

None yet

3 participants