@raydiant/playlist-window-manager 0.0.0-test-8 → 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,14 +89,14 @@ var BrowserWindowRenderer = /** @class */ (function () {
88
89
  show: false,
89
90
  frame: this.opts.frame,
90
91
  hasShadow: this.opts.hasShadow,
91
- fullscreen: true,
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.setBounds(opts.bounds);
99
+ this.setWindowOrViewBounds(this.offscreenWindow, opts.bounds);
99
100
  opts.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts constructor2 ".concat(JSON.stringify({
100
101
  bounds: this.offscreenWindow.getBounds(),
101
102
  normalBounds: this.offscreenWindow.getNormalBounds(),
@@ -187,15 +188,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
187
188
  window.view.setBackgroundColor(backgroundColor === 'transparent' ? '#00000000' : backgroundColor);
188
189
  }
189
190
  this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createWindow4: ".concat(JSON.stringify(window.bounds)));
190
- // TODO zlv added
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
- }
191
+ this.setWindowOrViewBounds(window.view, window.bounds);
199
192
  this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createWindow7: ".concat(JSON.stringify(window.view.getBounds())));
200
193
  if (!this.proxySettings) return [3 /*break*/, 2];
201
194
  return [4 /*yield*/, window.view.webContents.session.setProxy(this.proxySettings)];
@@ -237,10 +230,11 @@ var BrowserWindowRenderer = /** @class */ (function () {
237
230
  this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds1: ".concat(JSON.stringify(bounds)));
238
231
  window.bounds = bounds;
239
232
  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
233
  // Child BrowserWindows are absolutely positioned so we need to add the main windows
242
234
  // x/y to when updating the child window's bounds.
243
- window.view.setBounds(__assign(__assign({}, window.bounds), { x: window.bounds.x + this.opts.bounds.x, y: window.bounds.y + this.opts.bounds.y }));
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);
244
238
  this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds3: ".concat(JSON.stringify({
245
239
  bounds: window.view.getBounds(),
246
240
  normalBounds: window.view.getNormalBounds(),
@@ -249,7 +243,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
249
243
  }
250
244
  else {
251
245
  this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds4: ".concat(JSON.stringify(window.bounds)));
252
- window.view.setBounds(window.bounds);
246
+ this.setWindowOrViewBounds(window.view, window.bounds);
253
247
  this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds5: ".concat(JSON.stringify(window.view.getBounds())));
254
248
  }
255
249
  };
@@ -354,6 +348,18 @@ var BrowserWindowRenderer = /** @class */ (function () {
354
348
  }
355
349
  window.view.webContents.setAudioMuted(false);
356
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
+ };
357
363
  BrowserWindowRenderer.prototype.getWindow = function (windowId) {
358
364
  return this.windows[windowId];
359
365
  };
@@ -0,0 +1,2 @@
1
+ import { WindowBounds } from './types';
2
+ export declare const isFullscreen: (bounds: WindowBounds) => boolean;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raydiant/playlist-window-manager",
3
- "version": "0.0.0-test-8",
3
+ "version": "0.0.0-test-9",
4
4
  "description": "Window manager for playlist playback.",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -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: true,
66
+ fullscreen: isFullscreen(this.opts.bounds),
66
67
  webPreferences: {
67
68
  preload: path.join(__dirname, 'preload.js'),
68
69
  },
@@ -78,7 +79,7 @@ export default class BrowserWindowRenderer
78
79
  opts.bounds
79
80
  )}`
80
81
  );
81
- this.offscreenWindow.setBounds(opts.bounds);
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
  {
@@ -232,18 +233,7 @@ export default class BrowserWindowRenderer
232
233
  window.bounds
233
234
  )}`
234
235
  );
235
- // TODO zlv added
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
- }
236
+ this.setWindowOrViewBounds(window.view, window.bounds);
247
237
  this.logger.info(
248
238
  `playlist-window-manager/src/BrowserWindowRenderer.ts createWindow7: ${JSON.stringify(
249
239
  window.view.getBounds()
@@ -285,23 +275,19 @@ export default class BrowserWindowRenderer
285
275
  window.bounds = bounds;
286
276
 
287
277
  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
278
  // Child BrowserWindows are absolutely positioned so we need to add the main windows
299
279
  // x/y to when updating the child window's bounds.
300
- window.view.setBounds({
280
+ const newBounds = {
301
281
  ...window.bounds,
302
282
  x: window.bounds.x + this.opts.bounds.x,
303
283
  y: window.bounds.y + this.opts.bounds.y,
304
- });
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);
305
291
 
306
292
  this.logger.info(
307
293
  `playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds3: ${JSON.stringify(
@@ -318,7 +304,7 @@ export default class BrowserWindowRenderer
318
304
  window.bounds
319
305
  )}`
320
306
  );
321
- window.view.setBounds(window.bounds);
307
+ this.setWindowOrViewBounds(window.view, window.bounds);
322
308
  this.logger.info(
323
309
  `playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds5: ${JSON.stringify(
324
310
  window.view.getBounds()
@@ -442,6 +428,22 @@ export default class BrowserWindowRenderer
442
428
  window.view.webContents.setAudioMuted(false);
443
429
  }
444
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
+
445
447
  private getWindow(windowId: string): BrowserWindowRendererWindow | null {
446
448
  return this.windows[windowId];
447
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
+ };