2020-07-28 18:04:01 +00:00
|
|
|
const { createScreen } = process._linkedBinding('electron_common_screen');
|
2019-04-30 00:46:08 +00:00
|
|
|
|
2020-07-28 18:04:01 +00:00
|
|
|
let _screen: Electron.Screen;
|
2019-04-30 00:46:08 +00:00
|
|
|
|
2020-07-28 18:04:01 +00:00
|
|
|
// We can't call createScreen until after app.on('ready'), but this module
|
|
|
|
// exposes an instance created by createScreen. In order to avoid
|
|
|
|
// side-effecting and calling createScreen upon import of this module, instead
|
|
|
|
// we export a proxy which lazily calls createScreen on first access.
|
|
|
|
export default new Proxy({}, {
|
2020-10-08 01:01:23 +00:00
|
|
|
get: (target, prop: keyof Electron.Screen) => {
|
2020-07-28 18:04:01 +00:00
|
|
|
if (_screen === undefined) {
|
|
|
|
_screen = createScreen();
|
|
|
|
}
|
2020-10-08 01:01:23 +00:00
|
|
|
const v = _screen[prop];
|
2020-07-28 18:04:01 +00:00
|
|
|
if (typeof v === 'function') {
|
|
|
|
return v.bind(_screen);
|
|
|
|
}
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
});
|