diff --git a/gcs/electron/main.ts b/gcs/electron/main.ts index 9006ba1a8..d40cbbc47 100644 --- a/gcs/electron/main.ts +++ b/gcs/electron/main.ts @@ -216,6 +216,9 @@ ipcMain.handle("window:select-file-in-explorer", async (_event, filters) => { } return null }) +ipcMain.on("window:update-title", async (_event, value) => { + getWindow()?.setTitle(value) +}) function createWindow() { win = new BrowserWindow({ @@ -224,6 +227,7 @@ function createWindow() { preload: path.join(__dirname, "preload.js"), nodeIntegration: true, }, + title: "FGCS", show: false, alwaysOnTop: true, minWidth: 750, diff --git a/gcs/electron/preload.js b/gcs/electron/preload.js index 6aec86ad0..d617f661b 100644 --- a/gcs/electron/preload.js +++ b/gcs/electron/preload.js @@ -47,6 +47,7 @@ const ALLOWED_SEND_CHANNELS = [ "window:zoom-in", "window:zoom-out", "window:open-file-in-explorer", + "window:update-title", // app state updates "app:connected-state", ] diff --git a/gcs/index.html b/gcs/index.html index 5fee79978..884dba96f 100644 --- a/gcs/index.html +++ b/gcs/index.html @@ -4,7 +4,7 @@ - FGCS + FGCS
diff --git a/gcs/src/redux/middleware/socketMiddleware.js b/gcs/src/redux/middleware/socketMiddleware.js index 2d5803225..bfab1d6d8 100644 --- a/gcs/src/redux/middleware/socketMiddleware.js +++ b/gcs/src/redux/middleware/socketMiddleware.js @@ -357,6 +357,7 @@ const socketMiddleware = (store) => { // Flags that the drone is disconnected socket.socket.on("disconnected_from_drone", () => { store.dispatch(setConnected(false)) + window.ipcRenderer.send("window:update-title", "FGCS") }) // Flags an error with the com port diff --git a/gcs/src/redux/slices/droneInfoSlice.js b/gcs/src/redux/slices/droneInfoSlice.js index a3a4d7edd..e866cd567 100644 --- a/gcs/src/redux/slices/droneInfoSlice.js +++ b/gcs/src/redux/slices/droneInfoSlice.js @@ -109,6 +109,10 @@ const droneInfoSlice = createSlice({ reducers: { setFlightSwVersion: (state, action) => { state.flightSwVersion = action.payload + window.ipcRenderer.send( + "window:update-title", + `FGCS - ${state.aircraftType === 1 ? "ArduPlane" : "ArduCopter"} ${action.payload}`, + ) }, setHeartbeatData: (state, action) => { if ( diff --git a/gcs/tests/electron-fixtures.ts b/gcs/tests/electron-fixtures.ts index 0afde2d18..0b4193a4b 100644 --- a/gcs/tests/electron-fixtures.ts +++ b/gcs/tests/electron-fixtures.ts @@ -31,7 +31,7 @@ export async function getSharedElectronApp(): Promise { sharedMainWindow = await sharedElectronApp.waitForEvent("window", { predicate: async (window) => { const title = await window.title() - return title === "FGCS" + return title.includes("FGCS") }, timeout: 30000, })