-
Notifications
You must be signed in to change notification settings - Fork 51
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
Would it make sense to have some kind of "view" or "renderable" handle? #123
Comments
And on android, where |
Basically, I want better cooperation with the existing layout systems (if they exist). I'm especially unsure what the best approach is for building a "native" user interface on Linux? GTK? Or would it be best to do it "raw", and provide something like |
Wayland's wl_surface can be used for anything as well, but that's how the handle is done. I wonder whether on macOS you don't need to have a reference to a window to perform some requests on it? Also, the user could simply omit the window, fields are not required to be set, so setting just NSView is absolutely fine.
visual has nothing to do with windows on X11, it's a pixel format. Everything is a XID, which is window as it's said in the structs. |
The window field is entirely redundant on macOS, it can always be gotten from the view. So maybe it would actually make sense to rename the |
The common name for this thing on e.g. Android and in graphics APIs like (E)GL and Vulkan is a "surface", I'd name it that. OTOH it's not that in Vulkan/GL yet, you still have to create a Surface from a Surface which may sound weird? |
I've been thinking about this again, and I think my problem is that we have conflated distinct concepts in To start with, the task of this library was to pass a render-able surface from Winit/SDL/similar to Glutin/Wgpu/similar. I can only really speak for macOS/iOS, but the correct way to do this correct is to pass a I'm currently undecided myself whether we really ought to provide In any case, this matters if we want to provide proper subsurface support in Winit. With the current design of An idea for how this may look is as follows: enum RawSurfaceHandle {
AndroidNdk(ANativeWindow),
CoreGraphics(CALayer), // Both AppKit and UIKit
Drm(plane), // Probably
Gbm(device), // Probably
Haiku(BDirectWindow), // Probably
OhosNdk(OHNativeWindow),
Wayland(wl_surface),
WebCanvas(HtmlCanvasElement),
WebOffscreenCanvas(OffscreenCanvas),
Win32(HWND, GWLP_HINSTANCE), // Unsure
WinRt(CoreWindow), // Maybe?
Xcb(xcb_window_t, xcb_visualid_t), // Unsure
Xlib(Window, visual ID), // Unsure
}
// May not be available on all platforms, a higher-level concept in windowing libraries, not related to drawing
enum RawWidgetHandle {
AndroidNdk(View), // Maybe?
AppKit(NSView),
Haiku(BWindow), // Probably
OhosNDK(XComponent),
Orbital(orbclient::Window),
UIKit(UIView),
Web(HTMLElement),
Win32(HWND), // Maybe?
} I think you can usually go from Unsure how we should model this trait-wise. |
You're correct that it would be a Unrelated to this, we could also provide an |
I'm only really familiar with macOS and iOS, but on those platforms it would make sense to split the window and the view handles in two.
That way, users could make some sort of interface in the native toolkit, and just provide the
NSView
handle towgpu
to render into. With the current design, we're assuming that the whole window's content is what should be rendered into.I think this is roughly how it already works on web, e.g. you can lay out the page in a certain way, and then just create a canvas that you pass on to the renderer to do its thing. (Though arguably
winit
shouldn't be creating a canvas, perhaps instead it should provide adiv
that the graphics library itself can insert the canvas into?)Would this sort of thing work on other platforms?
The text was updated successfully, but these errors were encountered: