summaryrefslogtreecommitdiffstats
path: root/extensions/44/vertical-workspaces/lib/windowAttentionHandler.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--extensions/44/vertical-workspaces/lib/windowAttentionHandler.js (renamed from extensions/vertical-workspaces/lib/windowAttentionHandler.js)80
1 files changed, 51 insertions, 29 deletions
diff --git a/extensions/vertical-workspaces/lib/windowAttentionHandler.js b/extensions/44/vertical-workspaces/lib/windowAttentionHandler.js
index 10703c2..a3db986 100644
--- a/extensions/vertical-workspaces/lib/windowAttentionHandler.js
+++ b/extensions/44/vertical-workspaces/lib/windowAttentionHandler.js
@@ -11,47 +11,69 @@
'use strict';
const Main = imports.ui.main;
-const WindowAttentionHandler = imports.ui.windowAttentionHandler;
const MessageTray = imports.ui.messageTray;
-const ExtensionUtils = imports.misc.extensionUtils;
-const Me = ExtensionUtils.getCurrentExtension();
-
-const _Util = Me.imports.lib.util;
+const WindowAttentionHandler = imports.ui.windowAttentionHandler;
+let Me;
let opt;
-let _firstRun = false;
-function update(reset = false) {
- opt = Me.imports.lib.settings.opt;
- const moduleEnabled = opt.get('winAttentionHandlerModule', true);
- reset = reset || !moduleEnabled;
+var WindowAttentionHandlerModule = class {
+ constructor(me) {
+ Me = me;
+ opt = Me.opt;
- if (_firstRun && reset)
- return;
+ this._firstActivation = true;
+ this.moduleEnabled = false;
+ this._overrides = null;
+ }
- _firstRun = false;
- if (reset) {
- reset = true;
- _updateConnections(reset);
+ cleanGlobals() {
+ Me = null;
opt = null;
- return;
}
- _updateConnections();
-}
+ update(reset) {
+ this.moduleEnabled = opt.get('windowAttentionHandlerModule');
+ const conflict = false;
-function _updateConnections(reset) {
- global.display.disconnectObject(Main.windowAttentionHandler);
+ reset = reset || !this.moduleEnabled || conflict;
- const handlerFnc = reset
- ? Main.windowAttentionHandler._onWindowDemandsAttention
- : WindowAttentionHandlerCommon._onWindowDemandsAttention;
+ // 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(' WindowAttentionHandlerModule - Keeping untouched');
+ }
+
+ _activateModule() {
+ this._updateConnections();
+ console.debug(' WindowAttentionHandlerModule - Activated');
+ }
- global.display.connectObject(
- 'window-demands-attention', handlerFnc.bind(Main.windowAttentionHandler),
- 'window-marked-urgent', handlerFnc.bind(Main.windowAttentionHandler),
- Main.windowAttentionHandler);
-}
+ _disableModule() {
+ const reset = true;
+ this._updateConnections(reset);
+
+ console.debug(' WindowAttentionHandlerModule - Disabled');
+ }
+
+ _updateConnections(reset) {
+ global.display.disconnectObject(Main.windowAttentionHandler);
+
+ const handlerFnc = reset
+ ? Main.windowAttentionHandler._onWindowDemandsAttention
+ : WindowAttentionHandlerCommon._onWindowDemandsAttention;
+
+ global.display.connectObject(
+ 'window-demands-attention', handlerFnc.bind(Main.windowAttentionHandler),
+ 'window-marked-urgent', handlerFnc.bind(Main.windowAttentionHandler),
+ Main.windowAttentionHandler);
+ }
+};
const WindowAttentionHandlerCommon = {
_onWindowDemandsAttention(display, window) {