Revert will-enter-full-screen event, matching osx fullscreen: false behaviour on windows instead

This commit is contained in:
Heilig Benedek 2016-02-22 10:23:56 +01:00
parent 157a290e38
commit 39bb670719
9 changed files with 25 additions and 41 deletions

View file

@ -219,10 +219,6 @@ void Window::OnWindowMoved() {
Emit("moved");
}
void Window::OnWindowWillEnterFullScreen(bool* prevent_default) {
*prevent_default = Emit("will-enter-full-screen");
}
void Window::OnWindowEnterFullScreen() {
Emit("enter-full-screen");
}

View file

@ -67,7 +67,6 @@ class Window : public mate::TrackableObject<Window>,
void OnWindowMoved() override;
void OnWindowScrollTouchBegin() override;
void OnWindowScrollTouchEnd() override;
void OnWindowWillEnterFullScreen(bool* prevent_default) override;
void OnWindowEnterFullScreen() override;
void OnWindowLeaveFullScreen() override;
void OnWindowEnterHtmlFullScreen() override;

View file

@ -134,10 +134,16 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
SetAlwaysOnTop(true);
}
#if defined(OS_MACOSX) || defined(OS_WIN)
bool fullscreen;
if (options.Get(options::kFullscreen, &fullscreen) && fullscreen) {
// Disable fullscreen button when 'fullscreenable' is false or 'fullscreen'
// is specified to false.
bool fullscreenable = true;
options.Get(options::kFullScreenable, &fullscreenable);
bool fullscreen = false;
if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen)
fullscreenable = false;
SetFullScreenable(fullscreenable);
if (fullscreen)
SetFullScreen(true);
}
#endif
bool skip;
if (options.Get(options::kSkipTaskbar, &skip) && skip) {
@ -445,13 +451,6 @@ void NativeWindow::NotifyWindowMoved() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowMoved());
}
bool NativeWindow::RequestEnterFullScreen() {
bool prevent_default = false;
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
OnWindowWillEnterFullScreen(&prevent_default));
return prevent_default;
}
void NativeWindow::NotifyWindowEnterFullScreen() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
OnWindowEnterFullScreen());

View file

@ -197,9 +197,6 @@ class NativeWindow : public base::SupportsUserData,
// Requests the WebContents to close, can be cancelled by the page.
virtual void RequestToClosePage();
// Request the WebContents to go fullscreen, can be cancelled by the page.
virtual bool RequestEnterFullScreen();
// Methods called by the WebContents.
virtual void CloseContents(content::WebContents* source);
virtual void RendererUnresponsive(content::WebContents* source);

View file

@ -602,9 +602,6 @@ void NativeWindowMac::SetFullScreen(bool fullscreen) {
if (fullscreen == IsFullscreen())
return;
if (fullscreen && RequestEnterFullScreen())
return;
if (!base::mac::IsOSLionOrLater()) {
LOG(ERROR) << "Fullscreen mode is only supported above Lion";
return;

View file

@ -52,7 +52,6 @@ class NativeWindowObserver {
virtual void OnWindowMoved() {}
virtual void OnWindowScrollTouchBegin() {}
virtual void OnWindowScrollTouchEnd() {}
virtual void OnWindowWillEnterFullScreen(bool* prevent_default) {}
virtual void OnWindowEnterFullScreen() {}
virtual void OnWindowLeaveFullScreen() {}
virtual void OnWindowEnterHtmlFullScreen() {}

View file

@ -117,7 +117,8 @@ NativeWindowViews::NativeWindowViews(
movable_(true),
resizable_(true),
maximizable_(true),
minimizable_(true) {
minimizable_(true),
fullscreenable_(true) {
options.Get(options::kTitle, &title_);
options.Get(options::kAutoHideMenuBar, &menu_bar_autohide_);
@ -347,14 +348,10 @@ bool NativeWindowViews::IsMinimized() {
}
void NativeWindowViews::SetFullScreen(bool fullscreen) {
bool prevent_default = false;
if (fullscreen)
prevent_default = RequestEnterFullScreen();
#if defined(OS_WIN)
// There is no native fullscreen state on Windows.
if (fullscreen) {
if (!prevent_default) {
if (IsFullScreenable()) {
last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
NotifyWindowEnterFullScreen();
}
@ -364,10 +361,10 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) {
}
// We set the new value after notifying, so we can handle the size event
// correctly.
if (!prevent_default)
if (IsFullScreenable())
window_->SetFullscreen(fullscreen);
#else
if (!(fullscreen && prevent_default)) {
if (!fullscreen || IsFullScreenable()) {
if (IsVisible())
window_->SetFullscreen(fullscreen);
else
@ -499,11 +496,15 @@ bool NativeWindowViews::IsMaximizable() {
#endif
}
void NativeWindowViews::SetFullScreenable(bool maximizable) {
void NativeWindowViews::SetFullScreenable(bool fullscreenable) {
#if defined(OS_WIN)
FlipWindowStyle(GetAcceleratedWidget(), false, WS_MAXIMIZEBOX);
#endif
fullscreenable_ = fullscreenable;
}
bool NativeWindowViews::IsFullScreenable() {
return true;
return fullscreenable_;
}
void NativeWindowViews::SetClosable(bool closable) {

View file

@ -212,6 +212,7 @@ class NativeWindowViews : public NativeWindow,
bool resizable_;
bool maximizable_;
bool minimizable_;
bool fullscreenable_;
std::string title_;
gfx::Size widget_size_;

View file

@ -276,11 +276,6 @@ __Note__: On OS X this event is just an alias of `moved`.
Emitted once when the window is moved to a new position.
### Event: 'will-enter-full-screen'
Emitted when the window is about to enter full screen state. Calling `event.preventDefault()`
will cancel the state change.
### Event: 'enter-full-screen'
Emitted when the window enters full screen state.
@ -589,17 +584,17 @@ nothing.
Returns whether the window can be manually maximized by user. On Linux always
returns `true`.
### `win.setFullScreenable(fullscreenable)` _OS X_
### `win.setFullScreenable(fullscreenable)`
* `fullscreenable` Boolean
Sets whether the maximize/zoom window button toggles fullscreen mode or
maximizes the window. On Windows and Linux does nothing.
maximizes the window.
### `win.isFullScreenable()` _OS X_
### `win.isFullScreenable()`
Returns whether the maximize/zoom window button toggles fullscreen mode or
maximizes the window. On Windows and Linux always returns `true`.
maximizes the window.
### `win.setClosable(closable)` _OS X_ _Windows_