From e6967238cd54570a5330830286abf66ec45440f1 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Tue, 10 May 2022 23:13:49 +0200 Subject: [PATCH] Add exit fullscreen button On some devices, there are no dedicated hardware buttons for leaving fullscreen mode (for example browsers on the Steamdeck). This adds a software "exit fullscreen" button to the bottom bar. --- .../components/bottom-bar/index.tsx | 33 ++++++++++++--- .../components/bottom-bar/style.css | 42 +++++++++++++++---- .../components/icons/initial.tsx | 8 +++- 3 files changed, 69 insertions(+), 14 deletions(-) diff --git a/src/main/services/preact-canvas/components/bottom-bar/index.tsx b/src/main/services/preact-canvas/components/bottom-bar/index.tsx index 5597cbdf..0b131d41 100644 --- a/src/main/services/preact-canvas/components/bottom-bar/index.tsx +++ b/src/main/services/preact-canvas/components/bottom-bar/index.tsx @@ -13,12 +13,19 @@ import { Component, h } from "preact"; import { isFeaturePhone } from "src/main/utils/static-display"; import { bind } from "src/utils/bind"; -import { Back, Fullscreen, Information } from "../icons/initial"; +import { + Back, + FullscreenEnter, + FullscreenExit, + Information +} from "../icons/initial"; import { bottomBar, checkbox, fpToggle, fullscreen, + fullscreenEnter, + fullscreenExit, hidden, leftIcon, leftKeyIcon, @@ -41,6 +48,12 @@ function goFullscreen() { } } +function exitFullscreen() { + if (document.exitFullscreen) { + document.exitFullscreen(); + } +} + const fullscreenSupported: boolean = !!( document.documentElement.requestFullscreen || document.documentElement.webkitRequestFullscreen @@ -184,20 +197,30 @@ export default class BottomBar extends Component { "" ) : fullscreenSupported ? ( ) : (
); + return (