From a4512614e7bdbbe69781eec47241a3073c58575b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 22 Feb 2022 18:54:08 +0100 Subject: [PATCH] Backport support for top positioning The current mockups from branding position the logo on the top right, which the extension didn't support until recently. Related: #2052594 --- 0001-Support-positioning-at-the-top.patch | 135 +++++++++++++++++++++ 0001-prefs-Scale-preview-border.patch | 40 ++++++ gnome-shell-extension-background-logo.spec | 9 +- 3 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 0001-Support-positioning-at-the-top.patch create mode 100644 0001-prefs-Scale-preview-border.patch diff --git a/0001-Support-positioning-at-the-top.patch b/0001-Support-positioning-at-the-top.patch new file mode 100644 index 0000000..0374b36 --- /dev/null +++ b/0001-Support-positioning-at-the-top.patch @@ -0,0 +1,135 @@ +From ff01583cb7eb00cbe012011b3de34298243787bc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Florian=20M=C3=BCllner?= +Date: Tue, 8 Feb 2022 13:41:18 +0100 +Subject: [PATCH] Support positioning at the top + +Fedora has always placed the logo at the bottom, but for RHEL the +placement will likely be at the top. +--- + extension.js | 30 ++++++++----------- + prefs.js | 30 +++++++++---------- + ...sted.background-logo-extension.gschema.xml | 6 +++- + 3 files changed, 33 insertions(+), 33 deletions(-) + +diff --git a/extension.js b/extension.js +index d1bf35b..8255617 100644 +--- a/extension.js ++++ b/extension.js +@@ -166,26 +166,22 @@ class BackgroundLogo extends St.Widget { + + _updatePosition() { + let xAlign, yAlign; +- switch (this._settings.get_string('logo-position')) { +- case 'center': +- xAlign = Clutter.ActorAlign.CENTER; +- yAlign = Clutter.ActorAlign.CENTER; +- break; +- case 'bottom-left': ++ const position = this._settings.get_string('logo-position'); ++ if (position.endsWith('left')) + xAlign = Clutter.ActorAlign.START; +- yAlign = Clutter.ActorAlign.END; +- break; +- case 'bottom-center': +- xAlign = Clutter.ActorAlign.CENTER; +- yAlign = Clutter.ActorAlign.END; +- break; +- case 'bottom-right': ++ else if (position.endsWith('right')) + xAlign = Clutter.ActorAlign.END; ++ else ++ xAlign = Clutter.ActorAlign.CENTER; ++ ++ if (position.startsWith('top')) ++ yAlign = Clutter.ActorAlign.START; ++ else if (position.startsWith('bottom')) + yAlign = Clutter.ActorAlign.END; +- break; +- } +- this._bin.x_align = xAlign; +- this._bin.y_align = yAlign; ++ else ++ yAlign = Clutter.ActorAlign.CENTER; ++ ++ this._bin.set({ xAlign, yAlign }); + } + + _updateBorder() { +diff --git a/prefs.js b/prefs.js +index a2ce27a..c8d5903 100644 +--- a/prefs.js ++++ b/prefs.js +@@ -76,6 +76,9 @@ class BackgroundLogoPrefsWidget extends Gtk.Grid { + comboBox.append('bottom-left', 'Bottom left'); + comboBox.append('bottom-center', 'Bottom center'); + comboBox.append('bottom-right', 'Bottom right'); ++ comboBox.append('top-left', 'Top left'); ++ comboBox.append('top-center', 'Top center'); ++ comboBox.append('top-right', 'Top right'); + this._settings.bind('logo-position', + comboBox, 'active-id', + Gio.SettingsBindFlags.DEFAULT); +@@ -196,24 +199,21 @@ class BackgroundLogoPrefsWidget extends Gtk.Grid { + _getLogoPosition(width, height) { + let scaledBorder = this._settings.get_uint('logo-border'); + let x, y; +- switch (this._settings.get_string('logo-position')) { +- case 'center': +- x = (width - this._logo.get_width()) / 2; +- y = (height - this._logo.get_height()) / 2; +- break; +- case 'bottom-left': ++ const position = this._settings.get_string('logo-position'); ++ if (position.endsWith('left')) + x = scaledBorder; +- y = height - this._logo.get_height() - scaledBorder; +- break; +- case 'bottom-center': ++ else if (position.endsWith('right')) ++ x = (width - this._logo.get_width() - scaledBorder); ++ else + x = (width - this._logo.get_width()) / 2; ++ ++ if (position.startsWith('top')) ++ y = scaledBorder; ++ else if (position.startsWith('bottom')) + y = height - this._logo.get_height() - scaledBorder; +- break; +- case 'bottom-right': +- x = width - this._logo.get_width() - scaledBorder; +- y = height - this._logo.get_height() - scaledBorder; +- break; +- } ++ else ++ y = (height - this._logo.get_height()) / 2; ++ + return [x, y]; + } + +diff --git a/schemas/org.fedorahosted.background-logo-extension.gschema.xml b/schemas/org.fedorahosted.background-logo-extension.gschema.xml +index abacefb..74bc3a8 100644 +--- a/schemas/org.fedorahosted.background-logo-extension.gschema.xml ++++ b/schemas/org.fedorahosted.background-logo-extension.gschema.xml +@@ -5,6 +5,9 @@ + + + ++ ++ ++ + + + Logo position + + The position logo of the logo; valid values are 'center', +- 'bottom-left', 'bottom-center' and 'bottom-right' ++ 'bottom-left', 'bottom-center', 'bottom-right', ++ 'top-left', 'top-center' and 'top-right' + + + +-- +2.33.1 + diff --git a/0001-prefs-Scale-preview-border.patch b/0001-prefs-Scale-preview-border.patch new file mode 100644 index 0000000..05cbd59 --- /dev/null +++ b/0001-prefs-Scale-preview-border.patch @@ -0,0 +1,40 @@ +From ab86a3469bca9246ba5a6039d0cce8c6afae1fc9 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Florian=20M=C3=BCllner?= +Date: Tue, 15 Feb 2022 15:25:43 +0100 +Subject: [PATCH] prefs: Scale preview border + +We currently pick up the settings value directly, which is the +border that is used on the actual (i.e. monitor-sized) background. + +That's way too big when applied as-is on the preview, so assume a +common monitor size and compute an appropriate scale from that. +--- + prefs.js | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/prefs.js b/prefs.js +index c8d5903..ba78322 100644 +--- a/prefs.js ++++ b/prefs.js +@@ -13,6 +13,7 @@ const ExtensionUtils = imports.misc.extensionUtils; + + const BACKGROUND_SCHEMA = 'org.gnome.desktop.background'; + ++const MONITOR_WIDTH = 1920; + const PREVIEW_WIDTH = 400; + + let BackgroundLogoPrefsWidget = GObject.registerClass( +@@ -197,7 +198,9 @@ class BackgroundLogoPrefsWidget extends Gtk.Grid { + } + + _getLogoPosition(width, height) { +- let scaledBorder = this._settings.get_uint('logo-border'); ++ const previewScale = PREVIEW_WIDTH / MONITOR_WIDTH; ++ const scaledBorder = ++ previewScale * this._settings.get_uint('logo-border'); + let x, y; + const position = this._settings.get_string('logo-position'); + if (position.endsWith('left')) +-- +2.33.1 + diff --git a/gnome-shell-extension-background-logo.spec b/gnome-shell-extension-background-logo.spec index 358abf7..eefcb81 100644 --- a/gnome-shell-extension-background-logo.spec +++ b/gnome-shell-extension-background-logo.spec @@ -3,7 +3,7 @@ Name: gnome-shell-extension-background-logo Version: 40.0~rc -Release: 2%{?dist} +Release: 3%{?dist} Summary: Background logo extension for GNOME Shell License: GPLv2+ @@ -20,6 +20,9 @@ Requires: gnome-shell >= %{shell_version} # https://pagure.io/background-logo-extension/pull-request/32 Patch0: 32.patch +Patch1: 0001-Support-positioning-at-the-top.patch +Patch2: 0001-prefs-Scale-preview-border.patch + %description Show your pride! Display the Fedora logo (or any other graphic) in the corner of your desktop. @@ -39,6 +42,10 @@ Show your pride! Display the Fedora logo (or any other graphic) in the corner of %{_datadir}/gnome-shell/extensions/background-logo@fedorahosted.org/ %changelog +* Tue Feb 22 2022 Florian Müllner - 40.0~rc-3 +- Backport support for top positioning in RHEL + Related: #2052594 + * Wed Mar 31 2021 Michael Catanzaro - 40.0~rc-2 - Fix logo flickering