diff --git a/src/common/communication.js b/src/common/communication.js index bedafb79..eccf333c 100644 --- a/src/common/communication.js +++ b/src/common/communication.js @@ -45,6 +45,7 @@ export const WINDOW_CLOSE = 'window_close'; export const WINDOW_MINIMIZE = 'window_minimize'; export const WINDOW_MAXIMIZE = 'window_maximize'; export const WINDOW_RESTORE = 'window_restore'; +export const GET_FULL_SCREEN_STATUS = 'get-full-screen-status'; export const UPDATE_TARGET_URL = 'update_target_url'; diff --git a/src/main/windows/mainWindow.js b/src/main/windows/mainWindow.js index d26978a1..87ac4412 100644 --- a/src/main/windows/mainWindow.js +++ b/src/main/windows/mainWindow.js @@ -6,10 +6,10 @@ import fs from 'fs'; import path from 'path'; import os from 'os'; -import {app, BrowserWindow} from 'electron'; +import {app, BrowserWindow, ipcMain} from 'electron'; import log from 'electron-log'; -import {SELECT_NEXT_TAB, SELECT_PREVIOUS_TAB} from 'common/communication'; +import {SELECT_NEXT_TAB, SELECT_PREVIOUS_TAB, GET_FULL_SCREEN_STATUS} from 'common/communication'; import * as Validator from '../Validator'; import ContextMenu from '../contextMenu'; @@ -18,6 +18,7 @@ import {getLocalPreload, getLocalURLString} from '../utils'; function saveWindowState(file, window) { const windowState = window.getBounds(); windowState.maximized = window.isMaximized(); + windowState.fullscreen = window.isFullScreen(); try { fs.writeFileSync(file, JSON.stringify(windowState)); } catch (e) { @@ -66,7 +67,7 @@ function createMainWindow(config, options) { minWidth: minimumWindowWidth, minHeight: minimumWindowHeight, frame: !isFramelessWindow(), - fullscreen: false, + fullscreen: windowOptions.fullscreen, titleBarStyle: 'hidden', trafficLightPosition: {x: 12, y: 24}, backgroundColor: '#fff', // prevents blurry text: https://electronjs.org/docs/faq#the-font-looks-blurry-what-is-this-and-what-can-i-do @@ -83,6 +84,8 @@ function createMainWindow(config, options) { const mainWindow = new BrowserWindow(windowOptions); mainWindow.setMenuBarVisibility(false); + ipcMain.handle(GET_FULL_SCREEN_STATUS, () => mainWindow.isFullScreen()); + const localURL = getLocalURLString('index.html'); mainWindow.loadURL(localURL).catch( (reason) => { diff --git a/src/main/windows/settingsWindow.js b/src/main/windows/settingsWindow.js index 42245df8..94c885c4 100644 --- a/src/main/windows/settingsWindow.js +++ b/src/main/windows/settingsWindow.js @@ -14,6 +14,7 @@ export function createSettingsWindow(mainWindow, config, withDevTools) { ...config.data, parent: mainWindow, title: 'Desktop App Settings', + fullscreen: false, webPreferences: { nodeIntegration: false, contextIsolation: true, diff --git a/src/renderer/components/MainPage.jsx b/src/renderer/components/MainPage.jsx index e95306fe..08b9817e 100644 --- a/src/renderer/components/MainPage.jsx +++ b/src/renderer/components/MainPage.jsx @@ -32,6 +32,7 @@ import { SELECT_PREVIOUS_TAB, ADD_SERVER, FOCUS_THREE_DOT_MENU, + GET_FULL_SCREEN_STATUS, } from 'common/communication'; import restoreButton from '../../assets/titlebar/chrome-restore.svg'; @@ -150,6 +151,8 @@ export default class MainPage extends React.PureComponent { window.ipcRenderer.on('enter-full-screen', () => this.handleFullScreenState(true)); window.ipcRenderer.on('leave-full-screen', () => this.handleFullScreenState(false)); + window.ipcRenderer.invoke(GET_FULL_SCREEN_STATUS).then((fullScreenStatus) => this.handleFullScreenState(fullScreenStatus)); + window.ipcRenderer.on(ADD_SERVER, () => { this.addServer(); });