From a039fd4ce4116a0300b7d4868a254d0be491aec4 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sat, 10 Apr 2021 04:10:12 +0200 Subject: [PATCH] Make isFullscreen a bit more lenient. innerWidth|Height and screen.width|height no longer need an exact match --- src/ext/lib/video-data/PlayerData.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ext/lib/video-data/PlayerData.ts b/src/ext/lib/video-data/PlayerData.ts index 52adca8..12f7771 100644 --- a/src/ext/lib/video-data/PlayerData.ts +++ b/src/ext/lib/video-data/PlayerData.ts @@ -118,8 +118,18 @@ class PlayerData { } } + /** + * Returns whether we're in fullscreen mode or not. + */ static isFullScreen(){ - return ( window.innerHeight == window.screen.height && window.innerWidth == window.screen.width); + const ihdiff = Math.abs(window.screen.height - window.innerHeight); + const iwdiff = Math.abs(window.screen.width - window.innerWidth); + + // Chrome on linux on X on mixed PPI displays may return ever so slightly different values + // for innerHeight vs screen.height abd innerWidth vs. screen.width, probably courtesy of + // fractional scaling or something. This means we'll give ourself a few px of margin — the + // window elements visible in not-fullscreen are usually double digit px tall + return ( ihdiff < 5 && iwdiff < 5 ); }