Page MenuHomePhabricator

[desktop] Double-click to maximize or minimize
ClosedPublic

Authored by michal on Nov 15 2022, 12:40 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 19, 7:56 PM
Unknown Object (File)
Thu, Dec 19, 7:56 PM
Unknown Object (File)
Thu, Dec 19, 7:56 PM
Unknown Object (File)
Thu, Dec 19, 7:56 PM
Unknown Object (File)
Thu, Dec 19, 7:56 PM
Unknown Object (File)
Thu, Dec 19, 7:50 PM
Unknown Object (File)
Fri, Dec 13, 4:05 AM
Unknown Object (File)
Sat, Nov 30, 6:50 AM
Subscribers

Details

Summary

After hiding the default title bar (because it doesn't look good), we lose the functionality of double clicking. There's no proper way to do it with electron, so I detect the double click on the top bar and manually activate the correct action. Clickable elements on the top bar have to stop propagation of the double click so users don't maximize by mistake.

Test Plan
  • Test if double click to (un)maximize works
  • Change mac settings and check if minimize works
  • Change mac settings and check if "Do nothing" does nothing

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

ashoat added a subscriber: kamil.

I think it would be good for @kamil to review this too – he's looking at ENG-1687: Explore sqlite-worker NPM package, which is related to ENG-1685: Stateful web client, which I think has some connection to the Electron app. Given this overlap I think it makes sense for @michal to review @kamil's diffs in the space, and for @kamil to review @michal's diffs in the space.

tomek requested changes to this revision.Nov 15 2022, 6:07 AM
tomek added inline comments.
desktop/main.js
52–71 ↗(On Diff #18424)

It would be a good idea to link to a place where this was discussed https://github.com/electron/electron/issues/16385

web/app.react.js
189–198 ↗(On Diff #18424)

Can we avoid defining arrow functions on every render?

This revision now requires changes to proceed.Nov 15 2022, 6:07 AM

Don't define arrow functions on every render, move the doubleClick callbacks to the <header>.

Looks good!

Would be great to add a brief comment explaining the possible scenarios in ipcMain.on('double-click-top-bar', () => { before landing. It took me a second + some googling to figure what was going on there

desktop/main.cjs
99–110

Based on some Googling, it looks like the possible values of AppleActionOnDoubleClick are: Maximize, Minimize, or None.

Looks like mine is set to Maximize and so these Mac-specific options get skipped and

if (win.isMaximized()) {
  win.unmaximize();
} else {
  win.maximize();
}

is the behavior that ends up being relevant.

Should we maybe jot down a comment explaining the defaults + possible values of AppleActionOnDoubleClick to clarify things for future readers? It might be clear to others but it took me a second to understand the possible scenarios here.

tomek added inline comments.
web/app.react.js
195

We can access the style as a property when it doesn't have any special chars

This revision is now accepted and ready to land.Nov 18 2022, 7:50 AM