From 8a5702f29656281ff006c649ef4ea188ab57ea08 Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Sun, 7 Feb 2021 21:20:14 +0100 Subject: [PATCH] Detect mobile monitor based on application-pixels --- src/controls.js | 2 ++ src/widget.js | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/controls.js b/src/controls.js index 308d5b12..f861da3b 100644 --- a/src/controls.js +++ b/src/controls.js @@ -28,6 +28,8 @@ class ClapperControls extends Gtk.Box this.currentPosition = 0; this.currentDuration = 0; this.isPositionDragging = false; + + this.isMobileMonitor = false; this.isMobile = false; this.showHours = false; diff --git a/src/widget.js b/src/widget.js index 2298b9ec..fc622d57 100644 --- a/src/widget.js +++ b/src/widget.js @@ -571,13 +571,20 @@ class ClapperWidget extends Gtk.Grid const geometry = monitor.geometry; const size = this.windowSize; - debug(`detected monitor resolution: ${geometry.width}x${geometry.height}`); + debug(`monitor application-pixels: ${geometry.width}x${geometry.height}`); if(geometry.width >= size[0] && geometry.height >= size[1]) { root.set_default_size(size[0], size[1]); debug(`restored window size: ${size[0]}x${size[1]}`); } + const monitorWidth = Math.max(geometry.width, geometry.height); + + if(monitorWidth < 1280) { + this.controls.isMobileMonitor = true; + debug('mobile monitor detected'); + } + surface.connect('notify::state', this._onStateNotify.bind(this)); } });