@raydiant/playlist-window-manager 0.0.0-test-12 → 0.0.0-test-14

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,22 +385,43 @@ var BrowserWindowRenderer = /** @class */ (function () {
385
385
  * 1919x1079.
386
386
  */
387
387
  BrowserWindowRenderer.prototype.setWindowOrViewBounds = function (window, bounds) {
388
- var currentBounds = window.getBounds();
389
- // calling setBounds may introduce -1px bug
390
- if (currentBounds.x === bounds.x ||
391
- currentBounds.y === bounds.y ||
392
- currentBounds.width === bounds.width ||
393
- currentBounds.height === bounds.height) {
388
+ if (window instanceof electron_1.BrowserView) {
389
+ this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds1: ".concat(JSON.stringify({
390
+ windowBounds: window.getBounds(),
391
+ bounds: bounds,
392
+ })));
393
+ window.setBounds(bounds);
394
394
  return;
395
395
  }
396
- // setBounds will be ignored if window was in fullscreen mode
397
- if (window instanceof electron_1.BrowserWindow && !(0, windowUtils_1.isFullscreen)(bounds)) {
398
- window.setFullScreen(false);
396
+ this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds2: ".concat(JSON.stringify({
397
+ newBounds: bounds,
398
+ fullscreen: window.isFullScreen(),
399
+ bounds: window.getBounds(),
400
+ contentBounds: window.getContentBounds(),
401
+ normalBounds: window.getNormalBounds(),
402
+ })));
403
+ // calling setBounds or setFullscreen may introduce -1px resolution error
404
+ // so we try to avoid unnecessary calls
405
+ if ((0, boundUtils_1.areBoundsEqual)(window.getBounds(), bounds) ||
406
+ ((0, boundUtils_1.isFullscreen)(bounds) && window.isFullScreen())) {
407
+ this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds3: bounds are equal");
408
+ return;
399
409
  }
400
- window.setBounds(bounds);
401
- if (window instanceof electron_1.BrowserWindow && (0, windowUtils_1.isFullscreen)(bounds)) {
410
+ if ((0, boundUtils_1.isFullscreen)(bounds)) {
411
+ this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds4: full screen");
402
412
  window.setFullScreen(true);
403
413
  }
414
+ else {
415
+ // setBounds will be ignored if window was in fullscreen mode
416
+ window.setFullScreen(false);
417
+ window.setBounds(bounds);
418
+ }
419
+ this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds6: before: ".concat(JSON.stringify({
420
+ fullscreen: window.isFullScreen(),
421
+ bounds: window.getBounds(),
422
+ contentBounds: window.getContentBounds(),
423
+ normalBounds: window.getNormalBounds(),
424
+ })));
404
425
  };
405
426
  BrowserWindowRenderer.prototype.getWindow = function (windowId) {
406
427
  return this.windows[windowId];
@@ -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-12",
3
+ "version": "0.0.0-test-14",
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,27 +475,64 @@ export default class BrowserWindowRenderer
475
475
  window: BrowserWindow | BrowserView,
476
476
  bounds: WindowBounds
477
477
  ) {
478
- const currentBounds = window.getBounds();
479
- // calling setBounds may introduce -1px bug
478
+ if (window instanceof BrowserView) {
479
+ this.logger.info(
480
+ `playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds1: ${JSON.stringify(
481
+ {
482
+ windowBounds: window.getBounds(),
483
+ bounds,
484
+ }
485
+ )}`
486
+ );
487
+ window.setBounds(bounds);
488
+ return;
489
+ }
490
+
491
+ this.logger.info(
492
+ `playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds2: ${JSON.stringify(
493
+ {
494
+ newBounds: bounds,
495
+ fullscreen: window.isFullScreen(),
496
+ bounds: window.getBounds(),
497
+ contentBounds: window.getContentBounds(),
498
+ normalBounds: window.getNormalBounds(),
499
+ }
500
+ )}`
501
+ );
502
+
503
+ // calling setBounds or setFullscreen may introduce -1px resolution error
504
+ // so we try to avoid unnecessary calls
480
505
  if (
481
- currentBounds.x === bounds.x ||
482
- currentBounds.y === bounds.y ||
483
- currentBounds.width === bounds.width ||
484
- currentBounds.height === bounds.height
506
+ areBoundsEqual(window.getBounds(), bounds) ||
507
+ (isFullscreen(bounds) && window.isFullScreen())
485
508
  ) {
509
+ this.logger.info(
510
+ `playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds3: bounds are equal`
511
+ );
486
512
  return;
487
513
  }
488
514
 
489
- // setBounds will be ignored if window was in fullscreen mode
490
- if (window instanceof BrowserWindow && !isFullscreen(bounds)) {
515
+ if (isFullscreen(bounds)) {
516
+ this.logger.info(
517
+ `playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds4: full screen`
518
+ );
519
+ window.setFullScreen(true);
520
+ } else {
521
+ // setBounds will be ignored if window was in fullscreen mode
491
522
  window.setFullScreen(false);
523
+ window.setBounds(bounds);
492
524
  }
493
525
 
494
- window.setBounds(bounds);
495
-
496
- if (window instanceof BrowserWindow && isFullscreen(bounds)) {
497
- window.setFullScreen(true);
498
- }
526
+ this.logger.info(
527
+ `playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds6: before: ${JSON.stringify(
528
+ {
529
+ fullscreen: window.isFullScreen(),
530
+ bounds: window.getBounds(),
531
+ contentBounds: window.getContentBounds(),
532
+ normalBounds: window.getNormalBounds(),
533
+ }
534
+ )}`
535
+ );
499
536
  }
500
537
 
501
538
  private getWindow(windowId: string): BrowserWindowRendererWindow | null {
@@ -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
+ };