Skip to content

Commit

Permalink
fix show/hide bug; use CSS vs Electron where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
lacymorrow committed Jun 5, 2023
1 parent ecc32af commit 65c3583
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
11 changes: 7 additions & 4 deletions src/main/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,20 @@ const center = options => {

const showWindow = () => {

each( win => win.showInactive() )
// Todo: showInactive() can be used in later versions of Electron
// each( win => win.showInactive() )

windows.win.webContents.send( 'remove_class', 'hidden' )
windows.hidden = false

}

const hideWindow = () => {

each( win => win.hide() )
// Previously:
// each( win => win.hide() )

windows.win.webContents.send( 'add_class', 'hidden' )
windows.hidden = true

}
Expand All @@ -398,8 +403,6 @@ const showHideWindow = () => {

}

windows.hidden = !windows.hidden

}

const moveToNextDisplay = options => {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const api = {
receive( channel, func ) {

const validChannels = new Set( [
'add_class', 'notify', 'lock_window', 'preload_sounds', 'play_sound', 'set_crosshair', 'set_info_icon', 'set_properties', 'set_reticle',
'add_class', 'remove_class', 'notify', 'lock_window', 'preload_sounds', 'play_sound', 'set_crosshair', 'set_info_icon', 'set_properties', 'set_reticle',
] )

if ( validChannels.has( channel ) ) {
Expand Down
7 changes: 7 additions & 0 deletions src/renderer/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

} )

// Add/Remove classes
window.crossover.receive( 'add_class', arg => {

// Trigger things
Expand All @@ -78,6 +79,12 @@

} )

window.crossover.receive( 'remove_class', arg => {

document.body.classList.remove( arg )

} )

// Sounds
window.crossover.receive( 'preload_sounds', arg => {

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/styles/dist/index.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/renderer/styles/dist/index.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions src/renderer/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
text-rendering: optimizeLegibility;
font-feature-settings: 'liga', 'clig', 'kern';
&.hidden {
display: none;
}

}

Expand Down Expand Up @@ -496,3 +493,8 @@ label {
display: flex;
justify-content: space-between;
}

.hidden {
display: none;
pointer-events: none;
}

0 comments on commit 65c3583

Please sign in to comment.