forked from darkretailer/gnome-shell-extension_maxi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.js
43 lines (38 loc) · 1.62 KB
/
extension.js
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
import Meta from 'gi://Meta';
import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';
export default class MaxiExtension extends Extension {
enable() {
this._settings = this.getSettings();
this._windowCreatedId = global.display.connect('window-created', (d, win) => {
win._maxievtId = win.connect('focus', (win) => {
const DEBUG = this._settings.get_boolean('debug');
if (DEBUG) {
global.log(" \
gnome-extension [email protected]: gtk_application_id: "
+ win.gtk_application_id
);
}
if (!this._settings.get_strv('blacklisted-apps').includes(win.gtk_application_id + ".desktop")) {
if (win.can_maximize()) {
if (this._settings.get_boolean('vertical')) {
win.maximize(Meta.MaximizeFlags.VERTICAL);
}
if (this._settings.get_boolean('horizontal')) {
win.maximize(Meta.MaximizeFlags.HORIZONTAL);
}
}
} else {
if (DEBUG) {
global.log('gnome-extension [email protected]: "' + win.gtk_application_id + '" is blacklisted');
}
}
win.disconnect(win._maxievtId);
});
});
}
disable() {
global.display.disconnect(this._windowCreatedId);
this._windowCreatedId = null;
this._settings = null;
}
}