Main window receives an OnFocus event when a child window closes

Issue Description:
We noticed while testing the changes discussed in Add on-focus event for OW windows that we were receiving OnFocus events in the main window when a child window closes. But the main window is not actually focused.

Attached is a video showing the issue. Notice that the main window’s title bar will turn magenta when we receive an OnFocus event and the console will also print a debug log on focus or blur. At the end of the video, the main window is not the focused window but has gained a focus event.

In our app specifically, we have a child, in-game window that can be opened and closed by the user via hotkeys. Manifest for our in-game window looks like:

"overlay": {
  "transparent": true,
  "desktop_only": false,
  "in_game_only": true,
  "clickthrough": false,
  "mute": true,
  "resizable": true,
  "show_in_taskbar": false,
  "disable_restore_animation": true,
  "keep_window_location": true,

The issue does not appear to be limited to just in-game child windows though. I confirmed the same issue while testing the above as a desktop window, instead of in-game. (225.3 KB)

Steps to reproduce:
For our app specifically…

  1. Focus the main window by clicking anywhere in the app.
  2. Change focus to the game (Rocket League) by clicking anywhere in game.
  3. Change focus to the in-game window by clicking anywhere in the overlay window.
  4. Close the window via hotkeys.
  5. Notice that the main window has received an OnFocus event incorrectly.

Impact for my app: [low, mid, high, show-stopper]
High. It’s an annoyance as we depend on focus/blur events to know when the player has returned from a match so we can show a win animation. This is essential to our UX.

Hi @bryan and thanks for your patience.

I followed your steps to reproduce the issue: Instead of using your app, I used our events simulator.
(You disabled the app from working in my region).

I registered for these two events:

window.onfocus = function(){ console.log(":debug OnFocus"); };
window.onblur = function(){ console.log(":debug OnBlur"); };

Everything worked as expected.

Can you please update your version to the developer’s channel and confirm that it’s working as expected with our simulator?

Reproduction of this issue requires a child window to gain focus, thus the base events simulator app does not meet the requirements.

I have reproduced the issue in a modified version of the events simulator with your added focus/blur events. Attached zip contains the following contents:

  • ow-version.png (screenshot of my current OW version, showing latest on Developers)
  • onfocus-issue.mp4 (video showing reproduction in the modified events simulator app)
  • rocket-league-events-sample-app (modified events simulator app to include a child window)

Please follow these reproduction steps with the modified events simulator app:

  1. Prepare the test by opening the modified events simulator app, Rocket League, and the child window. The child window can be opened by pressing tab while in game.
  2. Click within the index window. Notice that the OnFocus event is received correctly.
  3. Click within Rocket League. Notice that the OnBlur event is received correctly.
  4. Click within the child window to gain focus to the child window.
  5. Click the x to close the child window.
  6. Notice that the index window has received the OnFocus event incorrectly. (1.7 MB)