From 7f9c96a5a1e619c03bf81c8b3783703b780edaf4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 18 Jun 2023 15:38:09 +0200 Subject: Adding upstream version 20230618. Signed-off-by: Daniel Baumann --- extensions/vertical-workspaces/lib/osdWindow.js | 93 +++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 extensions/vertical-workspaces/lib/osdWindow.js (limited to 'extensions/vertical-workspaces/lib/osdWindow.js') diff --git a/extensions/vertical-workspaces/lib/osdWindow.js b/extensions/vertical-workspaces/lib/osdWindow.js new file mode 100644 index 0000000..a010558 --- /dev/null +++ b/extensions/vertical-workspaces/lib/osdWindow.js @@ -0,0 +1,93 @@ +/** + * V-Shell (Vertical Workspaces) + * osdWindow.js + * + * @author GdH + * @copyright 2022 - 2023 + * @license GPL-3.0 + * + */ + +'use strict'; + +const { Clutter } = imports.gi; +const Main = imports.ui.main; +const OsdWindow = imports.ui.osdWindow; + +const Me = imports.misc.extensionUtils.getCurrentExtension(); +const _Util = Me.imports.lib.util; + +const OsdPositions = { + 1: { + x_align: Clutter.ActorAlign.START, + y_align: Clutter.ActorAlign.START, + }, + 2: { + x_align: Clutter.ActorAlign.CENTER, + y_align: Clutter.ActorAlign.START, + }, + 3: { + x_align: Clutter.ActorAlign.END, + y_align: Clutter.ActorAlign.START, + }, + 4: { + x_align: Clutter.ActorAlign.CENTER, + y_align: Clutter.ActorAlign.CENTER, + }, + 5: { + x_align: Clutter.ActorAlign.START, + y_align: Clutter.ActorAlign.END, + }, + 6: { + x_align: Clutter.ActorAlign.CENTER, + y_align: Clutter.ActorAlign.END, + }, + 7: { + x_align: Clutter.ActorAlign.END, + y_align: Clutter.ActorAlign.END, + }, +}; + +let _overrides; +let opt; +let _firstRun = true; + +function update(reset = false) { + opt = Me.imports.lib.settings.opt; + const moduleEnabled = opt.get('osdWindowModule', true); + reset = reset || !moduleEnabled; + + // don't even touch this module if disabled + if (_firstRun && reset) + return; + + _firstRun = false; + + if (_overrides) + _overrides.removeAll(); + + if (reset || !moduleEnabled) { + updateExistingOsdWindows(6); + _overrides = null; + opt = null; + return; + } + + _overrides = new _Util.Overrides(); + _overrides.addOverride('osdWindow', OsdWindow.OsdWindow.prototype, OsdWindowCommon); +} + +function updateExistingOsdWindows(position) { + position = position ? position : opt.OSD_POSITION; + Main.osdWindowManager._osdWindows.forEach(osd => { + osd.set(OsdPositions[position]); + }); +} + +const OsdWindowCommon = { + after_show() { + if (!opt.OSD_POSITION) + this.opacity = 0; + this.set(OsdPositions[opt.OSD_POSITION]); + }, +}; -- cgit v1.2.3