Skip to content

Fix unresponsive app after fullscreen->normal state toggle (Windows) - #9645

Merged
kevinsawicki merged 5 commits into
electron:masterfrom
dharders:issue6036-fix-windows-fullscreen-startup-toggle
Jun 14, 2017
Merged

kevinsawicki merged 5 commits into
electron:masterfrom
dharders:issue6036-fix-windows-fullscreen-startup-toggle

Conversation

@dharders

@dharders dharders commented Jun 1, 2017 •

Copy link
Copy Markdown

Fixes #6036

Summary

In Windows only, starting an app in the fullscreen state i.e. with the BrowserWindow options { fullscreen: true } produces an unresponsive window after toggling to the normal window state. e.g. Pressing F11 or setFullScreen(false). See issue #6036

The window visibility flag WS_VISIBLE is never set for the GWL_STYLE when we start in fullscreen mode. This fix simply detects the fullscreen->normal window state transition and checks if the window is visible (which it always should be). If it isn't, it sets the visibility to true. i.e. :

void NativeWindowViews::SetFullScreen(bool fullscreen) {
   bool fullscreen_to_normal_detected = IsFullscreen() && !fullscreen;
   ...
   if (fullscreen_to_normal_detected && !IsVisible()) {
       LONG frame_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE);
       frame_style |= WS_VISIBLE;
       ::SetWindowLong(GetAcceleratedWidget(), GWL_STYLE, frame_style);
   }
   ...
}

Includes tests (this branch passes, old behavior fails)

Fixes #6036

@dharders

dharders commented Jun 1, 2017

Copy link
Copy Markdown
Author

Hmmm, Travis is being funky. All tests passed, yet Job #11868.1 build script still exited with 1.

Care to take a look anyone ?

/ping @kevinsawicki

@dharders
dharders force-pushed the issue6036-fix-windows-fullscreen-startup-toggle branch from ce27507 to aeb68c2 Compare June 5, 2017 01:39
@dharders

dharders commented Jun 5, 2017

Copy link
Copy Markdown
Author

Never mind, re-ran tests and all green now!

@kevinsawicki kevinsawicki self-assigned this Jun 5, 2017

@kevinsawicki kevinsawicki left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for figuring this one out, awesome to see the fix for it 👍

Left a few minor comments, let me know what you think.

Comment thread atom/browser/native_window_views.cc Outdated

#if defined(OS_WIN)
// There is no native fullscreen state on Windows.
bool fullscreen_to_normal_detected = IsFullscreen() && !fullscreen;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What do you think about calling this leaving_fullscreen instead?

Comment thread atom/browser/native_window_views.cc Outdated
if (fullscreen_to_normal_detected && !IsVisible()) {
LONG frame_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE);
frame_style |= WS_VISIBLE;
::SetWindowLong(GetAcceleratedWidget(), GWL_STYLE, frame_style);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This could just be:

FlipWindowStyle(GetAcceleratedWidget(), true, WS_VISIBLE);

Comment thread spec/api-browser-window-spec.js Outdated
assert.equal(w.isVisible(), false)
assert.equal(w.isFullScreen(), false)
done()
}, 1000)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of a setTimeout, could this just wait for the leave-full-screen event and verify the state after that fires:

w.once('leave-full-screen', () => {
  assert.equal(w.isVisible(), false)
  assert.equal(w.isFullScreen(), false)
  done()
})
w.setFullScreen(false)

@dharders
dharders force-pushed the issue6036-fix-windows-fullscreen-startup-toggle branch 2 times, most recently from 00aad74 to 112f465 Compare June 14, 2017 01:30
@dharders

Copy link
Copy Markdown
Author

Changes made, as requested.

ping @kevinsawicki

@kevinsawicki

Copy link
Copy Markdown
Contributor

Thanks for fixing this @dharders 👍 :shipit: 🎉

@kevinsawicki
kevinsawicki merged commit 45dc6fc into electron:master Jun 14, 2017
@dharders
dharders deleted the issue6036-fix-windows-fullscreen-startup-toggle branch June 15, 2017 03:29
@dharders

Copy link
Copy Markdown
Author

FYI: Released in "electron": "1.7.4 beta"

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.

Starting in fullscreen then toggling to windowed mode results in black screen (1.2.x)

3 participants