-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (28 loc) · 718 Bytes
/
index.js
File metadata and controls
31 lines (28 loc) · 718 Bytes
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
const registerShortcut = require('hyperterm-register-shortcut');
const floatingWindows = new Set([]);
let focusedWindow;
function registerWindow (win) {
win.on('focus', () => {
focusedWindow = win;
});
win.on('blur', () => {
if (focusedWindow === win) {
focusedWindow = undefined;
}
})
}
function toggleAlwaysOnTop () {
if (focusedWindow) {
if (floatingWindows.has(focusedWindow)) {
floatingWindows.delete(focusedWindow);
focusedWindow.setAlwaysOnTop(false);
} else {
floatingWindows.add(focusedWindow);
focusedWindow.setAlwaysOnTop(true);
}
}
}
module.exports = {
onApp: registerShortcut('float', toggleAlwaysOnTop),
onWindow: registerWindow
}