Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(App): Fix app focus detection
  • Loading branch information
adlk committed Jun 1, 2021
1 parent c32aed2 commit c42337f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/electron/ipc-api/focusState.js
@@ -0,0 +1,9 @@
export default (params) => {
params.mainWindow.on('focus', () => {
params.mainWindow.webContents.send('isWindowFocused', true);
});

params.mainWindow.on('blur', () => {
params.mainWindow.webContents.send('isWindowFocused', false);
});
};
2 changes: 2 additions & 0 deletions src/electron/ipc-api/index.js
Expand Up @@ -5,6 +5,7 @@ import download from './download';
import cld from './cld';
import dnd from './dnd';
import desktopCapturer from './desktopCapturer';
import focusState from './focusState';

export default (params) => {
settings(params);
Expand All @@ -14,4 +15,5 @@ export default (params) => {
cld(params);
dnd();
desktopCapturer();
focusState(params);
};
7 changes: 3 additions & 4 deletions src/stores/AppStore.js
Expand Up @@ -198,10 +198,9 @@ export default class AppStore extends Store {
this.isSystemDarkModeEnabled = nativeTheme.shouldUseDarkColors;
onVisibilityChange((isVisible) => {
this.isFocused = isVisible;
debug('Window is visible/focused', isVisible);
ipcRenderer.on('isWindowFocused', (event, isFocused) => {
debug('Setting is focused to', isFocused);
this.isFocused = isFocused;
});
// analytics autorun
Expand Down

0 comments on commit c42337f

Please sign in to comment.