From 5c85033140094daff85f0c32f83f94440353479f Mon Sep 17 00:00:00 2001 From: Ajesh Kumar S <31558237+AjeshKumarS@users.noreply.github.com> Date: Mon, 25 Oct 2021 21:58:29 +0530 Subject: Add feature to resize and fit window to screen on macOS when double c… (#2125) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sreelekha sreelekha.marasigogu@gmail.com --- src/components/layout/AppLayout.js | 21 ++++++++++++++++++++- src/index.ts | 4 ++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/components/layout/AppLayout.js b/src/components/layout/AppLayout.js index 9ae72a6c1..af27e8854 100644 --- a/src/components/layout/AppLayout.js +++ b/src/components/layout/AppLayout.js @@ -4,6 +4,7 @@ import { observer } from 'mobx-react'; import { defineMessages, injectIntl } from 'react-intl'; import { TitleBar } from 'electron-react-titlebar/renderer'; import injectSheet from 'react-jss'; +import { ipcRenderer } from 'electron'; import InfoBar from '../ui/InfoBar'; import { Component as BasicAuth } from '../../features/basicAuth'; @@ -14,7 +15,7 @@ import ErrorBoundary from '../util/ErrorBoundary'; // import globalMessages from '../../i18n/globalMessages'; -import { isWindows } from '../../environment'; +import { isWindows, isMac } from '../../environment'; import WorkspaceSwitchingIndicator from '../../features/workspaces/components/WorkspaceSwitchingIndicator'; import { workspaceStore } from '../../features/workspaces'; import AppUpdateInfoBar from '../AppUpdateInfoBar'; @@ -57,8 +58,20 @@ const styles = theme => ({ : `translateX(-${theme.workspaces.drawer.width}px)`; }, }, + titleBar: { + display: 'block', + zIndex: 1, + width: '100%', + height: '23px', + position: 'absolute', + top: 0, + }, }); +const toggleFullScreen = () => { + ipcRenderer.send('window.toolbar-double-clicked'); +}; + @injectSheet(styles) @observer class AppLayout extends Component { @@ -119,6 +132,12 @@ class AppLayout extends Component { icon="assets/images/logo.svg" /> )} + {isMac && !isFullScreen && ( + + )}
{workspacesDrawer} {sidebar} diff --git a/src/index.ts b/src/index.ts index b4a754289..89903a669 100644 --- a/src/index.ts +++ b/src/index.ts @@ -627,6 +627,10 @@ ipcMain.on('set-spellchecker-locales', (_e, { locale, serviceId }) => { serviceSession.setSpellCheckerLanguages(locales); }); +ipcMain.on('window.toolbar-double-clicked', () => { + mainWindow?.isMaximized() ? mainWindow.unmaximize() : mainWindow?.maximize(); +}); + // Quit when all windows are closed. app.on('window-all-closed', () => { // On OS X it is common for applications and their menu bar -- cgit v1.2.3-70-g09d2