Merge pull request #4686 from atom/fullscreen-logic
Improve fullscreen related logic code
This commit is contained in:
commit
a0c39c64cc
3 changed files with 18 additions and 31 deletions
|
@ -133,18 +133,17 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
|
||||||
if (options.Get(options::kAlwaysOnTop, &top) && top) {
|
if (options.Get(options::kAlwaysOnTop, &top) && top) {
|
||||||
SetAlwaysOnTop(true);
|
SetAlwaysOnTop(true);
|
||||||
}
|
}
|
||||||
|
// Disable fullscreen button if 'fullscreen' is specified to false.
|
||||||
// Disable fullscreen button when 'fullscreenable' is false or 'fullscreen'
|
|
||||||
// is specified to false.
|
|
||||||
bool fullscreenable = true;
|
bool fullscreenable = true;
|
||||||
options.Get(options::kFullScreenable, &fullscreenable);
|
|
||||||
bool fullscreen = false;
|
bool fullscreen = false;
|
||||||
if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen)
|
if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen)
|
||||||
fullscreenable = false;
|
fullscreenable = false;
|
||||||
|
// Overriden by 'fullscreenable'.
|
||||||
|
options.Get(options::kFullScreenable, &fullscreenable);
|
||||||
SetFullScreenable(fullscreenable);
|
SetFullScreenable(fullscreenable);
|
||||||
if (fullscreen)
|
if (fullscreen) {
|
||||||
SetFullScreen(true);
|
SetFullScreen(true);
|
||||||
|
}
|
||||||
bool skip;
|
bool skip;
|
||||||
if (options.Get(options::kSkipTaskbar, &skip) && skip) {
|
if (options.Get(options::kSkipTaskbar, &skip) && skip) {
|
||||||
SetSkipTaskbar(skip);
|
SetSkipTaskbar(skip);
|
||||||
|
|
|
@ -482,19 +482,9 @@ NativeWindowMac::NativeWindowMac(
|
||||||
options.Get(options::kDisableAutoHideCursor, &disableAutoHideCursor);
|
options.Get(options::kDisableAutoHideCursor, &disableAutoHideCursor);
|
||||||
[window_ setDisableAutoHideCursor:disableAutoHideCursor];
|
[window_ setDisableAutoHideCursor:disableAutoHideCursor];
|
||||||
|
|
||||||
// Disable fullscreen button when 'fullscreenable' is false or 'fullscreen'
|
// Disable zoom button if window is not resizable.
|
||||||
// is specified to false.
|
if (!maximizable)
|
||||||
bool fullscreenable = true;
|
|
||||||
options.Get(options::kFullScreenable, &fullscreenable);
|
|
||||||
bool fullscreen = false;
|
|
||||||
if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen)
|
|
||||||
fullscreenable = false;
|
|
||||||
SetFullScreenable(fullscreenable);
|
|
||||||
|
|
||||||
// Disable zoom button if window is not resizable
|
|
||||||
if (!maximizable) {
|
|
||||||
SetMaximizable(false);
|
SetMaximizable(false);
|
||||||
}
|
|
||||||
|
|
||||||
NSView* view = inspectable_web_contents()->GetView()->GetNativeView();
|
NSView* view = inspectable_web_contents()->GetView()->GetNativeView();
|
||||||
[view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
[view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||||
|
|
|
@ -363,29 +363,27 @@ bool NativeWindowViews::IsMinimized() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::SetFullScreen(bool fullscreen) {
|
void NativeWindowViews::SetFullScreen(bool fullscreen) {
|
||||||
|
if (!IsFullScreenable())
|
||||||
|
return;
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
// There is no native fullscreen state on Windows.
|
// There is no native fullscreen state on Windows.
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
if (IsFullScreenable()) {
|
last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
|
||||||
last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
|
NotifyWindowEnterFullScreen();
|
||||||
NotifyWindowEnterFullScreen();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
last_window_state_ = ui::SHOW_STATE_NORMAL;
|
last_window_state_ = ui::SHOW_STATE_NORMAL;
|
||||||
NotifyWindowLeaveFullScreen();
|
NotifyWindowLeaveFullScreen();
|
||||||
}
|
}
|
||||||
// We set the new value after notifying, so we can handle the size event
|
// We set the new value after notifying, so we can handle the size event
|
||||||
// correctly.
|
// correctly.
|
||||||
if (IsFullScreenable())
|
window_->SetFullscreen(fullscreen);
|
||||||
window_->SetFullscreen(fullscreen);
|
|
||||||
#else
|
#else
|
||||||
if (!fullscreen || (fullscreen && IsFullScreenable())) {
|
if (IsVisible())
|
||||||
if (IsVisible())
|
window_->SetFullscreen(fullscreen);
|
||||||
window_->SetFullscreen(fullscreen);
|
else
|
||||||
else
|
window_->native_widget_private()->ShowWithWindowState(
|
||||||
window_->native_widget_private()->ShowWithWindowState(
|
ui::SHOW_STATE_FULLSCREEN);
|
||||||
ui::SHOW_STATE_FULLSCREEN);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue