Merge pull request #9645 from dharders/issue6036-fix-windows-fullscreen-startup-toggle
Fix unresponsive app after fullscreen->normal state toggle (Windows)
This commit is contained in:
		
				commit
				
					
						45dc6fc04f
					
				
			
		
					 2 changed files with 44 additions and 0 deletions
				
			
		| 
						 | 
					@ -480,6 +480,8 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(OS_WIN)
 | 
					#if defined(OS_WIN)
 | 
				
			||||||
  // There is no native fullscreen state on Windows.
 | 
					  // There is no native fullscreen state on Windows.
 | 
				
			||||||
 | 
					  bool leaving_fullscreen = IsFullscreen() && !fullscreen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (fullscreen) {
 | 
					  if (fullscreen) {
 | 
				
			||||||
    last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
 | 
					    last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
 | 
				
			||||||
    NotifyWindowEnterFullScreen();
 | 
					    NotifyWindowEnterFullScreen();
 | 
				
			||||||
| 
						 | 
					@ -505,6 +507,13 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) {
 | 
				
			||||||
  // 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.
 | 
				
			||||||
  window_->SetFullscreen(fullscreen);
 | 
					  window_->SetFullscreen(fullscreen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // If restoring from fullscreen and the window isn't visible, force visible,
 | 
				
			||||||
 | 
					  // else a non-responsive window shell could be rendered.
 | 
				
			||||||
 | 
					  // (this situation may arise when app starts with fullscreen: true)
 | 
				
			||||||
 | 
					  // Note: the following must be after "window_->SetFullscreen(fullscreen);"
 | 
				
			||||||
 | 
					  if (leaving_fullscreen && !IsVisible())
 | 
				
			||||||
 | 
					    FlipWindowStyle(GetAcceleratedWidget(), true, WS_VISIBLE);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
  if (IsVisible())
 | 
					  if (IsVisible())
 | 
				
			||||||
    window_->SetFullscreen(fullscreen);
 | 
					    window_->SetFullscreen(fullscreen);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2102,6 +2102,41 @@ describe('BrowserWindow module', function () {
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  describe('BrowserWindow.setFullScreen(false)', function () {
 | 
				
			||||||
 | 
					    // only applicable to windows: https://github.com/electron/electron/issues/6036
 | 
				
			||||||
 | 
					    if (process.platform !== 'win32') return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it('should restore a normal visible window from a fullscreen startup state', function (done) {
 | 
				
			||||||
 | 
					      w.webContents.once('did-finish-load', function () {
 | 
				
			||||||
 | 
					        // start fullscreen and hidden
 | 
				
			||||||
 | 
					        w.setFullScreen(true)
 | 
				
			||||||
 | 
					        w.once('show', function () {
 | 
				
			||||||
 | 
					          // restore window to normal state
 | 
				
			||||||
 | 
					          w.setFullScreen(false)
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					        w.once('leave-full-screen', function () {
 | 
				
			||||||
 | 
					          assert.equal(w.isVisible(), true)
 | 
				
			||||||
 | 
					          assert.equal(w.isFullScreen(), false)
 | 
				
			||||||
 | 
					          done()
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					        w.show()
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					      w.loadURL('about:blank')
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it('should keep window hidden if already in hidden state', function (done) {
 | 
				
			||||||
 | 
					      w.webContents.once('did-finish-load', function () {
 | 
				
			||||||
 | 
					        w.once('leave-full-screen', () => {
 | 
				
			||||||
 | 
					          assert.equal(w.isVisible(), false)
 | 
				
			||||||
 | 
					          assert.equal(w.isFullScreen(), false)
 | 
				
			||||||
 | 
					          done()
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					        w.setFullScreen(false)
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					      w.loadURL('about:blank')
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  describe('parent window', function () {
 | 
					  describe('parent window', function () {
 | 
				
			||||||
    let c = null
 | 
					    let c = null
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue