-
Notifications
You must be signed in to change notification settings - Fork 42
/
util.js
52 lines (40 loc) · 1.33 KB
/
util.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
44
45
46
47
48
49
50
51
52
const Config = imports.misc.config;
function versionCompare(first, second){
if (!first) first = Config.PACKAGE_VERSION;
first = first.split('.');
second = second.split('.');
for (let i = 0; i < first.length; i++){
first[i] = parseInt(first[i]);
}
for (let i = 0; i < second.length; i++){
second[i] = parseInt(second[i]);
}
for (let i = 0; i < first.length; i++){
if (i >= second.length) return 1;
if (first[i] != second[i])
return first[i] - second[i];
}
if (second.length > i) return -1;
return 0;
}
var Compatibility = class Compatibility{
constructor(){
let _wsmgr = global.workspace_manager;
let _screen = global.screen;
let _display = global.display;
if (_screen && (!_wsmgr || !_wsmgr.get_workspace_by_index || !_wsmgr.get_n_workspaces)) _wsmgr = null;
if (_screen && (!_display || !_display.get_current_monitor || !_display.get_monitor_geometry)) _display = null;
this._wsmgr = _wsmgr;
this._screen = _screen;
this._display = _display;
}
get_workspace_manager (){
return this._wsmgr || this._screen;
}
get_screen (){
return this._display || this._screen;
}
get_display (){
return this._display || this._screen.get_display();
}
}