generated from electron-react-boilerplate/electron-react-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(hide): fixing hideInstant with global debounce
- Loading branch information
1 parent
f805b6c
commit eba4d0f
Showing
6 changed files
with
54 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { BrowserWindow } from 'electron'; | ||
import { kitState } from '../state'; | ||
import shims from '../shims'; | ||
|
||
export const hideInstant = debounce( | ||
(window: BrowserWindow) => { | ||
if (!window || window.isDestroyed() || !window.isVisible()) { | ||
return; | ||
} | ||
|
||
if (kitState.isWindows) { | ||
// Windows-specific hide logic | ||
shims['@johnlindquist/node-window-manager'].windowManager.hideInstantly(window.getNativeWindowHandle()); | ||
if (window.isFocused()) { | ||
window.emit('blur'); | ||
window.emit('hide'); | ||
} | ||
} else if (kitState.isMac) { | ||
// macOS-specific hide logic | ||
shims['@johnlindquist/mac-panel-window'].hideInstant(window); | ||
} else if (kitState.isLinux) { | ||
// Linux logic | ||
window.hide(); | ||
} | ||
}, | ||
100, | ||
{ leading: true, trailing: false }, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters