From ab5892c60e6f5487b08115c0d8fddc44b709c77c Mon Sep 17 00:00:00 2001 From: John Knox Date: Wed, 4 Dec 2019 06:50:38 -0800 Subject: [PATCH] Fix initial window focus bug Summary: When launching flipper release build, the initial window focus was wrong, so it appeared unfocussed. Clicking away and then back to the window would fix it. This should set the initial focus to be correct from the start. Task has more details. Reviewed By: mweststrate Differential Revision: D18808306 fbshipit-source-id: 2c5828d0b3298594dc30f956bb14141e6cff5918 --- src/dispatcher/application.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/dispatcher/application.tsx b/src/dispatcher/application.tsx index 925f862a8..d915c18be 100644 --- a/src/dispatcher/application.tsx +++ b/src/dispatcher/application.tsx @@ -56,6 +56,16 @@ export default (store: Store, logger: Logger) => { }); }); + // windowIsFocussed is initialized in the store before the app is fully ready. + // So wait until everything is up and running and then check and set the isFocussed state. + window.addEventListener('flipper-store-ready', () => { + const isFocussed = currentWindow.isFocused(); + store.dispatch({ + type: 'windowIsFocused', + payload: isFocussed, + }); + }); + ipcRenderer.on( 'flipper-protocol-handler', (_event: string, query: string) => {