From 24a105fbe40b914d1567089f30390dc92a85e8b4 Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Mon, 14 Dec 2020 21:30:00 +0100 Subject: [PATCH] Do not drop old GTK4 support Recent GTK4 git is way too buggy. We cannot update the GTK version above 3.99.4 yet. So add compatibility with newer versions without dropping support for older ones. --- clapper_src/misc.js | 1 + clapper_src/player.js | 5 ++++- clapper_src/widget.js | 10 ++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/clapper_src/misc.js b/clapper_src/misc.js index b1ef3e2f..f03cd9b7 100644 --- a/clapper_src/misc.js +++ b/clapper_src/misc.js @@ -12,6 +12,7 @@ var settings = new Gio.Settings({ }); var maxVolume = 1.5; +var isOldGtk = (Gtk.MINOR_VERSION === 99 && Gtk.MICRO_VERSION <= 4); let { debug } = Debug; let inhibitCookie; diff --git a/clapper_src/player.js b/clapper_src/player.js index 776ed62c..ac5e0035 100644 --- a/clapper_src/player.js +++ b/clapper_src/player.js @@ -322,7 +322,10 @@ class ClapperPlayer extends PlayerBase let clapperWidget = this.widget.get_ancestor(Gtk.Grid); if(!clapperWidget.fullscreenMode) { - let size = window.get_default_size(); + let size = (Misc.isOldGtk) + ? window.get_size() + : window.get_default_size(); + if(size[0] > 0 && size[1] > 0) clapperWidget._saveWindowSize(size); } diff --git a/clapper_src/widget.js b/clapper_src/widget.js index 707174a1..664693dd 100644 --- a/clapper_src/widget.js +++ b/clapper_src/widget.js @@ -135,7 +135,9 @@ var Widget = GObject.registerClass({ return; let root = this.get_root(); - let size = root.get_default_size(); + let size = (Misc.isOldGtk) + ? root.get_size() + : root.get_default_size(); this._saveWindowSize(size); @@ -160,7 +162,11 @@ var Widget = GObject.registerClass({ ? this.floatSize : this.windowSize; - root.set_default_size(resize[0], resize[1]); + if(Misc.isOldGtk) + root.resize(resize[0], resize[1]); + else + root.set_default_size(resize[0], resize[1]); + debug(`resized window: ${resize[0]}x${resize[1]}`); this.revealerBottom.showChild(false);