-
Notifications
You must be signed in to change notification settings - Fork 920
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
Support subsurface/subview/widgets? #3506
Comments
Personally, I think we should declare this as out of scope of Winit. At least on macOS and iOS such subviews wouldn't really be useful on their own, we'd have to start allowing creating |
Keep in mind that this is already present in a form of So I guess this issue is more about removing hacky child window stuff and doing proper subview.
it's already in winit and they are very much required to do complex scene compositing/video players, etc. The same as mixing renderers. |
Having some way to do subsurfaces/subviews is pretty important for creating a general purpose toolkit like GTK on top of winit. So it seems important unless being a backend for a UI toolkit, or a video player is considered out of scope for winit. Or being used to create a video player, etc. If it's not supported in winit, there would need to be some acceptable way at least to use platform-specific code to implement this on top of winit. Not sure how practical this would be currently on all of these platforms. Actually using subsurfaces for things like hardware decoded video will inevitably be platform-specific... at least in the absence of libraries that help with that. Is it possible to represent all of these kind of subviews as a |
Basic subviews don't require anything special. We may have option to create special purpose subveiws, but in general the end goal is to have a way to a separate render target within a window to have video players, overlays drawn with software rendering, just transparent surfaces to dim main scene, etc. And on macOS maybe some views that affect compositing which you can pass via the platform specific attributes. |
Reconsidering, I think my problem is actually that a Winit But I realize that subviews could actually resolve most of my issues here, especially if we started assigning events to subviews instead of windows (e.g. split some of the events in But then again, once we do that, we will likely also have to implement some sort of event bubbling, which, ugh, feature creep. |
Copying the rough notes from today's meeting: We can route mouse input events to each subsurface, as that's already done automatically on each platform. Routing keyboard input events needs focus. Maybe we re-implement focusing? Definitely need some sort of platform-specific focusing support. Some things maybe cannot bubble (e.g. popups, but maybe those are still separate windows?). Has to be user-controllable. |
Throwing my two cents in. (Author of Wayland subsurface PR here) We're trying to support multiple types of window. All windows can:
However, each window type has their own features:
Since we're aiming to use a trait-based API for this, it would make sense to do something like: pub trait Surface: rwh_06::HasRawWindowHandle/*, etc. */ {
// surface-specific methods
}
pub trait Toplevel: Surface {
pub fn set_maximized(maximized: bool);
}
pub trait Subview: Surface {
pub fn set_position(pos: &Position);
} |
For Android, as discussed in Matrix before I left for a month, using multiple |
Wayland subsurfaces would be really important for power optimization: https://nical.github.io/drafts/gui-gpu-notes.html |
I have done a bit more GUI work on other projects in the meantime, and I've realized macOS's
The easiest way to fix this would be to add a hint to In addition, platforms are generally inconsistent with regards to clipping views. Wayland and Windows don't, but macOS and X11 do (AFAIK), so that needs to be ironed out. |
wp_viewporter supports cropping subsurfaces and I think it's already used in Winit for scaling. Also, some pointer events need to be handled in Wayland for subsurfaces; how is it for other platforms? |
On Windows, DirectComposition doesn't delegate inputs, so that will have to be emulated in software. MacOS and X11 do have builtin event delegation and bubbling, but I'm not sure exactly how that works. |
@jgcodes2020 you created #3928. Can we still use Has someone implemented this new API (if it's different)? |
I had a PR to implement at least the split between If I were to implement it now, the resulting API would combine the two designs; using the |
The idea to support "subviews", i.e. a sort of limited
Window
that can be nested inside ofWindow
, has floated around a few times, so I wanted to open an issue to discuss it.A
Subview
would have the following platform equivalent (feel free to edit this):UIView
NSView
wl_subsurface
HTMLCanvasElement
(?)XID
HWND
android.view.Surface
/ANativeWindow
Related: #696. Also discussion in #3311.
The text was updated successfully, but these errors were encountered: