mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-08 20:06:32 +00:00
use ipc message to focus on serial plotter window (#1410)
This commit is contained in:
parent
026e80e7fc
commit
4e590ab618
@ -14,6 +14,10 @@ import { MonitorManagerProxyClient } from '../../../common/protocol';
|
||||
import { BoardsServiceProvider } from '../../boards/boards-service-provider';
|
||||
import { MonitorModel } from '../../monitor-model';
|
||||
import { ArduinoToolbar } from '../../toolbar/arduino-toolbar';
|
||||
import {
|
||||
CLOSE_PLOTTER_WINDOW,
|
||||
SHOW_PLOTTER_WINDOW,
|
||||
} from '../../../common/ipc-communication';
|
||||
|
||||
const queryString = require('query-string');
|
||||
|
||||
@ -58,7 +62,7 @@ export class PlotterFrontendContribution extends Contribution {
|
||||
override onStart(app: FrontendApplication): MaybePromise<void> {
|
||||
this.url = new Endpoint({ path: '/plotter' }).getRestUrl().toString();
|
||||
|
||||
ipcRenderer.on('CLOSE_CHILD_WINDOW', async () => {
|
||||
ipcRenderer.on(CLOSE_PLOTTER_WINDOW, async () => {
|
||||
if (!!this.window) {
|
||||
this.window = null;
|
||||
}
|
||||
@ -96,7 +100,7 @@ export class PlotterFrontendContribution extends Contribution {
|
||||
async startPlotter(): Promise<void> {
|
||||
await this.monitorManagerProxy.startMonitor();
|
||||
if (!!this.window) {
|
||||
this.window.focus();
|
||||
ipcRenderer.send(SHOW_PLOTTER_WINDOW);
|
||||
return;
|
||||
}
|
||||
const wsPort = this.monitorManagerProxy.getWebSocketPort();
|
||||
|
2
arduino-ide-extension/src/common/ipc-communication.ts
Normal file
2
arduino-ide-extension/src/common/ipc-communication.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export const SHOW_PLOTTER_WINDOW = 'SHOW_PLOTTER_WINDOW';
|
||||
export const CLOSE_PLOTTER_WINDOW = 'CLOSE_PLOTTER_WINDOW';
|
@ -23,6 +23,10 @@ import * as os from '@theia/core/lib/common/os';
|
||||
import { Restart } from '@theia/core/lib/electron-common/messaging/electron-messages';
|
||||
import { TheiaBrowserWindowOptions } from '@theia/core/lib/electron-main/theia-electron-window';
|
||||
import { IsTempSketch } from '../../node/is-temp-sketch';
|
||||
import {
|
||||
CLOSE_PLOTTER_WINDOW,
|
||||
SHOW_PLOTTER_WINDOW,
|
||||
} from '../../common/ipc-communication';
|
||||
|
||||
app.commandLine.appendSwitch('disable-http-cache');
|
||||
|
||||
@ -324,15 +328,21 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
|
||||
webPreferences: {
|
||||
devTools: true,
|
||||
nativeWindowOpen: true,
|
||||
openerId: electronWindow?.webContents.id,
|
||||
openerId: electronWindow.webContents.id,
|
||||
},
|
||||
});
|
||||
event.newGuest = new BrowserWindow(options);
|
||||
|
||||
const showPlotterWindow = () => {
|
||||
event.newGuest?.show();
|
||||
};
|
||||
ipcMain.on(SHOW_PLOTTER_WINDOW, showPlotterWindow);
|
||||
event.newGuest.setMenu(null);
|
||||
event.newGuest?.on('closed', () => {
|
||||
electronWindow?.webContents.send('CLOSE_CHILD_WINDOW');
|
||||
event.newGuest.on('closed', () => {
|
||||
ipcMain.removeListener(SHOW_PLOTTER_WINDOW, showPlotterWindow);
|
||||
electronWindow.webContents.send(CLOSE_PLOTTER_WINDOW);
|
||||
});
|
||||
event.newGuest?.loadURL(url);
|
||||
event.newGuest.loadURL(url);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user