-
Notifications
You must be signed in to change notification settings - Fork 80
Change Window from a borrowed handle to a weakly owned handle
#174
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
base: master
Are you sure you want to change the base?
Conversation
|
Win32 backend update done, tested and functional! 🙂 |
bb1108a to
2ef375f
Compare
4a82bfc to
999f97d
Compare
e10382d to
231bbc6
Compare
This PR splits off the X11 event loop logic into a separate module. It also changes the X11 implementation of the `Window` type to take only a shared reference to the inner type (`&WindowInner` instead of `&mut WindowInner`), bringing it in line with the other backends. This does not change any of the logic however, it only separates some of the window state from the event loop state, to make sure they don't step on each other's toes in the future (particularly around the WindowHandler). This is part of the effort to split up #174 into smaller pieces.
More post-rebase fixes, add missing flush call Post-rebase fixes Fix windows OpenGL context creation Minor fixes Squashed: Port X11 backend to x11rb Fix macOS build Win32 refactor Make the added with_scale_factor fn pub(crate) for now Remove unneeded internal HasRawWindowHandle implementation Simplify everything by making the public Window/GlContext types hold the Weak themselves Remove lifetime from Window type, refactor and split X11 backend Added functional open_parented example
231bbc6 to
0b58445
Compare
|
I'd second this - I'm attempting to integrate baseview as a replacement for winit in floem and the lifetime (not to mention the requirement that the window creation closure be This would vastly simplify that integration. |
This PR implements the idea discussed with @glowcoil on Discord a few days ago, which is to make the
Windowhandle'staticand clone-able, so that it can be easily stored in theWindowHandler.Note this PR is based on #172 for now, which is why the new example shows up in the diff. This can be changed depending on #172's merge status.This has been properly rebased now.This makes the following breaking API changes, for all platforms and backends:
Windowtype.Windowtype is now an owned, weak handle to the actual underlying window.Windowtype clone-able.Windowargument passed to theWindowHandlerbuilder is now a fully owned value instead of a temporary borrow, which enables the handler to store it for its whole lifetime.Windowargument onWindowHandler::on_frameandWindowHandler::on_eventmethods.Windowmethods now only take&selfinstead of&mut self.Windowmethods are now internally fallible: they will panic if the actual window the handle points to has been destroyed. This can only happen if theWindowHandlermisbehaves and clones theWindowoutside of its own lifetime.GlContexthas received the same treatment, for the same reasons: it's now a weak, owned clone-able handle to the GL context of a window, and its methods will also panic if the underlying context is destroyed.As of now, this PR is still a WIP:
The X11 backend is complete and functional, but it will probably need to be rebased on top of Switch from xcb crate to x11rb #173 before this PR can be merged.It's done!I started working on the Win32 backend, but it's not done yet.Done!I haven't touched the Cocoa backend, and it will not build at all at the moment.Done, but still needs testing.As of now, this PR will not build on macOS or Windows until I've completed the work mentioned above.