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

Black screen on window close in fullscreen mode #20263

Closed
3 tasks done
alxmiron opened this issue Sep 17, 2019 · 10 comments
Closed
3 tasks done

Black screen on window close in fullscreen mode #20263

alxmiron opened this issue Sep 17, 2019 · 10 comments

Comments

@alxmiron
Copy link

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • 6.0.9
  • Operating System:
    • MacOS 10.14.6

To Reproduce

  1. Open electron window with control buttons by new BrowserWindow({ frame: true })
  2. Change close logic to default mac behavior - hide app on close, not quit. Can be done by
mainWindow.on('close', event => {
     event.preventDefault();
     mainWindow.hide();
});
  1. Set fullscreen mode
  2. Click close button

Expected Behavior

Window is hidden

Actual Behavior

Full screen gets black

Screenshots

Sep-17-2019 22-04-46

Notes

Bug is not actual if mainWindow was cloed from normal mode (not fullscreen)

@HaNdTriX
Copy link

HaNdTriX commented Sep 26, 2019

The same bug applies to Electron-Version 7 as well:

  • electron@7.0.0-beta.3
  • electron@7.0.0-beta.4
  • electron@7.0.0-beta.5

@alxmiron did you found a workaround?

window.on('close', (event) => {
  if (window.isFullScreen()) {
    window.setFullScreen(false)
  }
  // The following line is being ignored :-(
  window.hide()
})

@alxmiron
Copy link
Author

Not yet. Yes, you can exit fullscreen or exit entire app instead of hiding, but it's not an expected behavior

@jackple
Copy link

jackple commented Nov 25, 2019

@HaNdTriX @alxmiron You can use setTimeout, like:

if (is.macos && mainWindow.isFullScreen()) {
  mainWindow.setFullScreen(false)
  await wait(750)
}
mainWindow.hide()

@holmberd
Copy link

holmberd commented Apr 1, 2020

@jackple instead of a timeout you can use the callback from the leave-full-screen window event.

@agalwood
Copy link

I also encountered this problem, thanks to the leave-full-screen event mentioned by @holmberd , this is my code :

window.on('close', (event) => {
  if (window.isFullScreen()) {
    window.once('leave-full-screen', () => window.hide())

    window.setFullScreen(false)
  } else {
    window.hide()
  }
})

@whitemiaool
Copy link

+1

@electron-triage
Copy link

The Electron version reported on this issue is no longer supported. See our supported versions documentation.

If this is still reproducible on a supported version, please open a new issue with any other new information that a maintainer should know.

Thank you for taking the time to report this issue and helping to make Electron better! Your help is appreciated.

@schontz
Copy link

schontz commented Oct 25, 2021

This issue persists. Not that the workaround is particularly difficult, but it is a bug nonetheless. Please re-open.

@Safa-gh
Copy link

Safa-gh commented Oct 31, 2021

Reproduced on 13.6.1, please fix

@pushkin-
Copy link

reopened the issue here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
6.1.x
Unsorted Issues
Development

No branches or pull requests