-
-
Notifications
You must be signed in to change notification settings - Fork 477
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
Replace winit
with raw-window-handle
#1425
Comments
I agree and I've already started working on it. I'll probably send a PR based on old v0.23 rework and some ideas I've got while reading through out the egl/glx spec. Basically we need like 4 core structs.
And display is the one that can create the rest of 3. Surface will require There should be a way to find arbitrary configurations and pick the suitable one, like I'm not yet sure about adding support for In general it's not that hard to decouple glutin from winit, it would just mean to rewrite it, given that its current internal state is unmaintainable... |
@kchibisov Great, thanks, and I'm glad you're taking over as I wouldn't have done much more than trying to change the current API to accept You're right that the current internal state is very tricky to work this into, glad that you've got a plan for this and let me know if there's anything to help out with (on the Android side) 👍 IIUC:
I thought PBuffers were "generic", they are used on Android for "screen-less" rendering - but maybe also require a connection to the framework. As for those who want |
Fixed in #1435. |
Preface
This requirement came up while attempting to support Android
Surface
s in "regular" apps that may not be backed bywinit
. Separately it also came up while temporarily replacing the oldandroid_glue
code withndk-glue
;winit
doesn't provide an "Android window handle" through theExt
trait "system" similar to Windows/X11/Wayland, requiring the use ofndk-glue
.However,
winit
does provide this Android handle, as well as all other handles, directly through a genericRawWindowHandle
- which has been used now to prevent pulling in another dependency to get access tostatic
resources.A head-start with this conversion for Android and Wayland can be found at https://github.com/MarijnS95/glutin/compare/raw-window-handle.
Why
RawWindowHandle
?It exists solely to decouple surface/window consumers from
winit
-specific code (window "producer"), and allowing others (other crates) to interoperate with rendering-API crates easily. On Android it allows working with arbitrarySurface
s anywhere in an an app'sView
.What's not available through
RawWindowHandle
?They don't provide any info about the window itself, there's no
inner_size()
: this'll be up to the user to pass in.What to do with
WindowedContext
?There's no
Window
to hold on to anymore (RawWindowHandle
doesn't have any lifetime guarantees). Perhaps it's best to remove it in its entirety, moving all functions on it toContext<>
? Alternatively we can "keep" it and just useRawWindowHandle
for theW
type, in case it starts doing lifetime juggling at some point in time.headless/surfaceless?
I'm not fully understanding what is going on here. It seems that these features require a connection to windowing system? I thought that wasn't needed at all, but it seems to be "hacked together" with hidden
winit
windows on some occasions. What's there to salvage from this code if the goal is to dropwinit
entirely?Using
winit
helpersIt seems that at least the
x11
backend leans onwinit
to callxlib
functions: these'll need to find another place if they need to be called at all.Retaining
winit
behind a feature flagIt can still be useful to provide the user with e.g. an event-loop helper function (to listen to
Suspended
/Resumed
events on Android for surface creation/destruction, and forwardResized
tofn resized()
).All in all this seems like a rather large refactor, one that may need to be done in smaller iterations to get right. For one we could introduce
RawWindowHandle
support in the public API first, then migrate internal functions (that build winit windows) over to the newRawWindowHandle
API, and finally deprecate/remove or hidewinit
functions behind a feature flag.I probably forgot a million things, and mentioned many things that I could easily look up myself, but felt the need to bring this up first for discussion before really making any more progress on the aforementioned WIP branch.
The text was updated successfully, but these errors were encountered: