1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
18 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
19 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
20 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
21 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
22 | };
|
23 | Object.defineProperty(exports, "__esModule", { value: true });
|
24 | exports.ElectronSecondaryWindowService = void 0;
|
25 | const electronRemote = require("../../../electron-shared/@electron/remote");
|
26 | const inversify_1 = require("inversify");
|
27 | const default_secondary_window_service_1 = require("../../browser/window/default-secondary-window-service");
|
28 | let ElectronSecondaryWindowService = class ElectronSecondaryWindowService extends default_secondary_window_service_1.DefaultSecondaryWindowService {
|
29 | constructor() {
|
30 | super(...arguments);
|
31 | this.electronWindows = new Map();
|
32 | }
|
33 | doCreateSecondaryWindow(onClose) {
|
34 | const id = this.nextWindowId();
|
35 | electronRemote.getCurrentWindow().webContents.once('did-create-window', newElectronWindow => {
|
36 | newElectronWindow.setMenuBarVisibility(false);
|
37 | this.electronWindows.set(id, newElectronWindow);
|
38 | newElectronWindow.on('closed', () => {
|
39 | this.electronWindows.delete(id);
|
40 | const browserWin = this.secondaryWindows.find(w => w.name === id);
|
41 | if (browserWin) {
|
42 | this.handleWindowClosed(browserWin, onClose);
|
43 | }
|
44 | else {
|
45 | console.warn(`Could not execute proper close handling for secondary window '${id}' because its frontend window could not be found.`);
|
46 | }
|
47 | ;
|
48 | });
|
49 | });
|
50 | const win = window.open(default_secondary_window_service_1.DefaultSecondaryWindowService.SECONDARY_WINDOW_URL, id);
|
51 | return win !== null && win !== void 0 ? win : undefined;
|
52 | }
|
53 | focus(win) {
|
54 |
|
55 | const electronWindow = this.electronWindows.get(win.name);
|
56 | if (electronWindow) {
|
57 | if (electronWindow.isMinimized()) {
|
58 | electronWindow.restore();
|
59 | }
|
60 | electronWindow.focus();
|
61 | }
|
62 | else {
|
63 | console.warn(`There is no known secondary window '${win.name}'. Thus, the window could not be focussed.`);
|
64 | }
|
65 | }
|
66 | };
|
67 | ElectronSecondaryWindowService = __decorate([
|
68 | (0, inversify_1.injectable)()
|
69 | ], ElectronSecondaryWindowService);
|
70 | exports.ElectronSecondaryWindowService = ElectronSecondaryWindowService;
|
71 |
|
\ | No newline at end of file |