#winit-window #full-screen #toggle #platform #applications #mode #add

winit-fullscreen

Adds a method to winit::window::Window to toggle fullscreen

5 releases (3 stable)

1.0.2 Dec 3, 2023
1.0.1 Mar 28, 2023
1.0.0 Jan 8, 2023
0.1.1 Jun 18, 2021
0.1.0 Jun 17, 2021

#4 in #toggle

Download history 9/week @ 2024-02-23 7/week @ 2024-03-01 56/week @ 2024-03-29

56 downloads per month
Used in mage-core

MIT license

19KB

winit-fullscreen

This is a simple crate that manages toggling of fullscreen in a winit-based application. Given a borrowed immutable reference to your winit::window::Window instance, you can call:

window.toggle_fullscreen();

If your window is not fullscreen, it will be now, otherwise the reverse will be true.

Motivation

I found the fullscreen interface difficult to remember, the documentation lacking and there are some complexities involving different platforms (some do not support full exclusive mode, for example). So I decided to wrap up the functionality under a simple, argumentless, single function.

I am happy to contribute this back into the Winit crate if there is interest.

Issues and ideas

Please post any issues or ideas on the GitHub site on https://github.com/Cthutu/winit-fullscreen.

Credits

Written by Matt Davies, copyright ©2021, all rights reserved.


lib.rs:

This crate uses an extension trait to add a method winit::window::Window to allow for easy fullscreen toggling.

window.toggle_fullscreen()

Check the example for a minimal winit app that can toggle to fullscreen on pressing ENTER.

Future work

I plan to add an enum to allow a hint for exclusive or borderless.

Dependencies

~2–19MB
~234K SLoC