diff options
Diffstat (limited to 'extensions/44/vertical-workspaces/lib/osdWindow.js')
-rw-r--r-- | extensions/44/vertical-workspaces/lib/osdWindow.js | 145 |
1 files changed, 85 insertions, 60 deletions
diff --git a/extensions/44/vertical-workspaces/lib/osdWindow.js b/extensions/44/vertical-workspaces/lib/osdWindow.js index a010558..4699ddf 100644 --- a/extensions/44/vertical-workspaces/lib/osdWindow.js +++ b/extensions/44/vertical-workspaces/lib/osdWindow.js @@ -10,79 +10,104 @@ 'use strict'; -const { Clutter } = imports.gi; +const Clutter = imports.gi.Clutter; + 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 Me; let opt; -let _firstRun = true; -function update(reset = false) { - opt = Me.imports.lib.settings.opt; - const moduleEnabled = opt.get('osdWindowModule', true); - reset = reset || !moduleEnabled; +let OsdPositions; - // don't even touch this module if disabled - if (_firstRun && reset) - return; +var OsdWindowModule = class { + constructor(me) { + Me = me; + opt = Me.opt; - _firstRun = false; + this._firstActivation = true; + this.moduleEnabled = false; + this._overrides = null; - if (_overrides) - _overrides.removeAll(); + 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, + }, + }; + } - if (reset || !moduleEnabled) { - updateExistingOsdWindows(6); - _overrides = null; + cleanGlobals() { + Me = null; opt = null; - return; + OsdPositions = null; } - _overrides = new _Util.Overrides(); - _overrides.addOverride('osdWindow', OsdWindow.OsdWindow.prototype, OsdWindowCommon); -} + update(reset) { + this.moduleEnabled = opt.get('osdWindowModule'); + const conflict = false; -function updateExistingOsdWindows(position) { - position = position ? position : opt.OSD_POSITION; - Main.osdWindowManager._osdWindows.forEach(osd => { - osd.set(OsdPositions[position]); - }); -} + reset = reset || !this.moduleEnabled || conflict; + + // don't touch the original code if module disabled + if (reset && !this._firstActivation) { + this._disableModule(); + } else if (!reset) { + this._firstActivation = false; + this._activateModule(); + } + if (reset && this._firstActivation) + console.debug(' OsdWindowModule - Keeping untouched'); + } + + _activateModule() { + if (!this._overrides) + this._overrides = new Me.Util.Overrides(); + + this._overrides.addOverride('osdWindow', OsdWindow.OsdWindow.prototype, OsdWindowCommon); + console.debug(' OsdWindowModule - Activated'); + } + + _disableModule() { + if (this._overrides) + this._overrides.removeAll(); + this._overrides = null; + this._updateExistingOsdWindows(6); + + console.debug(' WorkspaceSwitcherPopupModule - Disabled'); + } + + _updateExistingOsdWindows(position) { + position = position ? position : opt.OSD_POSITION; + Main.osdWindowManager._osdWindows.forEach(osd => { + osd.set(OsdPositions[position]); + }); + } +}; const OsdWindowCommon = { after_show() { |