@raydiant/playlist-window-manager 0.0.0-test-8 → 0.0.0-test-10
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,16 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
88
89
|
show: false,
|
|
89
90
|
frame: this.opts.frame,
|
|
90
91
|
hasShadow: this.opts.hasShadow,
|
|
91
|
-
fullscreen:
|
|
92
|
+
fullscreen: (0, windowUtils_1.isFullscreen)(this.opts.bounds),
|
|
92
93
|
webPreferences: {
|
|
93
94
|
preload: path.join(__dirname, 'preload.js'),
|
|
94
95
|
},
|
|
95
96
|
});
|
|
96
97
|
this.proxySettings = null;
|
|
97
98
|
opts.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts constructor1 ".concat(JSON.stringify(opts.bounds)));
|
|
98
|
-
this.offscreenWindow
|
|
99
|
+
this.setWindowOrViewBounds(this.offscreenWindow, opts.bounds);
|
|
99
100
|
opts.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts constructor2 ".concat(JSON.stringify({
|
|
101
|
+
fullscreen: this.offscreenWindow.isFullScreen(),
|
|
100
102
|
bounds: this.offscreenWindow.getBounds(),
|
|
101
103
|
normalBounds: this.offscreenWindow.getNormalBounds(),
|
|
102
104
|
contentBounds: this.offscreenWindow.getContentBounds(),
|
|
@@ -132,6 +134,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
132
134
|
: this.createOrGetPooledBrowserWindow(windowId, {
|
|
133
135
|
show: false,
|
|
134
136
|
frame: this.opts.frame,
|
|
137
|
+
fullscreen: (0, windowUtils_1.isFullscreen)(this.opts.bounds),
|
|
135
138
|
// NOTE: useWindowPool: true does not work with renderChildWindowsAsBrowserViews: false
|
|
136
139
|
// because the parent can't be changed after creating the BrowserWindow.
|
|
137
140
|
parent: parentWindowId
|
|
@@ -173,6 +176,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
173
176
|
if (window.view instanceof electron_1.BrowserView) {
|
|
174
177
|
this.moveWindowOffscreen(window);
|
|
175
178
|
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createWindow2: ".concat(JSON.stringify({
|
|
179
|
+
fullscreen: this.offscreenWindow.isFullScreen(),
|
|
176
180
|
bounds: this.offscreenWindow.getBounds(),
|
|
177
181
|
normalBounds: this.offscreenWindow.getNormalBounds(),
|
|
178
182
|
contentBounds: this.offscreenWindow.getContentBounds(),
|
|
@@ -187,15 +191,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
187
191
|
window.view.setBackgroundColor(backgroundColor === 'transparent' ? '#00000000' : backgroundColor);
|
|
188
192
|
}
|
|
189
193
|
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createWindow4: ".concat(JSON.stringify(window.bounds)));
|
|
190
|
-
|
|
191
|
-
if (window.view instanceof electron_1.BrowserWindow) {
|
|
192
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createWindow5:");
|
|
193
|
-
window.view.setBounds(window.bounds);
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createWindow6: setBounds");
|
|
197
|
-
window.view.setBounds(window.bounds);
|
|
198
|
-
}
|
|
194
|
+
this.setWindowOrViewBounds(window.view, window.bounds);
|
|
199
195
|
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createWindow7: ".concat(JSON.stringify(window.view.getBounds())));
|
|
200
196
|
if (!this.proxySettings) return [3 /*break*/, 2];
|
|
201
197
|
return [4 /*yield*/, window.view.webContents.session.setProxy(this.proxySettings)];
|
|
@@ -237,11 +233,13 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
237
233
|
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds1: ".concat(JSON.stringify(bounds)));
|
|
238
234
|
window.bounds = bounds;
|
|
239
235
|
if (window.view instanceof electron_1.BrowserWindow && window.parentWindowId) {
|
|
240
|
-
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 }))));
|
|
241
236
|
// Child BrowserWindows are absolutely positioned so we need to add the main windows
|
|
242
237
|
// x/y to when updating the child window's bounds.
|
|
243
|
-
|
|
238
|
+
var newBounds = __assign(__assign({}, window.bounds), { x: window.bounds.x + this.opts.bounds.x, y: window.bounds.y + this.opts.bounds.y });
|
|
239
|
+
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds2: ".concat(JSON.stringify(newBounds)));
|
|
240
|
+
this.setWindowOrViewBounds(window.view, newBounds);
|
|
244
241
|
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds3: ".concat(JSON.stringify({
|
|
242
|
+
fullscreen: window.view.isFullScreen(),
|
|
245
243
|
bounds: window.view.getBounds(),
|
|
246
244
|
normalBounds: window.view.getNormalBounds(),
|
|
247
245
|
contentBounds: window.view.getContentBounds(),
|
|
@@ -249,7 +247,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
249
247
|
}
|
|
250
248
|
else {
|
|
251
249
|
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds4: ".concat(JSON.stringify(window.bounds)));
|
|
252
|
-
window.view
|
|
250
|
+
this.setWindowOrViewBounds(window.view, window.bounds);
|
|
253
251
|
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds5: ".concat(JSON.stringify(window.view.getBounds())));
|
|
254
252
|
}
|
|
255
253
|
};
|
|
@@ -354,6 +352,22 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
354
352
|
}
|
|
355
353
|
window.view.webContents.setAudioMuted(false);
|
|
356
354
|
};
|
|
355
|
+
/**
|
|
356
|
+
* This function is designed to solve missing 1px issue.
|
|
357
|
+
* If we set 1920x1080 bounds on 1920x1080 display
|
|
358
|
+
* then the actual BrowserWindow resolution would be
|
|
359
|
+
* 1919x1079.
|
|
360
|
+
*/
|
|
361
|
+
BrowserWindowRenderer.prototype.setWindowOrViewBounds = function (window, bounds) {
|
|
362
|
+
// setBounds will be ignored if window was in fullscreen mode
|
|
363
|
+
if (window instanceof electron_1.BrowserWindow && !(0, windowUtils_1.isFullscreen)(bounds)) {
|
|
364
|
+
window.setFullScreen(false);
|
|
365
|
+
}
|
|
366
|
+
window.setBounds(bounds);
|
|
367
|
+
if (window instanceof electron_1.BrowserWindow && (0, windowUtils_1.isFullscreen)(bounds)) {
|
|
368
|
+
window.setFullScreen(true);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
357
371
|
BrowserWindowRenderer.prototype.getWindow = function (windowId) {
|
|
358
372
|
return this.windows[windowId];
|
|
359
373
|
};
|
|
@@ -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,7 +63,7 @@ export default class BrowserWindowRenderer
|
|
|
62
63
|
show: false,
|
|
63
64
|
frame: this.opts.frame,
|
|
64
65
|
hasShadow: this.opts.hasShadow,
|
|
65
|
-
fullscreen:
|
|
66
|
+
fullscreen: isFullscreen(this.opts.bounds),
|
|
66
67
|
webPreferences: {
|
|
67
68
|
preload: path.join(__dirname, 'preload.js'),
|
|
68
69
|
},
|
|
@@ -78,10 +79,11 @@ export default class BrowserWindowRenderer
|
|
|
78
79
|
opts.bounds
|
|
79
80
|
)}`
|
|
80
81
|
);
|
|
81
|
-
this.offscreenWindow
|
|
82
|
+
this.setWindowOrViewBounds(this.offscreenWindow, opts.bounds);
|
|
82
83
|
opts.logger.info(
|
|
83
84
|
`playlist-window-manager/src/BrowserWindowRenderer.ts constructor2 ${JSON.stringify(
|
|
84
85
|
{
|
|
86
|
+
fullscreen: this.offscreenWindow.isFullScreen(),
|
|
85
87
|
bounds: this.offscreenWindow.getBounds(),
|
|
86
88
|
normalBounds: this.offscreenWindow.getNormalBounds(),
|
|
87
89
|
contentBounds: this.offscreenWindow.getContentBounds(),
|
|
@@ -107,7 +109,7 @@ export default class BrowserWindowRenderer
|
|
|
107
109
|
backgroundColor,
|
|
108
110
|
receiveMessageCallback,
|
|
109
111
|
errorCallback,
|
|
110
|
-
}: CreateWindowOptions) {
|
|
112
|
+
}: CreateWindowOptions): Promise<void> {
|
|
111
113
|
this.logger.info(
|
|
112
114
|
`playlist-window-manager/src/BrowserWindowRenderer.ts createWindow1: ${JSON.stringify(
|
|
113
115
|
parentWindowId && !this.opts.renderChildWindowsAsBrowserViews
|
|
@@ -133,6 +135,7 @@ export default class BrowserWindowRenderer
|
|
|
133
135
|
: this.createOrGetPooledBrowserWindow(windowId, {
|
|
134
136
|
show: false,
|
|
135
137
|
frame: this.opts.frame,
|
|
138
|
+
fullscreen: isFullscreen(this.opts.bounds),
|
|
136
139
|
// NOTE: useWindowPool: true does not work with renderChildWindowsAsBrowserViews: false
|
|
137
140
|
// because the parent can't be changed after creating the BrowserWindow.
|
|
138
141
|
parent: parentWindowId
|
|
@@ -207,6 +210,7 @@ export default class BrowserWindowRenderer
|
|
|
207
210
|
this.logger.info(
|
|
208
211
|
`playlist-window-manager/src/BrowserWindowRenderer.ts createWindow2: ${JSON.stringify(
|
|
209
212
|
{
|
|
213
|
+
fullscreen: this.offscreenWindow.isFullScreen(),
|
|
210
214
|
bounds: this.offscreenWindow.getBounds(),
|
|
211
215
|
normalBounds: this.offscreenWindow.getNormalBounds(),
|
|
212
216
|
contentBounds: this.offscreenWindow.getContentBounds(),
|
|
@@ -232,18 +236,7 @@ export default class BrowserWindowRenderer
|
|
|
232
236
|
window.bounds
|
|
233
237
|
)}`
|
|
234
238
|
);
|
|
235
|
-
|
|
236
|
-
if (window.view instanceof BrowserWindow) {
|
|
237
|
-
this.logger.info(
|
|
238
|
-
`playlist-window-manager/src/BrowserWindowRenderer.ts createWindow5:`
|
|
239
|
-
);
|
|
240
|
-
window.view.setBounds(window.bounds);
|
|
241
|
-
} else {
|
|
242
|
-
this.logger.info(
|
|
243
|
-
`playlist-window-manager/src/BrowserWindowRenderer.ts createWindow6: setBounds`
|
|
244
|
-
);
|
|
245
|
-
window.view.setBounds(window.bounds);
|
|
246
|
-
}
|
|
239
|
+
this.setWindowOrViewBounds(window.view, window.bounds);
|
|
247
240
|
this.logger.info(
|
|
248
241
|
`playlist-window-manager/src/BrowserWindowRenderer.ts createWindow7: ${JSON.stringify(
|
|
249
242
|
window.view.getBounds()
|
|
@@ -285,27 +278,24 @@ export default class BrowserWindowRenderer
|
|
|
285
278
|
window.bounds = bounds;
|
|
286
279
|
|
|
287
280
|
if (window.view instanceof BrowserWindow && window.parentWindowId) {
|
|
288
|
-
this.logger.info(
|
|
289
|
-
`playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds2: ${JSON.stringify(
|
|
290
|
-
{
|
|
291
|
-
...window.bounds,
|
|
292
|
-
x: window.bounds.x + this.opts.bounds.x,
|
|
293
|
-
y: window.bounds.y + this.opts.bounds.y,
|
|
294
|
-
}
|
|
295
|
-
)}`
|
|
296
|
-
);
|
|
297
|
-
|
|
298
281
|
// Child BrowserWindows are absolutely positioned so we need to add the main windows
|
|
299
282
|
// x/y to when updating the child window's bounds.
|
|
300
|
-
|
|
283
|
+
const newBounds = {
|
|
301
284
|
...window.bounds,
|
|
302
285
|
x: window.bounds.x + this.opts.bounds.x,
|
|
303
286
|
y: window.bounds.y + this.opts.bounds.y,
|
|
304
|
-
}
|
|
287
|
+
};
|
|
288
|
+
this.logger.info(
|
|
289
|
+
`playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds2: ${JSON.stringify(
|
|
290
|
+
newBounds
|
|
291
|
+
)}`
|
|
292
|
+
);
|
|
293
|
+
this.setWindowOrViewBounds(window.view, newBounds);
|
|
305
294
|
|
|
306
295
|
this.logger.info(
|
|
307
296
|
`playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds3: ${JSON.stringify(
|
|
308
297
|
{
|
|
298
|
+
fullscreen: window.view.isFullScreen(),
|
|
309
299
|
bounds: window.view.getBounds(),
|
|
310
300
|
normalBounds: window.view.getNormalBounds(),
|
|
311
301
|
contentBounds: window.view.getContentBounds(),
|
|
@@ -318,7 +308,7 @@ export default class BrowserWindowRenderer
|
|
|
318
308
|
window.bounds
|
|
319
309
|
)}`
|
|
320
310
|
);
|
|
321
|
-
window.view
|
|
311
|
+
this.setWindowOrViewBounds(window.view, window.bounds);
|
|
322
312
|
this.logger.info(
|
|
323
313
|
`playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds5: ${JSON.stringify(
|
|
324
314
|
window.view.getBounds()
|
|
@@ -442,6 +432,26 @@ export default class BrowserWindowRenderer
|
|
|
442
432
|
window.view.webContents.setAudioMuted(false);
|
|
443
433
|
}
|
|
444
434
|
|
|
435
|
+
/**
|
|
436
|
+
* This function is designed to solve missing 1px issue.
|
|
437
|
+
* If we set 1920x1080 bounds on 1920x1080 display
|
|
438
|
+
* then the actual BrowserWindow resolution would be
|
|
439
|
+
* 1919x1079.
|
|
440
|
+
*/
|
|
441
|
+
private setWindowOrViewBounds(
|
|
442
|
+
window: BrowserWindow | BrowserView,
|
|
443
|
+
bounds: WindowBounds
|
|
444
|
+
) {
|
|
445
|
+
// setBounds will be ignored if window was in fullscreen mode
|
|
446
|
+
if (window instanceof BrowserWindow && !isFullscreen(bounds)) {
|
|
447
|
+
window.setFullScreen(false);
|
|
448
|
+
}
|
|
449
|
+
window.setBounds(bounds);
|
|
450
|
+
if (window instanceof BrowserWindow && isFullscreen(bounds)) {
|
|
451
|
+
window.setFullScreen(true);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
445
455
|
private getWindow(windowId: string): BrowserWindowRendererWindow | null {
|
|
446
456
|
return this.windows[windowId];
|
|
447
457
|
}
|
|
@@ -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
|
+
};
|