@raydiant/playlist-window-manager 0.0.0-test-11 → 0.0.0-test-13

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.
@@ -76,7 +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
+ var boundUtils_1 = require("./boundUtils");
80
80
  var BrowserWindowRenderer = /** @class */ (function () {
81
81
  function BrowserWindowRenderer(opts) {
82
82
  this.opts = opts;
@@ -89,7 +89,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
89
89
  show: false,
90
90
  frame: this.opts.frame,
91
91
  hasShadow: this.opts.hasShadow,
92
- fullscreen: (0, windowUtils_1.isFullscreen)(this.opts.bounds),
92
+ fullscreen: (0, boundUtils_1.isFullscreen)(this.opts.bounds),
93
93
  webPreferences: {
94
94
  preload: path.join(__dirname, 'preload.js'),
95
95
  },
@@ -134,7 +134,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
134
134
  : this.createOrGetPooledBrowserWindow(windowId, {
135
135
  show: false,
136
136
  frame: this.opts.frame,
137
- fullscreen: (0, windowUtils_1.isFullscreen)(this.opts.bounds),
137
+ fullscreen: (0, boundUtils_1.isFullscreen)(this.opts.bounds),
138
138
  // NOTE: useWindowPool: true does not work with renderChildWindowsAsBrowserViews: false
139
139
  // because the parent can't be changed after creating the BrowserWindow.
140
140
  parent: parentWindowId
@@ -385,12 +385,29 @@ var BrowserWindowRenderer = /** @class */ (function () {
385
385
  * 1919x1079.
386
386
  */
387
387
  BrowserWindowRenderer.prototype.setWindowOrViewBounds = function (window, bounds) {
388
+ this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds1: ".concat(JSON.stringify({
389
+ windowBounds: window.getBounds(),
390
+ bounds: bounds,
391
+ })));
392
+ // calling setBounds may introduce -1px resolution error
393
+ if ((0, boundUtils_1.areBoundsEqual)(window.getBounds(), bounds)) {
394
+ this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds2: bounds are equal");
395
+ return;
396
+ }
388
397
  // setBounds will be ignored if window was in fullscreen mode
389
- if (window instanceof electron_1.BrowserWindow && !(0, windowUtils_1.isFullscreen)(bounds)) {
398
+ if (window instanceof electron_1.BrowserWindow && !(0, boundUtils_1.isFullscreen)(bounds)) {
399
+ this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds3: not full screen");
390
400
  window.setFullScreen(false);
391
401
  }
402
+ this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds4: before: ".concat(JSON.stringify({
403
+ windowBounds: window.getBounds(),
404
+ })));
392
405
  window.setBounds(bounds);
393
- if (window instanceof electron_1.BrowserWindow && (0, windowUtils_1.isFullscreen)(bounds)) {
406
+ this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds5: before: ".concat(JSON.stringify({
407
+ windowBounds: window.getBounds(),
408
+ })));
409
+ if (window instanceof electron_1.BrowserWindow && (0, boundUtils_1.isFullscreen)(bounds)) {
410
+ this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds6: is full screen");
394
411
  window.setFullScreen(true);
395
412
  }
396
413
  };
@@ -1,2 +1,3 @@
1
1
  import { WindowBounds } from './types';
2
2
  export declare const isFullscreen: (bounds: WindowBounds) => boolean;
3
+ export declare const areBoundsEqual: (bounds1: WindowBounds, bounds2: WindowBounds) => boolean;
@@ -1,9 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFullscreen = void 0;
3
+ exports.areBoundsEqual = exports.isFullscreen = void 0;
4
4
  var electron_1 = require("electron");
5
5
  var isFullscreen = function (bounds) {
6
6
  var screenBounds = electron_1.screen.getPrimaryDisplay().bounds;
7
7
  return (bounds.width === screenBounds.width && bounds.height === screenBounds.height);
8
8
  };
9
9
  exports.isFullscreen = isFullscreen;
10
+ var areBoundsEqual = function (bounds1, bounds2) {
11
+ return (bounds1.x === bounds2.x &&
12
+ bounds1.y === bounds2.y &&
13
+ bounds1.width === bounds2.width &&
14
+ bounds1.height === bounds2.height);
15
+ };
16
+ exports.areBoundsEqual = areBoundsEqual;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raydiant/playlist-window-manager",
3
- "version": "0.0.0-test-11",
3
+ "version": "0.0.0-test-13",
4
4
  "description": "Window manager for playlist playback.",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -17,7 +17,7 @@ import {
17
17
  Logger,
18
18
  } from './types';
19
19
  import WindowUnresponsiveError from './WindowUnresponsiveError';
20
- import { isFullscreen } from './windowUtils';
20
+ import { areBoundsEqual, isFullscreen } from './boundUtils';
21
21
 
22
22
  interface ProxySettings {
23
23
  proxyRules: string;
@@ -475,12 +475,51 @@ export default class BrowserWindowRenderer
475
475
  window: BrowserWindow | BrowserView,
476
476
  bounds: WindowBounds
477
477
  ) {
478
+ this.logger.info(
479
+ `playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds1: ${JSON.stringify(
480
+ {
481
+ windowBounds: window.getBounds(),
482
+ bounds,
483
+ }
484
+ )}`
485
+ );
486
+
487
+ // calling setBounds may introduce -1px resolution error
488
+ if (areBoundsEqual(window.getBounds(), bounds)) {
489
+ this.logger.info(
490
+ `playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds2: bounds are equal`
491
+ );
492
+ return;
493
+ }
494
+
478
495
  // setBounds will be ignored if window was in fullscreen mode
479
496
  if (window instanceof BrowserWindow && !isFullscreen(bounds)) {
497
+ this.logger.info(
498
+ `playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds3: not full screen`
499
+ );
480
500
  window.setFullScreen(false);
481
501
  }
502
+
503
+ this.logger.info(
504
+ `playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds4: before: ${JSON.stringify(
505
+ {
506
+ windowBounds: window.getBounds(),
507
+ }
508
+ )}`
509
+ );
482
510
  window.setBounds(bounds);
511
+ this.logger.info(
512
+ `playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds5: before: ${JSON.stringify(
513
+ {
514
+ windowBounds: window.getBounds(),
515
+ }
516
+ )}`
517
+ );
518
+
483
519
  if (window instanceof BrowserWindow && isFullscreen(bounds)) {
520
+ this.logger.info(
521
+ `playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds6: is full screen`
522
+ );
484
523
  window.setFullScreen(true);
485
524
  }
486
525
  }
@@ -7,3 +7,15 @@ export const isFullscreen = (bounds: WindowBounds): boolean => {
7
7
  bounds.width === screenBounds.width && bounds.height === screenBounds.height
8
8
  );
9
9
  };
10
+
11
+ export const areBoundsEqual = (
12
+ bounds1: WindowBounds,
13
+ bounds2: WindowBounds
14
+ ): boolean => {
15
+ return (
16
+ bounds1.x === bounds2.x &&
17
+ bounds1.y === bounds2.y &&
18
+ bounds1.width === bounds2.width &&
19
+ bounds1.height === bounds2.height
20
+ );
21
+ };