-
Notifications
You must be signed in to change notification settings - Fork 18
/
background.js
67 lines (60 loc) · 1.77 KB
/
background.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('window.html', {
'state': 'fullscreen',
'bounds': {
'width': 1920,
'height': 1080
}
}, function(window) {
window.onClosed.addListener(function() {
setBounds(true);
setKeyboard(false);
});
setBounds(false);
setKeyboard(true);
});
});
function setBounds(restore) {
chrome.system.display.getInfo(function(displays) {
var display;
for (var i = 0; i < displays.length; i++) {
if (displays[i].isPrimary) {
display = displays[i];
break;
}
}
if (display) {
var targetWidth = 1920;
var targetHeight = 1080;
var width = display.bounds.width;
var height = display.bounds.height;
var overscan = {
'left': 0,
'right': 0,
'top': 0,
'bottom': 0
};
if (!restore) {
if (width > targetWidth) {
overscan.left = (width - targetWidth) / 2;
overscan.right = overscan.left;
}
if (height > targetHeight) {
overscan.top = (height - targetHeight) / 2;
overscan.bottom = overscan.top;
}
}
var info = {
'overscan': overscan
};
chrome.system.display.setDisplayProperties(display.id, info);
}
});
};
function setKeyboard(enable) {
if(chrome.accessibilityFeatures) {
chrome.accessibilityFeatures.virtualKeyboard.set({
value: enable
});
}
}