Skip to content

Commit

Permalink
Stop overlay window closing via taskbar after Windows Explorer restart
Browse files Browse the repository at this point in the history
If Windows Explorer is restarted, the Tracky Mouse Screen Overlay window
appears in the taskbar.
See: #47
And: electron/electron#29526

This partially remedies the situation, by handling the case where the
user can try to close the screen overlay window, which isn't supposed
to be possible.
  • Loading branch information
1j01 committed Apr 17, 2024
1 parent 04db842 commit 9e851df
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions desktop-app/src/electron-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,23 @@ const createWindow = () => {
screenOverlayWindow.setAlwaysOnTop(true, 'screen-saver');

screenOverlayWindow.loadFile(`src/electron-screen-overlay.html`);
screenOverlayWindow.on('close', (event) => {
// If Windows Explorer is restarted while the app is running,
// the Screen Overlay Window can appear in the taskbar, and become closable.
// Various window attributes are forgotten, so we need to reset them.
// See: https://github.com/1j01/tracky-mouse/issues/47
// And: https://github.com/electron/electron/issues/29526
event.preventDefault();
screenOverlayWindow.setSkipTaskbar(true);
screenOverlayWindow.setClosable(false);
screenOverlayWindow.setFullScreen(true);
screenOverlayWindow.setIgnoreMouseEvents(true);
// I can't seem to get the window to show on top of the taskbar after it's closed,
// although it does show on top before it's closed, after Windows Explorer is restarted.
// So a more proactive approach of restoring skipTaskbar (and maybe closable) is needed.
screenOverlayWindow.setAlwaysOnTop(false);
screenOverlayWindow.setAlwaysOnTop(true, 'screen-saver');
});
screenOverlayWindow.on('closed', () => {
screenOverlayWindow = null;
});
Expand Down

0 comments on commit 9e851df

Please sign in to comment.