Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick full screen #803

Merged
merged 12 commits into from
Oct 16, 2016
Merged

Quick full screen #803

merged 12 commits into from
Oct 16, 2016

Conversation

maxdeviant
Copy link
Contributor

@maxdeviant maxdeviant commented Oct 7, 2016

This PR is for investigating/adding the quick full screen functionality that @jordwalke requested in #666 (I guess I'm doing the devil's work here 😱 ).

Currently I have it working quickly by just expanding the window to take up all available space on the screen. It feels a little hacky to me, but it is fast 😄

TODO:

  • Enter quick full screen mode
  • Leave quick full screen mode
    • Restore the window to the previous size/location it was in before entering full screen
  • Toggle the menu item appropriately
  • Add accelerators for Linux
  • Figure out if there is a more elegant way to do this
    • I tried the simple stuff first (i.e., using BrowserWindow.setFullScreen, but that still uses the OS X animations.
    • EDIT: After making some tweaks and sleeping on it, I think that my current implementation is probably the best way to go about it, given the constraints of Electron.

@jordwalke
Copy link

I hope that other electron apps can learn from your approach.

},
{
label: 'Enter Quick Full Screen',
accelerator: 'Cmd+Enter',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice choice! (Is it configurable?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently Hyper doesn't support custom hotkeys. But once we do then it will be configurable!

I don't recall if there is an open issue for that or not.

@@ -245,6 +246,16 @@ app.on('ready', () => installDevExtensions(isDev).then(() => {
win.maximize();
});

rpc.on('enter quick full screen', () => {
const {width, height} = electron.screen.getPrimaryDisplay().workAreaSize;
win.setSize(width, height);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this render on top of the menu bar?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not currently. I was going to ask what you had in mind for the behavior.

@maxdeviant
Copy link
Contributor Author

@jordwalke If it works well I can see about abstracting it into an Electron plugin so other apps can add the same functionality easily 👍

@maxdeviant
Copy link
Contributor Author

Here it is in action: https://gfycat.com/BitterScentedBarnowl

@maxdeviant maxdeviant changed the title [WIP] Quick full screen Quick full screen Oct 7, 2016
{
id: 'LEAVE_QUICK_FULL_SCREEN',
label: 'Leave Quick Full Screen',
accelerator: 'Cmd+Enter',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an accelerator for Linux users 😀 We don't have Cmd

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flybayer Any thoughts on what the accelerator should be? 🤔 Alt+Enter?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That may be ok, although Ctrl+Shift+Enter might be better. It's similar to Cmd+Shift+F for OSX.

@rauchg
Copy link
Member

rauchg commented Oct 8, 2016

How about ^⌘F ?

@rauchg
Copy link
Member

rauchg commented Oct 8, 2016

(not sure it's better, but seems more standard?)

@maxdeviant
Copy link
Contributor Author

@rauchg ^⌘F is already reserved for normal full screen on OSX (which triggers the animation).

@shime
Copy link
Contributor

shime commented Oct 9, 2016

Great work, can't wait for it to be merged. Worth noting that the hotkey for entering full screen in iTerm is also ⌘↵.

@shime
Copy link
Contributor

shime commented Oct 9, 2016

Detected a couple of issues after using it for longer time:

  • it remembers the window size after exiting, so when it's restarted it will show in full screen - maybe not a problem, but it's unable to exit full screen as a result
  • the event is not firing every time the hotkey is pressed, it fires after 2-3 attempts occasionally

@maxdeviant
Copy link
Contributor Author

maxdeviant commented Oct 9, 2016

@shime Yea, I was aware of the first issue, but I'm not totally sure what the best way to handle it is, because Hyper saves your terminal position and size when it exits (as part of another feature).

I was debating between:

  • Simply not saving the position/size when in quick full screen
    • This would restore the position/size you had before entering full screen on the next load
  • Saving the "is full screen" state to the Electron config (where the position and size are recorded)
    • This would bring you back to full screen on the next load, but you would be able to toggle it off using the hotkey

The former is easier since we just have to track the state in-memory, as opposed to the latter where it must be written out when the app exits.

cc @rauchg @jordwalke Any input on how this should work?

@maxdeviant
Copy link
Contributor Author

@shime Also, that second issue is interesting. I've only done cursory testing, so the next time I have a look at it I will see if I can reproduce and fix the issue.

@jordwalke
Copy link

Me? I'm not picky about which of those two solutions you go for as long as it's not buggy. I'm just happy to have full screen!

rpc.on('leave quick full screen req', () => {
store_.dispatch(uiActions.leaveQuickFullScreen());
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this "roundtrip" approach. Gives us lots of flexibility

@rauchg rauchg merged commit 64e87d0 into vercel:master Oct 16, 2016
rauchg added a commit that referenced this pull request Oct 18, 2016
chabou added a commit to chabou/hyper that referenced this pull request Nov 2, 2016
* master:
  chore(package): update electron to version 1.4.5 (vercel#949)
  add onRendererWindow, because it actually available. check ./lib/utils/plugins.js:193 (vercel#924)
  increase timeout for update checks (vercel#928)
  Change URL regex - fixes vercel#867 (vercel#943)
  Make the close menu items less ambiguous
  Comply to XO's no-warning-comments rule
  Prefer default export to make XO happy (vercel#931)
  chore(package): update ms to version 0.7.2 (vercel#933)
  chore(package): update copy-webpack-plugin to version 4.0.0 (vercel#927)
  log plugins' errors in Electron console (vercel#923)
  Improve tabs title   (vercel#892)
  increase notification timeout up to 30m (vercel#913)
  Create github templates (vercel#919)
  chore(package): update electron to version 1.4.4 (vercel#907)
  Prevent Hterm to share same preferences between instances (vercel#906)
  0.8.3
  0.9.0
  Revert "Quick full screen (vercel#803)"
  Ignore file watch errors. Fixes vercelGH-225 (vercel#893)
@jordwalke
Copy link

Did I miss why this was reverted?

@maxdeviant
Copy link
Contributor Author

@jordwalke There was an issue with it where sometimes you would get locked in quick full screen and not be able to get out. Usually it happened if you switched back and forth too fast.

I've been meaning to have a look at it, but haven't had any time to devote to it lately 🙁

@hojberg
Copy link

hojberg commented Jan 26, 2017

damn i was excited about this

@ChadTaljaardt
Copy link

Bump for this, it is a must have feature for productivity in my opinion.

@asantos00
Copy link
Contributor

Any plans about the Cmd+enter action to fullscreen on mac?

@albinekb
Copy link
Contributor

you can do that with the custom keymaps @asantos00

@asantos00
Copy link
Contributor

So it will not be added as default behaviour? I think it is default behaviour for all OSX apps :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants