Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
84 lines (70 loc) · 1.92 KB
/
Copy pathindex.js
File metadata and controls
84 lines (70 loc) · 1.92 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
'use strict';
const electron = require('electron');
const app = electron.app;
const titleBarHeight = 24;
const progressBarHeight = 24;
const chatWidth = 325;
// adds debug features like hotkeys for triggering dev tools and reload
require('electron-debug')();
// prevent window being garbage collected
let mainWindow;
let childWindow;
function onClosed() {
// dereference the window
// for multiple windows store them in an array
mainWindow = null;
childWindow = null;
}
function onMoved(stack, things) {
var pos = mainWindow.getPosition();
childWindow.setPosition(pos[0], pos[1] + titleBarHeight, true);
}
function onResized() {
// TODO: maybe?
}
function createChildWindow() {
var pos = mainWindow.getPosition();
childWindow = new electron.BrowserWindow({
parent: mainWindow,
width: 1280,
height: 720,
transparent: true,
frame: false,
resizable: false,
});
childWindow.setPosition(pos[0], pos[1] + titleBarHeight, false);
childWindow.setIgnoreMouseEvents(true);
childWindow.setSkipTaskbar(true);
childWindow.show();
childWindow.setAspectRatio(16/9);
var windowHandle = childWindow.getNativeWindowHandle().readUInt32LE(0);
global.mpvWindow = windowHandle;
}
function createMainWindow() {
const win = new electron.BrowserWindow({
width: 1280 + chatWidth,
height: 720 + titleBarHeight + progressBarHeight,
frame: false
});
win.loadURL(`file://${__dirname}/client/index.html`);
win.on('closed', onClosed);
win.on("move", onMoved);
win.on("resize", onResized);
return win;
}
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (!mainWindow) {
mainWindow = createMainWindow();
createChildWindow();
}
});
app.on('ready', () => {
mainWindow = createMainWindow();
mainWindow.setAspectRatio(16/9, [chatWidth, titleBarHeight + progressBarHeight]); // TODO: figure out why this is completely and utterly broken
createChildWindow();
});