summaryrefslogtreecommitdiffstats
path: root/extensions/44/vertical-workspaces/lib/windowManager.js
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/44/vertical-workspaces/lib/windowManager.js')
-rw-r--r--extensions/44/vertical-workspaces/lib/windowManager.js148
1 files changed, 84 insertions, 64 deletions
diff --git a/extensions/44/vertical-workspaces/lib/windowManager.js b/extensions/44/vertical-workspaces/lib/windowManager.js
index 2d46b0b..0cae6aa 100644
--- a/extensions/44/vertical-workspaces/lib/windowManager.js
+++ b/extensions/44/vertical-workspaces/lib/windowManager.js
@@ -10,81 +10,101 @@
'use strict';
-const { GObject, Clutter, Meta } = imports.gi;
+const Clutter = imports.gi.Clutter;
+const GObject = imports.gi.GObject;
+const Meta = imports.gi.Meta;
const Main = imports.ui.main;
const WindowManager = imports.ui.windowManager;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const _Util = Me.imports.lib.util;
-let _overrides;
-
-const MINIMIZE_WINDOW_ANIMATION_TIME = WindowManager.MINIMIZE_WINDOW_ANIMATION_TIME;
-const MINIMIZE_WINDOW_ANIMATION_MODE = WindowManager.MINIMIZE_WINDOW_ANIMATION_MODE;
+let Me;
let opt;
-let _firstRun = true;
-function update(reset = false) {
- opt = Me.imports.lib.settings.opt;
- const moduleEnabled = opt.get('windowManagerModule', true);
- reset = reset || !moduleEnabled;
+var WindowManagerModule = class {
+ constructor(me) {
+ Me = me;
+ opt = Me.opt;
- // don't even touch this module if disabled
- if (_firstRun && reset)
- return;
+ this._firstActivation = true;
+ this.moduleEnabled = false;
+ this._overrides = null;
- _firstRun = false;
+ this._originalMinimizeSigId = 0;
+ this._minimizeSigId = 0;
+ this._originalUnminimizeSigId = 0;
+ this._unminimizeSigId = 0;
+ }
- if (_overrides)
- _overrides.removeAll();
+ cleanGlobals() {
+ Me = null;
+ opt = null;
+ }
+ update(reset) {
+ this.moduleEnabled = opt.get('windowManagerModule');
+ const conflict = false;
- _replaceMinimizeFunction(reset);
+ reset = reset || !this.moduleEnabled || conflict;
+ // don't even 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(' WindowManagerModule - Keeping untouched');
+ }
- if (reset) {
- _overrides = null;
- opt = null;
- return;
+ _activateModule() {
+ if (!this._overrides)
+ this._overrides = new Me.Util.Overrides();
+
+ this._overrides.addOverride('WindowManager', WindowManager.WindowManager.prototype, WindowManagerCommon);
+
+ if (!this._minimizeSigId) {
+ this._originalMinimizeSigId = GObject.signal_handler_find(Main.wm._shellwm, { signalId: 'minimize' });
+ if (this._originalMinimizeSigId) {
+ Main.wm._shellwm.block_signal_handler(this._originalMinimizeSigId);
+ this._minimizeSigId = Main.wm._shellwm.connect('minimize', WindowManagerCommon._minimizeWindow.bind(Main.wm));
+ }
+
+ this._originalUnminimizeSigId = GObject.signal_handler_find(Main.wm._shellwm, { signalId: 'unminimize' });
+ if (this._originalUnminimizeSigId) {
+ Main.wm._shellwm.block_signal_handler(this._originalUnminimizeSigId);
+ this._unminimizeSigId = Main.wm._shellwm.connect('unminimize', WindowManagerCommon._unminimizeWindow.bind(Main.wm));
+ }
+ }
+ console.debug(' WindowManagerModule - Activated');
}
- _overrides = new _Util.Overrides();
-
- _overrides.addOverride('WindowManager', WindowManager.WindowManager.prototype, WindowManagerCommon);
-}
-
-// ------------- Fix and adapt minimize/unminimize animations --------------------------------------
-
-let _originalMinimizeSigId;
-let _minimizeSigId;
-let _originalUnminimizeSigId;
-let _unminimizeSigId;
-
-function _replaceMinimizeFunction(reset = false) {
- if (reset) {
- Main.wm._shellwm.disconnect(_minimizeSigId);
- _minimizeSigId = 0;
- Main.wm._shellwm.unblock_signal_handler(_originalMinimizeSigId);
- _originalMinimizeSigId = 0;
-
- Main.wm._shellwm.disconnect(_unminimizeSigId);
- _unminimizeSigId = 0;
- Main.wm._shellwm.unblock_signal_handler(_originalUnminimizeSigId);
- _originalUnminimizeSigId = 0;
- } else if (!_minimizeSigId) {
- _originalMinimizeSigId = GObject.signal_handler_find(Main.wm._shellwm, { signalId: 'minimize' });
- if (_originalMinimizeSigId) {
- Main.wm._shellwm.block_signal_handler(_originalMinimizeSigId);
- _minimizeSigId = Main.wm._shellwm.connect('minimize', WindowManagerCommon._minimizeWindow.bind(Main.wm));
+ _disableModule() {
+ if (this._overrides)
+ this._overrides.removeAll();
+ this._overrides = null;
+
+ if (this._minimizeSigId) {
+ Main.wm._shellwm.disconnect(this._minimizeSigId);
+ this._minimizeSigId = 0;
+ }
+ if (this._originalMinimizeSigId) {
+ Main.wm._shellwm.unblock_signal_handler(this._originalMinimizeSigId);
+ this._originalMinimizeSigId = 0;
}
- _originalUnminimizeSigId = GObject.signal_handler_find(Main.wm._shellwm, { signalId: 'unminimize' });
- if (_originalUnminimizeSigId) {
- Main.wm._shellwm.block_signal_handler(_originalUnminimizeSigId);
- _unminimizeSigId = Main.wm._shellwm.connect('unminimize', WindowManagerCommon._unminimizeWindow.bind(Main.wm));
+ if (this._unminimizeSigId) {
+ Main.wm._shellwm.disconnect(this._unminimizeSigId);
+ this._unminimizeSigId = 0;
+ }
+ if (this._originalUnminimizeSigId) {
+ Main.wm._shellwm.unblock_signal_handler(this._originalUnminimizeSigId);
+ this._originalUnminimizeSigId = 0;
}
+
+ console.debug(' WindowManagerModule - Disabled');
}
-}
+};
// fix for mainstream bug - fullscreen windows should minimize using opacity transition
// but its being applied directly on window actor and that doesn't work
@@ -109,8 +129,8 @@ const WindowManagerCommon = {
/* if (actor.meta_window.is_monitor_sized()) {
actor.get_first_child().ease({
opacity: 0,
- duration: MINIMIZE_WINDOW_ANIMATION_TIME,
- mode: MINIMIZE_WINDOW_ANIMATION_MODE,
+ duration: WindowManager.MINIMIZE_WINDOW_ANIMATION_TIME,
+ mode: WindowManager.MINIMIZE_WINDOW_ANIMATION_MODE,
onStopped: () => this._minimizeWindowDone(shellwm, actor),
});
} else { */
@@ -140,8 +160,8 @@ const WindowManagerCommon = {
scale_y: yScale,
x: xDest,
y: yDest,
- duration: MINIMIZE_WINDOW_ANIMATION_TIME,
- mode: MINIMIZE_WINDOW_ANIMATION_MODE,
+ duration: WindowManager.MINIMIZE_WINDOW_ANIMATION_TIME,
+ mode: WindowManager.MINIMIZE_WINDOW_ANIMATION_MODE,
onStopped: () => this._minimizeWindowDone(shellwm, actor),
});
// }
@@ -176,8 +196,8 @@ const WindowManagerCommon = {
actor.set_scale(1.0, 1.0);
actor.ease({
opacity: 255,
- duration: MINIMIZE_WINDOW_ANIMATION_TIME,
- mode: MINIMIZE_WINDOW_ANIMATION_MODE,
+ duration: WindowManager.MINIMIZE_WINDOW_ANIMATION_TIME,
+ mode: WindowManager.MINIMIZE_WINDOW_ANIMATION_MODE,
onStopped: () => this._unminimizeWindowDone(shellwm, actor),
});
} else { */
@@ -208,8 +228,8 @@ const WindowManagerCommon = {
scale_y: 1,
x: xDest,
y: yDest,
- duration: MINIMIZE_WINDOW_ANIMATION_TIME,
- mode: MINIMIZE_WINDOW_ANIMATION_MODE,
+ duration: WindowManager.MINIMIZE_WINDOW_ANIMATION_TIME,
+ mode: WindowManager.MINIMIZE_WINDOW_ANIMATION_MODE,
onStopped: () => this._unminimizeWindowDone(shellwm, actor),
});
// }