File: extension.js

package info (click to toggle)
gnome-shell-extension-no-annoyance 0%2B20170928-f21d09a-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 80 kB
  • sloc: makefile: 2
file content (57 lines) | stat: -rw-r--r-- 1,263 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const Main = imports.ui.main;
const WindowAttentionHandler = imports.ui.windowAttentionHandler;
const Shell = imports.gi.Shell;
const Lang = imports.lang;

function StealMyFocus() {
  this._init();
}

function WindowIsReadyRemover() {
  this._init();
}

StealMyFocus.prototype = {
  _init : function() {
    this._tracker = Shell.WindowTracker.get_default();
    this._handlerid = global.display.connect('window-demands-attention', Lang.bind(this, this._onWindowDemandsAttention));
  },

  _onWindowDemandsAttention: function(display, window) {
    Main.activateWindow(window);
  },

  destroy: function () {
    global.display.disconnect(this._handlerid);
  }
}


WindowIsReadyRemover.prototype = {

  _init : function() {
    this._tracker = Shell.WindowTracker.get_default();
    log('Disabling Window Is Ready Notification')
    global.display.disconnect(Main.windowAttentionHandler._windowDemandsAttentionId);
  },

  destroy: function () {
    global.display.disconnect(this._handlerid);
  }
}

let windowIsReadyRemover;
let stealmyfocus;

function init() {
}

function enable() {
  stealmyfocus = new StealMyFocus();
  windowIsReadyRemover = new WindowIsReadyRemover();
}

function disable() {
  stealmyfocus.destroy();
  windowIsReadyRemover.destroy();
}