Conversation
8ef02a7 to
6389938
Compare
|
AI: Change name to |
6389938 to
1aa23ba
Compare
This MR adds a handle type specifically for views. "Views" are defined as sub-areas of windows that graphics APIs can render into. This is separated from Windows, which may be a key difference for some APIs. So far this MR only implements views that wrap around windows, and views that wrap around NSView from AppKit. Discussion must be done to determine if this is the best way to go about this, as well as if we should add other views. Ref: #123 Signed-off-by: John Nunley <dev@notgull.net>
1aa23ba to
1e2d68c
Compare
|
I'm actually wondering if this isn't the right play here. Maybe just having a macOS window handle with a back-pointer to the struct AppkitWindowHandle {
ns_view: NonNull<c_void>,
ns_window: Option<NonNull<c_void>>
} |
| /// [`winit`]: https://crates.io/crates/winit | ||
| /// [`sdl2`]: https://crates.io/crates/sdl2 | ||
| /// [`wgpu`]: https://crates.io/crates/wgpu | ||
| /// [`glutin`]: https://crates.io/crates/gl |
There was a problem hiding this comment.
Glutin and GL are two independent crates
| /// [`glutin`]: https://crates.io/crates/gl | |
| /// [`glutin`]: https://crates.io/crates/glutin |
kchibisov
left a comment
There was a problem hiding this comment.
I think the best way forward with this, would be to change current window handle to SurfaceHandle, and for window handle, have a way to get it from the SurfaceHandle::window_handle(&self) -> WindowHandle?
This thing should be forward compat, I think.
Also, you don't need Window that often, but if you need, you likely need both at the same time, so it's better to have the actual data(pointers, etc) to lay at the same struct and produced together (less change to fail).
| pub enum RawSurfaceHandle { | ||
| /// A view that simply represents an entire window. | ||
| /// | ||
| /// This view should be used when you want to render directly into the | ||
| /// entire window. In addition, this should be used when there is no | ||
| /// meaningful difference between windows and views in the windowing system. | ||
| /// For example, in Windows, a `HWND` can correspond to both a view handle | ||
| /// as well as a window handle. | ||
| Window(RawWindowHandle), | ||
|
|
||
| /// A raw view handle for AppKit. | ||
| /// | ||
| /// ## Availability Hints | ||
| /// This variant is used on macOS systems. | ||
| AppKit(AppKitSurfaceHandle), | ||
| } |
There was a problem hiding this comment.
This thing is technically not forward compat, since if you had e.g. Wayland in Window and with update you made a special variant for that, that won't change the enum and the code will still compile, but it won't work anymore, because the data within enum moved.
madsmtm
left a comment
There was a problem hiding this comment.
I think I'd like to wait a bit with this, I'd like to get reference-counting figured out first (#188) (if we haven't figured it out in like 2 weeks, consider this concern resolved).
I also think I agree with Kirill, at least in that I'd rather preserve the WindowHandle we have right now as-is as the surface/view handle, and rather introduce a wrapper on top that is the actual "window" handle.
This MR adds a handle type specifically for views. "Views" are defined
as sub-areas of windows that graphics APIs can render into. This is
separated from Windows, which may be a key difference for some APIs.
So far this MR only implements views that wrap around windows, and views
that wrap around NSView from AppKit. Discussion must be done to
determine if this is the best way to go about this, as well as if we
should add other views.
Ref: #123