Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4e590ab

Browse files
author
Alberto Iannaccone
authored
use ipc message to focus on serial plotter window (#1410)
1 parent 026e80e commit 4e590ab

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

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

Lines changed: 6 additions & 2 deletions
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();
Lines changed: 2 additions & 0 deletions
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‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +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 {
27+
CLOSE_PLOTTER_WINDOW,
28+
SHOW_PLOTTER_WINDOW,
29+
} from '../../common/ipc-communication';
2630

2731
app.commandLine.appendSwitch('disable-http-cache');
2832

@@ -324,15 +328,21 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
324328
webPreferences: {
325329
devTools: true,
326330
nativeWindowOpen: true,
327-
openerId: electronWindow?.webContents.id,
331+
openerId: electronWindow.webContents.id,
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);
332-
event.newGuest?.on('closed', () => {
333-
electronWindow?.webContents.send('CLOSE_CHILD_WINDOW');
341+
event.newGuest.on('closed', () => {
342+
ipcMain.removeListener(SHOW_PLOTTER_WINDOW, showPlotterWindow);
343+
electronWindow.webContents.send(CLOSE_PLOTTER_WINDOW);
334344
});
335-
event.newGuest?.loadURL(url);
345+
event.newGuest.loadURL(url);
336346
}
337347
}
338348
);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /