-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Right now, Winit exposes window creation and modification functionality the same way on all platforms. Is that something that makes sense? On mobile, only one function in WindowBuilder (with_multitouch) actually does anything, and only three functions in Window (get_hidpi_factor, get_inner_size, and get_outer_size) do anything useful. A few more functions are implemented for Emscripten, but it has much more in common with mobile platforms than it does with desktop platforms.
Should we expose an entirely different window structure for these platforms that better reflects the underlying capabilities? I don't have much experience with those platforms, but I've written up an example of what I think that sort of API would look like:
- Bikeshedding aside, I'm calling it
View. - For creation,
Viewexposeslist_views(&EventsLoop) -> impl Iterator<View>, which gets an iterator over all windows the OS provides. Viewexposes the following methods:set_multitouch(&self, bool): enables or disables multitouch support.get_hidpi_factor(&self) -> f32: gets the HiDPI factor.get_size(&self) -> LogicalSize: gets the window's size.
- Winit adds two new public platform modules:
mobile- Exposes extension trait
ViewExtwith the following methods:set_valid_orientations(ValidScreenOrientations): used to set the valid screen orientations.
- Adds
ValidScreenOrientationsstruct, defined as followed:pub struct ValidScreenOrientations { pub portrait: bool, pub landscape: bool }
- Exposes extension trait
emscripten- Exposes extension trait
ViewExtwith the following methods:set_fullscreen(bool): sets if the window is fullscreen or notgrab_cursor(bool): grabs or ungrabs the cursorhide_cursor(bool): hides or shows the cursor
- Exposes extension trait
That design may be infeasible one way or another, so any API corrections are appreciated.
Relevant to #33
cc @francesca64 @seivan @mtak- @willglynn
EDIT: Renamed WindowBorrowed to View since that's a better name for it, and added a reference to EventsLoop in list_views.