-
Notifications
You must be signed in to change notification settings - Fork 927
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
feat: Add a safe method for cross-crate interop to winit #2744
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
59a4144
feat: Integrate window-handle into winit
notgull c3616e1
Moved traits to raw-window-handle
notgull a735cd9
Try the new branch
notgull 1db45e2
Use pathces in Cargo.toml
notgull 2e9b655
Fix errors
notgull 902a8ca
Add an OwnedDisplayHandle structure
notgull 6bdb342
Use crates.io rwh
notgull 61e4180
Fix handler on Android
notgull 1fcc441
Add more documentation to OwnedDisplayHandle
notgull 506f08c
Review comments
notgull 0767b89
Fix import error
notgull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand the purpose of this type. The
EventLoop
itself is what should have theHasDisplayHandle
impl, and its lifetime is what should be used. The fact that you're not using this type in examples at all suggests me that there's no clear case when it should be used(at least you should use it inside the examples).The
EventLoopWindowTarget
must have the same lifetime as theEventLoop
itself, because it's simply a field onEventLoop
in all the backends.The
Clone
is also sort of questionable, because it simply will discard the lifetime attached to it, given that there's only a way to get&OwnedDisplayHandle
not the owned type on its own?if that's intent on
lifetime
casting, different method should be used withunsafe
bit on it(because it's simplymem::tranmsute
like thingy of donig'static
lifetime).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why this type exists is for the
glutin
case. The scenario is that you need an object that has a display handle before a window is created, since you need to query the display. You can't useEventLoop
,&EventLoop
or aDisplayHandle<'_>
taken from anEventLoop
because theEventLoop
is owned/borrowed mutably for event handling. You can't use theEventLoopWindowTarget
that is provided in the event handler, since it disappears between events, which means it can't be used persistently. Normally I'd use aWindow
, but forglutin
(outside of Win32) you haven't created aWindow
yet.Therefore I created this type to fill that hole. Something that implements
HasDisplayHandle
that can be used according to Rust's borrowing system. This way, it can be used in the display position without any unsafe hacks.If theactually, it might be necessary for the borrowing rules to check out in this case.Clone
is a deal breaker I can get rid of it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just think that it's
unsafe
, so you might have different method liketo_static
, which casts away lifetime.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added documentation clarifying the purpose of
OwnedWindowHandle
and why it is safe.