Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All popup windows steal focus from everything when they first appear in patch v2.0.1 #10

Closed
TiberiumFusion opened this issue Jan 16, 2024 · 3 comments
Labels
Patch Files Issue regards the patch files
Milestone

Comments

@TiberiumFusion
Copy link
Owner

TiberiumFusion commented Jan 16, 2024

Problem

  1. Do not already have a chat window open for your friend
  2. Launch a game
  3. Wait for game to load and Steam overlay to become available
  4. Friend messages you
  5. Steam drags you back to your desktop, where it has spawned a new chat window with the message from your friend, which has just stolen focus from your game.

Notes

I have verified that this occurs in patch v2.0.1, and that it does not occur in patch v1.2.0.

The problem seems to originate from some change(s) Valve made between 8200419 and 8601984.

Obviously the correct behavior is for the Steam overlay to handle the message notification without yanking you out of the game back to your desktop.

@TiberiumFusion TiberiumFusion added Patch Files Issue regards the patch files In Progress Issue research & resolution is currently underway labels Jan 16, 2024
@TiberiumFusion
Copy link
Owner Author

TiberiumFusion commented Jan 16, 2024

The issue has been identified (under the May 2023 client).

The problem in part is coming from the resolution to #9. When the fix for #9 is removed, this issue (focus stealing) no longer occurs.

Also, while the OP notes this happens when ingame, this also happens outside of games as well. All windows created by FriendsUI's inner frame (incl. Friends List and friend chat windows) automatically steal focus when they are first created. This is not the correct behavior.

Since the code that fixes #9 is present in 8200419 and 8200419 does not have this problem, the only conclusion is that the context surrounding calls to Show(e = d.IF.k_EWindowBringToFrontAndForceOS) has changed between 8200419 and 8601984. Either some larger logic changed in how windows are created and managed, or the methods Show() calls into are behaving differently in 8601984 versus 8200419.

@TiberiumFusion TiberiumFusion changed the title Messages from friends steal focus from games in 8601984 Messages from friends steal focus from games in patch v2.0.1 Jan 16, 2024
@TiberiumFusion TiberiumFusion changed the title Messages from friends steal focus from games in patch v2.0.1 Messages from friends steal focus from everything in patch v2.0.1 Jan 16, 2024
@TiberiumFusion
Copy link
Owner Author

TiberiumFusion commented Jan 16, 2024

The solution to this issue (focus stealing) is co-dependent on reverting the fix to #9 and devising a new fix for #9.

This might seem a little tricky, since the Dec 2022 client relies on the fix for #9 or else all chat windows are solid black, so we cannot comprise that.

The thorough solution involves hours of time digging through Valve's bastardized JS. Fuck that.
I don't like shortcut solutions, but in this case that's what's going to happen.

Solution

The fix for #9 changes 8601984's line:
r && (this.OnCreateInternal(), t != d.IF.k_EWindowBringToFrontInvalid && this.Focus(t)));
into:
r ? (this.OnCreateInternal(), t != d.IF.k_EWindowBringToFrontInvalid && this.Focus(t)) : (null === (n = null === (t = SteamClient.Features) || void 0 === t ? void 0 : t.SteamInitsPopups) || void 0 === n ? void 0 : n.call(t)) || this.OnCreateInternal() );
(which is taken verbatim from 8200419)

In the false path of the ternary, the n.call to t.SteamInitPopups is what is causing the window to take focus. The OnCreateInternal() call is what fixes the solid black rectangle bug. In the context of the showing the Friends List window, this is necessary and desired. In the context of showing auto-created friend chat windows when a message is received, this is not the correct behavior. However, by the time of 8601984, Valve has merged these contexts in some unknown way (versus 8200419, which keeps them separate), and that is causing problems.

It's anyone's guess why the n.call t.SteamInitPopups syntax is so rancid, why it is needed, or why this behavior is placed here and used in this context instead of elsewhere, but simply removing it and it alone resolves both #9 and this issue.

So the line is now:
r ? (this.OnCreateInternal(), t != d.IF.k_EWindowBringToFrontInvalid && this.Focus(t)) : this.OnCreateInternal() );
id est we are simply ensuring OnCreateInternal() will run regardless, which flips the pointless boolean noted in #9 that controls the awful rendering behavior of Valve's use of react.

Effects of solution

Making the change noted above, both #9 and this issue are resolved in my tests in both the May 2023 client (my primary baseline for this patch) and the Dec 2022 client, without any concessions or regressions (discovered so far). Hopefully it stays that way.

This will quickly be deployed into a hotfix update.

@TiberiumFusion
Copy link
Owner Author

Patch version 2.0.2 has been released, which resolves this issue as noted above.

@TiberiumFusion TiberiumFusion removed the In Progress Issue research & resolution is currently underway label Jan 16, 2024
@TiberiumFusion TiberiumFusion added this to the Release 2.0.2 milestone Jan 16, 2024
@TiberiumFusion TiberiumFusion changed the title Messages from friends steal focus from everything in patch v2.0.1 All popup windows steal focus from everything when they first appear in patch v2.0.1 Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Patch Files Issue regards the patch files
Projects
None yet
Development

No branches or pull requests

1 participant