-
Notifications
You must be signed in to change notification settings - Fork 15.1k
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
Feature/simple fullscreen mode #10254
Feature/simple fullscreen mode #10254
Conversation
Couldn't users use
|
That's a good question, and a common one in the linked issues around this particular feature, but maximizing the window isn't the same thing as making it fullscreen. From a user perspective, fullscreen means hiding the dock, title bar, and menu bar, which provides a more immersive experience and reduces distractions (at least to users who use pre-Lion fullscreen functionality on apps like iTerm2 and Sublime Text 2), while also not dictating how users should manage their desktops and monitors (which is what post-Lion fullscreen does). From a practical perspective, fullscreen on Linux and Windows both operate in the same way as the pre-Lion fullscreen did (and does in this PR), while also offering separate "maximize window" features. |
@zachflower You're my hero for the day! This has been one of the sad points when using any electron based app on macOS and one I greatly miss when outside of Sublime Text. |
Just found this PR -- it was opened on my birthday. Best. Birthday. Ever. 🎉 I've been waiting for this for a very long time. What needs to happen to get it merged into the main codebase so that between Hyper and Atom my development environment can reach its final form? |
docs/api/browser-window.md
Outdated
|
||
* `flag` Boolean | ||
|
||
Sets whether the window should be in simple fullscreen mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description should make it clear what "simple fullscreen mode" is.
atom/browser/native_window_mac.mm
Outdated
[window setFrame:fullscreenFrame display: YES animate: YES]; | ||
|
||
// Fullscreen windows can't be resized, minimized, etc. | ||
if (was_minimizable_) SetMinimizable(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The window states are just style masks, I think you can just store the original window style masks instead of separate window states.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes a lot of sense, thanks for the feedback!
atom/browser/native_window_mac.mm
Outdated
@@ -819,7 +826,9 @@ static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val, | |||
zoom_to_page_width_(false), | |||
fullscreen_window_title_(false), | |||
attention_request_id_(0), | |||
title_bar_style_(NORMAL) { | |||
title_bar_style_(NORMAL), | |||
simple_fullscreen_(false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having both simple_fullscreen_
and is_simple_fullscreen_
is confusing, renaming simple_fullscreen_
to something like always_simple_fullscreen_
can improve code readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I can see how the current nomenclature is ambiguous. I will update accordingly.
Congrats on merging your first pull request! 🎉🎉🎉 |
If I'm on OS X 10.9.5, which is too old for me to build Electron from source and fix. NSApplicationPresentationOptions options =
NSApplicationPresentationAutoHideDock +
NSApplicationPresentationAutoHideMenuBar;
[NSApp setPresentationOptions:options];
was_maximizable_ = IsMaximizable();
was_movable_ = IsMovable();
NSRect fullscreenFrame = [window.screen frame];
if ( !fullscreen_window_title() ) {
// Hide the titlebar
SetStyleMask(false, NSTitledWindowMask);
// Resize the window to accomodate the _entire_ screen size
fullscreenFrame.size.height -= [[[NSApplication sharedApplication] mainMenu] menuBarHeight]; My hypothesis for the behavior is that when If that's what's actually happening, then perhaps the fix is to simply remove this last line. Otherwise, super thrilled to have this option in Electron, since changing OS X spaces makes me seasick = ) |
Hey @lynaghk! IIRC this snippet: fullscreenFrame.size.height -= [[[NSApplication sharedApplication] mainMenu] menuBarHeight]; Was necessary to work around an odd issue where the Electron window would receive an amount of padding equal to the height of the menubar, which resulted in an odd ~20px blank space at the top of the window. That said, it doesn't seem take into account the possibility of the menubar having already been hidden (and I admit I don't remember if I tested that specific circumstance or not), so that might be the issue? Either way, good catch! I'm not sure if I'll have time to jump on this soon with the holiday coming up, but—correct me if I'm wrong with this direction @MarshallOfSound or @zcbenz—it's probably a good idea to create a new issue outlining the problem, in case someone else has more bandwidth to put out a fix in the next week or two. |
Modern implementations of macOS utilize desktop spaces to implement fullscreen functionality, which presents a less-than-ideal interaction for users who use multiple monitors (and prefer to keep those monitors within the same space), or prefer to have more control over their ability to multitask while using a fullscreen application.
Prior to the release of Lion, fullscreen functionality on Mac OS X acted similarly to the current fullscreen functionality on Windows and Linux. This PR provides functionality to simulate that same style of pre-Lion fullscreen on macOS for Electron applications.
Full Disclosure: This is my first attempt at writing Objective-C... ever... so any feedback would be greatly appreciated! 😄
Usage
Simple fullscreen support can be enabled by passing
simpleFullscreen: true
to theBrowserWindow
constructor which, when enabled, will override the default macOS fullscreen functionality with the new simple fullscreen functionality.Additionally, two new methods (
setSimpleFullScreen()
andisFullScreen()
) have been added for more granular usability.Demonstration
Here is a short animation that demonstrates what simple fullscreen support looks like (pay attention to the window, as it stays on the current space rather than moving to a new one, which is the default functionality).
Background
Because popular desktop applications like Sublime Text 3, MacVim, and iTerm2 provide support for pre-Lion fullscreen, this particular feature has been requested many times over in several popular open source Electron projects (including the Electron core itself):