Skip to content

Commit 42d9030

Browse files
author
Alberto Iannaccone
committed
use ipc message to focus on serial plotter window
1 parent 8f95fd6 commit 42d9030

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

arduino-ide-extension/src/browser/serial/plotter/plotter-frontend-contribution.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import { MonitorManagerProxyClient } from '../../../common/protocol';
1414
import { BoardsServiceProvider } from '../../boards/boards-service-provider';
1515
import { MonitorModel } from '../../monitor-model';
1616
import { ArduinoToolbar } from '../../toolbar/arduino-toolbar';
17+
import {
18+
CLOSE_PLOTTER_WINDOW,
19+
SHOW_PLOTTER_WINDOW,
20+
} from '../../../common/ipc-communication';
1721

1822
const queryString = require('query-string');
1923

@@ -58,7 +62,7 @@ export class PlotterFrontendContribution extends Contribution {
5862
override onStart(app: FrontendApplication): MaybePromise<void> {
5963
this.url = new Endpoint({ path: '/plotter' }).getRestUrl().toString();
6064

61-
ipcRenderer.on('CLOSE_CHILD_WINDOW', async () => {
65+
ipcRenderer.on(CLOSE_PLOTTER_WINDOW, async () => {
6266
if (!!this.window) {
6367
this.window = null;
6468
}
@@ -96,7 +100,7 @@ export class PlotterFrontendContribution extends Contribution {
96100
async startPlotter(): Promise<void> {
97101
await this.monitorManagerProxy.startMonitor();
98102
if (!!this.window) {
99-
this.window.focus();
103+
ipcRenderer.send(SHOW_PLOTTER_WINDOW);
100104
return;
101105
}
102106
const wsPort = this.monitorManagerProxy.getWebSocketPort();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const SHOW_PLOTTER_WINDOW = 'SHOW_PLOTTER_WINDOW';
2+
export const CLOSE_PLOTTER_WINDOW = 'CLOSE_PLOTTER_WINDOW';

arduino-ide-extension/src/electron-main/theia/electron-main-application.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ import * as os from '@theia/core/lib/common/os';
2323
import { Restart } from '@theia/core/lib/electron-common/messaging/electron-messages';
2424
import { TheiaBrowserWindowOptions } from '@theia/core/lib/electron-main/theia-electron-window';
2525
import { IsTempSketch } from '../../node/is-temp-sketch';
26+
import { CLOSE_PLOTTER_WINDOW, SHOW_PLOTTER_WINDOW } from '../../common/ipc-communication';
2627

2728
app.commandLine.appendSwitch('disable-http-cache');
29+
app.commandLine.appendSwitch('disable-site-isolation-trials');
2830

2931
interface WorkspaceOptions {
3032
file: string;
@@ -325,12 +327,20 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
325327
devTools: true,
326328
nativeWindowOpen: true,
327329
openerId: electronWindow?.webContents.id,
330+
webSecurity: false,
331+
nodeIntegration: false,
328332
},
329333
});
330334
event.newGuest = new BrowserWindow(options);
335+
336+
const showPlotterWindow = () => {
337+
event.newGuest?.show();
338+
};
339+
ipcMain.on(SHOW_PLOTTER_WINDOW, showPlotterWindow);
331340
event.newGuest.setMenu(null);
332341
event.newGuest?.on('closed', () => {
333-
electronWindow?.webContents.send('CLOSE_CHILD_WINDOW');
342+
ipcMain.removeListener(SHOW_PLOTTER_WINDOW, showPlotterWindow);
343+
electronWindow?.webContents.send(CLOSE_PLOTTER_WINDOW);
334344
});
335345
event.newGuest?.loadURL(url);
336346
}

0 commit comments

Comments
 (0)