[Bug]: webContents.setAlwaysOnTop(false) fail
terry2010 opened this issue · comments
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 a bug report that matches the one I want to file, without success.
Electron Version
19.0.6
What operating system are you using?
Windows
Operating System Version
windows 10
What arch are you using?
x64
Last Known Working Electron version
never works
Expected Behavior
- execute mainWindow.setAlwaysOnTop(true) , window on top, cover other windows
- mouse don't touch mainWindow, and execute mainWindow.setAlwaysOnTop(false)
- mouse don't touch mainWindow, click any other full screen window, mainWindow will hidden
Actual Behavior
- execute mainWindow.setAlwaysOnTop(true) , window on top, cover other windows (✔)
- mouse don't touch mainWindow, and execute mainWindow.setAlwaysOnTop(false) (✔)
- mouse don't touch mainWindow, click any other full screen window, mainWindow will hidden (✖)
Actual Behavior:
3.1 mouse don't touch mainWindow, click any other full screen window, mainWindow still on top
3.2 mouse must click mainWindow , then click any other full screen window, mainWindow hidden
Testcase Gist URL
https://gist.github.com/6bccc9ff43b9a1dd1661e774e4bf8cc8
Additional Information
No response
My understanding is that since the Fiddle window is still in focus when the newly rendered window switches to setAlwaysOnTop(false)
, nothing gets triggered for it to move higher. It is only the next window to be in focus that will note the change. (For example, with Fiddle not full-screened I was able to select a different application window after the switch and that window was placed on top). This behavior seems logical to me (albeit a bit confusing), so I don't think this is an Electron bug.
I will be closing this now, but if someone believes this to be done in error, feel free to reopen it to discuss.
My understanding is that since the Fiddle window is still in focus when the newly rendered window switches to
setAlwaysOnTop(false)
, nothing gets triggered for it to move higher. It is only the next window to be in focus that will note the change. (For example, with Fiddle not full-screened I was able to select a different application window after the switch and that window was placed on top). This behavior seems logical to me (albeit a bit confusing), so I don't think this is an Electron bug.I will be closing this now, but if someone believes this to be done in error, feel free to reopen it to discuss.
Here is a scene:
an application has 2 window, win1 is prepare window, win2 is main window
- User click app icon to start this application
- win1 shows, and download some security data from remote server . win2 is hide at this time.
- after some minutes , data downloaded and decrypted
- hide win1
- show win2 ,and focusd on this win2
at step2, the real user action is : The user sees the prompt of win1 and open fullscreen chrome to continue browsing the web.
so , the real step5 is :
win2 shows and on top. tell user I'm ready, you could start work. but user decide to continue browsing the web.
now is the bug:
case 1 : user click chrome , but win2 still on top , user can't continue browsing the web
case 2: user must click win2 , then cilck chrome . This is an unnecessary and should never occur user action
Expected action:
user clicks fullscreen chrome , win2 hide, user continue browsing the web
Also :
wechat (windows version) has the expected action.
1. open a fullscreen chrome
2. open wechat
3. login wechat
4. click chrome immediately to hide wechat login window
5. wechat main window shows in screen center after successfullly finished login process
6. do not touch wechat , click chrome
7. wechat hide , chrome shows
As there seems to be a difference between this and the macOS functionality, it may be worth exploring in the future. For now however, the inclusion of focusing on the window after the switch should provide the functionality you are looking for. You can try adding mainWindow.focus()
after line 31 in the main.js
file of your gist.
As there seems to be a difference between this and the macOS functionality, it may be worth exploring in the future. For now however, the inclusion of focusing on the window after the switch should provide the functionality you are looking for. You can try adding
mainWindow.focus()
after line 31 in themain.js
file of your gist.
It still not work
- windows 10 (21H2,19044.1766) electron 19.0.6
still not works, and it has the same behavior as the old code - macos (11.6 x64) , electron 19.0.6
has strange behavior : mainWindow auto hide after code excutesmainWindow.focus()