@raydiant/playlist-window-manager 0.0.0-test-7 → 0.0.0-test-9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -33,6 +33,13 @@ export default class BrowserWindowRenderer implements PresentationWindowRenderer
|
|
|
33
33
|
sendMessageObject(windowId: string, type: string, payload?: any): void;
|
|
34
34
|
muteWindow(windowId: string): void;
|
|
35
35
|
unMuteWindow(windowId: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* This function is designed to solve missing 1px issue.
|
|
38
|
+
* If we set 1920x1080 bounds on 1920x1080 display
|
|
39
|
+
* then the actual BrowserWindow resolution would be
|
|
40
|
+
* 1919x1079.
|
|
41
|
+
*/
|
|
42
|
+
private setWindowOrViewBounds;
|
|
36
43
|
private getWindow;
|
|
37
44
|
private moveWindowOffscreen;
|
|
38
45
|
private addWindowToParent;
|
|
@@ -76,6 +76,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
76
76
|
var path = __importStar(require("path"));
|
|
77
77
|
var electron_1 = require("electron");
|
|
78
78
|
var WindowUnresponsiveError_1 = __importDefault(require("./WindowUnresponsiveError"));
|
|
79
|
+
var windowUtils_1 = require("./windowUtils");
|
|
79
80
|
var BrowserWindowRenderer = /** @class */ (function () {
|
|
80
81
|
function BrowserWindowRenderer(opts) {
|
|
81
82
|
this.opts = opts;
|
|
@@ -88,15 +89,14 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
88
89
|
show: false,
|
|
89
90
|
frame: this.opts.frame,
|
|
90
91
|
hasShadow: this.opts.hasShadow,
|
|
92
|
+
fullscreen: (0, windowUtils_1.isFullscreen)(this.opts.bounds),
|
|
91
93
|
webPreferences: {
|
|
92
94
|
preload: path.join(__dirname, 'preload.js'),
|
|
93
95
|
},
|
|
94
96
|
});
|
|
95
97
|
this.proxySettings = null;
|
|
96
98
|
opts.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts constructor1 ".concat(JSON.stringify(opts.bounds)));
|
|
97
|
-
|
|
98
|
-
this.offscreenWindow.setFullScreen(true);
|
|
99
|
-
this.offscreenWindow.setBounds(opts.bounds);
|
|
99
|
+
this.setWindowOrViewBounds(this.offscreenWindow, opts.bounds);
|
|
100
100
|
opts.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts constructor2 ".concat(JSON.stringify({
|
|
101
101
|
bounds: this.offscreenWindow.getBounds(),
|
|
102
102
|
normalBounds: this.offscreenWindow.getNormalBounds(),
|
|
@@ -188,16 +188,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
188
188
|
window.view.setBackgroundColor(backgroundColor === 'transparent' ? '#00000000' : backgroundColor);
|
|
189
189
|
}
|
|
190
190
|
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createWindow4: ".concat(JSON.stringify(window.bounds)));
|
|
191
|
-
|
|
192
|
-
if (window.view instanceof electron_1.BrowserWindow) {
|
|
193
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createWindow5: setFullScreen");
|
|
194
|
-
window.view.setFullScreen(true);
|
|
195
|
-
window.view.setBounds(window.bounds);
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createWindow6: setBounds");
|
|
199
|
-
window.view.setBounds(window.bounds);
|
|
200
|
-
}
|
|
191
|
+
this.setWindowOrViewBounds(window.view, window.bounds);
|
|
201
192
|
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createWindow7: ".concat(JSON.stringify(window.view.getBounds())));
|
|
202
193
|
if (!this.proxySettings) return [3 /*break*/, 2];
|
|
203
194
|
return [4 /*yield*/, window.view.webContents.session.setProxy(this.proxySettings)];
|
|
@@ -239,12 +230,11 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
239
230
|
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds1: ".concat(JSON.stringify(bounds)));
|
|
240
231
|
window.bounds = bounds;
|
|
241
232
|
if (window.view instanceof electron_1.BrowserWindow && window.parentWindowId) {
|
|
242
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds2: ".concat(JSON.stringify(__assign(__assign({}, window.bounds), { x: window.bounds.x + this.opts.bounds.x, y: window.bounds.y + this.opts.bounds.y }))));
|
|
243
233
|
// Child BrowserWindows are absolutely positioned so we need to add the main windows
|
|
244
234
|
// x/y to when updating the child window's bounds.
|
|
245
|
-
|
|
246
|
-
window.
|
|
247
|
-
|
|
235
|
+
var newBounds = __assign(__assign({}, window.bounds), { x: window.bounds.x + this.opts.bounds.x, y: window.bounds.y + this.opts.bounds.y });
|
|
236
|
+
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds2: ".concat(JSON.stringify(newBounds)));
|
|
237
|
+
this.setWindowOrViewBounds(window.view, newBounds);
|
|
248
238
|
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds3: ".concat(JSON.stringify({
|
|
249
239
|
bounds: window.view.getBounds(),
|
|
250
240
|
normalBounds: window.view.getNormalBounds(),
|
|
@@ -253,7 +243,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
253
243
|
}
|
|
254
244
|
else {
|
|
255
245
|
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds4: ".concat(JSON.stringify(window.bounds)));
|
|
256
|
-
window.view
|
|
246
|
+
this.setWindowOrViewBounds(window.view, window.bounds);
|
|
257
247
|
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds5: ".concat(JSON.stringify(window.view.getBounds())));
|
|
258
248
|
}
|
|
259
249
|
};
|
|
@@ -358,6 +348,18 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
358
348
|
}
|
|
359
349
|
window.view.webContents.setAudioMuted(false);
|
|
360
350
|
};
|
|
351
|
+
/**
|
|
352
|
+
* This function is designed to solve missing 1px issue.
|
|
353
|
+
* If we set 1920x1080 bounds on 1920x1080 display
|
|
354
|
+
* then the actual BrowserWindow resolution would be
|
|
355
|
+
* 1919x1079.
|
|
356
|
+
*/
|
|
357
|
+
BrowserWindowRenderer.prototype.setWindowOrViewBounds = function (window, bounds) {
|
|
358
|
+
window.setBounds(bounds);
|
|
359
|
+
if (window instanceof electron_1.BrowserWindow) {
|
|
360
|
+
window.setFullScreen((0, windowUtils_1.isFullscreen)(bounds));
|
|
361
|
+
}
|
|
362
|
+
};
|
|
361
363
|
BrowserWindowRenderer.prototype.getWindow = function (windowId) {
|
|
362
364
|
return this.windows[windowId];
|
|
363
365
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFullscreen = void 0;
|
|
4
|
+
var electron_1 = require("electron");
|
|
5
|
+
var isFullscreen = function (bounds) {
|
|
6
|
+
var screenBounds = electron_1.screen.getPrimaryDisplay().bounds;
|
|
7
|
+
return (bounds.width === screenBounds.width && bounds.height === screenBounds.height);
|
|
8
|
+
};
|
|
9
|
+
exports.isFullscreen = isFullscreen;
|
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
Logger,
|
|
17
17
|
} from './types';
|
|
18
18
|
import WindowUnresponsiveError from './WindowUnresponsiveError';
|
|
19
|
+
import { isFullscreen } from './windowUtils';
|
|
19
20
|
|
|
20
21
|
interface ProxySettings {
|
|
21
22
|
proxyRules: string;
|
|
@@ -62,6 +63,7 @@ export default class BrowserWindowRenderer
|
|
|
62
63
|
show: false,
|
|
63
64
|
frame: this.opts.frame,
|
|
64
65
|
hasShadow: this.opts.hasShadow,
|
|
66
|
+
fullscreen: isFullscreen(this.opts.bounds),
|
|
65
67
|
webPreferences: {
|
|
66
68
|
preload: path.join(__dirname, 'preload.js'),
|
|
67
69
|
},
|
|
@@ -77,9 +79,7 @@ export default class BrowserWindowRenderer
|
|
|
77
79
|
opts.bounds
|
|
78
80
|
)}`
|
|
79
81
|
);
|
|
80
|
-
|
|
81
|
-
this.offscreenWindow.setFullScreen(true);
|
|
82
|
-
this.offscreenWindow.setBounds(opts.bounds);
|
|
82
|
+
this.setWindowOrViewBounds(this.offscreenWindow, opts.bounds);
|
|
83
83
|
opts.logger.info(
|
|
84
84
|
`playlist-window-manager/src/BrowserWindowRenderer.ts constructor2 ${JSON.stringify(
|
|
85
85
|
{
|
|
@@ -233,19 +233,7 @@ export default class BrowserWindowRenderer
|
|
|
233
233
|
window.bounds
|
|
234
234
|
)}`
|
|
235
235
|
);
|
|
236
|
-
|
|
237
|
-
if (window.view instanceof BrowserWindow) {
|
|
238
|
-
this.logger.info(
|
|
239
|
-
`playlist-window-manager/src/BrowserWindowRenderer.ts createWindow5: setFullScreen`
|
|
240
|
-
);
|
|
241
|
-
window.view.setFullScreen(true);
|
|
242
|
-
window.view.setBounds(window.bounds);
|
|
243
|
-
} else {
|
|
244
|
-
this.logger.info(
|
|
245
|
-
`playlist-window-manager/src/BrowserWindowRenderer.ts createWindow6: setBounds`
|
|
246
|
-
);
|
|
247
|
-
window.view.setBounds(window.bounds);
|
|
248
|
-
}
|
|
236
|
+
this.setWindowOrViewBounds(window.view, window.bounds);
|
|
249
237
|
this.logger.info(
|
|
250
238
|
`playlist-window-manager/src/BrowserWindowRenderer.ts createWindow7: ${JSON.stringify(
|
|
251
239
|
window.view.getBounds()
|
|
@@ -287,25 +275,19 @@ export default class BrowserWindowRenderer
|
|
|
287
275
|
window.bounds = bounds;
|
|
288
276
|
|
|
289
277
|
if (window.view instanceof BrowserWindow && window.parentWindowId) {
|
|
290
|
-
this.logger.info(
|
|
291
|
-
`playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds2: ${JSON.stringify(
|
|
292
|
-
{
|
|
293
|
-
...window.bounds,
|
|
294
|
-
x: window.bounds.x + this.opts.bounds.x,
|
|
295
|
-
y: window.bounds.y + this.opts.bounds.y,
|
|
296
|
-
}
|
|
297
|
-
)}`
|
|
298
|
-
);
|
|
299
|
-
|
|
300
278
|
// Child BrowserWindows are absolutely positioned so we need to add the main windows
|
|
301
279
|
// x/y to when updating the child window's bounds.
|
|
302
|
-
|
|
303
|
-
window.view.setFullScreen(true);
|
|
304
|
-
window.view.setBounds({
|
|
280
|
+
const newBounds = {
|
|
305
281
|
...window.bounds,
|
|
306
282
|
x: window.bounds.x + this.opts.bounds.x,
|
|
307
283
|
y: window.bounds.y + this.opts.bounds.y,
|
|
308
|
-
}
|
|
284
|
+
};
|
|
285
|
+
this.logger.info(
|
|
286
|
+
`playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds2: ${JSON.stringify(
|
|
287
|
+
newBounds
|
|
288
|
+
)}`
|
|
289
|
+
);
|
|
290
|
+
this.setWindowOrViewBounds(window.view, newBounds);
|
|
309
291
|
|
|
310
292
|
this.logger.info(
|
|
311
293
|
`playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds3: ${JSON.stringify(
|
|
@@ -322,7 +304,7 @@ export default class BrowserWindowRenderer
|
|
|
322
304
|
window.bounds
|
|
323
305
|
)}`
|
|
324
306
|
);
|
|
325
|
-
window.view
|
|
307
|
+
this.setWindowOrViewBounds(window.view, window.bounds);
|
|
326
308
|
this.logger.info(
|
|
327
309
|
`playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds5: ${JSON.stringify(
|
|
328
310
|
window.view.getBounds()
|
|
@@ -446,6 +428,22 @@ export default class BrowserWindowRenderer
|
|
|
446
428
|
window.view.webContents.setAudioMuted(false);
|
|
447
429
|
}
|
|
448
430
|
|
|
431
|
+
/**
|
|
432
|
+
* This function is designed to solve missing 1px issue.
|
|
433
|
+
* If we set 1920x1080 bounds on 1920x1080 display
|
|
434
|
+
* then the actual BrowserWindow resolution would be
|
|
435
|
+
* 1919x1079.
|
|
436
|
+
*/
|
|
437
|
+
private setWindowOrViewBounds(
|
|
438
|
+
window: BrowserWindow | BrowserView,
|
|
439
|
+
bounds: WindowBounds
|
|
440
|
+
) {
|
|
441
|
+
window.setBounds(bounds);
|
|
442
|
+
if (window instanceof BrowserWindow) {
|
|
443
|
+
window.setFullScreen(isFullscreen(bounds));
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
449
447
|
private getWindow(windowId: string): BrowserWindowRendererWindow | null {
|
|
450
448
|
return this.windows[windowId];
|
|
451
449
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { screen } from 'electron';
|
|
2
|
+
import { WindowBounds } from './types';
|
|
3
|
+
|
|
4
|
+
export const isFullscreen = (bounds: WindowBounds): boolean => {
|
|
5
|
+
const screenBounds = screen.getPrimaryDisplay().bounds;
|
|
6
|
+
return (
|
|
7
|
+
bounds.width === screenBounds.width && bounds.height === screenBounds.height
|
|
8
|
+
);
|
|
9
|
+
};
|