Add web fullscreen support (#1142)
Adds fullscreen using native web APIs to the stdweb and web-sys backends. Due to limitations of browser APIs, requests for fullscreen can only be fulfilled during a short-lived user-triggered event. This commit does automatically handle that under the hood, but it does introduce unavoidable latency in full-screening the canvas.
This commit is contained in:
parent
bedb889693
commit
3ff4834bd5
7 changed files with 242 additions and 48 deletions
|
|
@ -206,13 +206,20 @@ impl Window {
|
|||
|
||||
#[inline]
|
||||
pub fn fullscreen(&self) -> Option<Fullscreen> {
|
||||
// TODO: should there be a maximization / fullscreen API?
|
||||
None
|
||||
if self.canvas.is_fullscreen() {
|
||||
Some(Fullscreen::Borderless(self.current_monitor()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_fullscreen(&self, _monitor: Option<Fullscreen>) {
|
||||
// TODO: should there be a maximization / fullscreen API?
|
||||
pub fn set_fullscreen(&self, monitor: Option<Fullscreen>) {
|
||||
if monitor.is_some() {
|
||||
self.canvas.request_fullscreen();
|
||||
} else if self.canvas.is_fullscreen() {
|
||||
backend::exit_fullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue