Page MenuHomePhabricator

D5631.id.diff
No OneTemporary

D5631.id.diff

diff --git a/desktop/main.cjs b/desktop/main.cjs
--- a/desktop/main.cjs
+++ b/desktop/main.cjs
@@ -1,4 +1,11 @@
-const { app, BrowserWindow, shell, Menu, ipcMain } = require('electron');
+const {
+ app,
+ BrowserWindow,
+ shell,
+ Menu,
+ ipcMain,
+ systemPreferences,
+} = require('electron');
const fs = require('fs');
const path = require('path');
@@ -96,6 +103,31 @@
updateNavigationState();
});
+ ipcMain.on('double-click-top-bar', () => {
+ if (isMac) {
+ // Possible values for AppleActionOnDoubleClick are Maximize,
+ // Minimize or None. We handle the last two inside this if.
+ // Maximize (which is the only behaviour for other platforms)
+ // is handled in the later block.
+ const action = systemPreferences.getUserDefault(
+ 'AppleActionOnDoubleClick',
+ 'string',
+ );
+ if (action === 'None') {
+ return;
+ } else if (action === 'Minimize') {
+ win.minimize();
+ return;
+ }
+ }
+
+ if (win.isMaximized()) {
+ win.unmaximize();
+ } else {
+ win.maximize();
+ }
+ });
+
win.webContents.setWindowOpenHandler(({ url: openURL }) => {
shell.openExternal(openURL);
// Returning 'deny' prevents a new electron window from being created
diff --git a/desktop/preload.cjs b/desktop/preload.cjs
--- a/desktop/preload.cjs
+++ b/desktop/preload.cjs
@@ -7,6 +7,7 @@
return () => ipcRenderer.removeListener('on-navigate', withEvent);
},
clearHistory: () => ipcRenderer.send('clear-history'),
+ doubleClickTopBar: () => ipcRenderer.send('double-click-top-bar'),
};
contextBridge.exposeInMainWorld('electronContextBridge', bridge);
diff --git a/web/app.react.js b/web/app.react.js
--- a/web/app.react.js
+++ b/web/app.react.js
@@ -162,6 +162,9 @@
);
}
+ onHeaderDoubleClick = () => electron?.doubleClickTopBar();
+ stopDoubleClickPropagation = electron ? e => e.stopPropagation() : null;
+
renderMainContent() {
let mainContent;
const { tab, settingsSection } = this.props.navInfo;
@@ -188,13 +191,14 @@
<div className={css.layout}>
<DisconnectedBarVisibilityHandler />
<DisconnectedBar />
- <header className={css['header']}>
+ <header className={css.header} onDoubleClick={this.onHeaderDoubleClick}>
<div className={css['main-header']}>
<h1 className={css.wordmark}>
<a
title="Comm Home"
aria-label="Go to Comm Home"
onClick={this.onWordmarkClicked}
+ onDoubleClick={this.stopDoubleClickPropagation}
>
Comm
</a>
diff --git a/web/components/navigation-arrows.react.js b/web/components/navigation-arrows.react.js
--- a/web/components/navigation-arrows.react.js
+++ b/web/components/navigation-arrows.react.js
@@ -8,6 +8,8 @@
import SWMansionIcon from '../SWMansionIcon.react.js';
import css from './navigation-arrows.css';
+const stopDoubleClickPropagation = e => e.stopPropagation();
+
function NavigationArrows(): React.Node {
const goBack = React.useCallback(
() => history.getHistoryObject().goBack(),
@@ -37,10 +39,18 @@
return (
<div className={css.container}>
- <a className={goBackClasses} onClick={goBack}>
+ <a
+ className={goBackClasses}
+ onClick={goBack}
+ onDoubleClick={stopDoubleClickPropagation}
+ >
<SWMansionIcon icon="arrow-left" size={24} />
</a>
- <a className={goForwardClasses} onClick={goForward}>
+ <a
+ className={goForwardClasses}
+ onClick={goForward}
+ onDoubleClick={stopDoubleClickPropagation}
+ >
<SWMansionIcon icon="arrow-right" size={24} />
</a>
</div>
diff --git a/web/electron.js b/web/electron.js
--- a/web/electron.js
+++ b/web/electron.js
@@ -11,6 +11,7 @@
// Returns a callback that you can call to remove the listener
+onNavigate: OnNavigateListener => () => void,
+clearHistory: () => void,
+ +doubleClickTopBar: () => void,
} = typeof electronContextBridge === 'undefined' ? null : electronContextBridge;
export default electron;

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 2:53 AM (8 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2511308
Default Alt Text
D5631.id.diff (4 KB)

Event Timeline