Repository navigation
grill run: hand the foreground back after the Battle.net window takes it - #93
Merged
Merged
Conversation
Each renewal request makes the app open a window that takes the foreground. The watcher minimized it, but that could leave no window in front, so a fullscreen program the user was in lost the foreground for good. The watcher now follows the window in front and, once the app has lost the foreground, hands it back to that window unless Windows already gave it to another.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Each sign-in renewal asks the Battle.net app to launch Warcraft III. The app opens a new window, and that window takes the foreground about 0.7 s later.
battlenet-window.ps1minimises it 40–60 ms afterwards, but minimising the foreground window does not reliably hand the foreground back.Measured with a
EVENT_SYSTEM_FOREGROUNDlogger: in the first run, all four requests left no window in front until the user clicked something, 12 s later in one case. A fullscreen program loses the foreground at that point: exclusive fullscreen minimises itself, and borderless stops receiving keyboard input. So every Run Map orgrill runinterrupts whatever the user is doing.Change
SetForegroundWindowwhile the app still holds the foreground, so the hand-back waits up to 0.5 s for the app to lose it, then tries until 1 s has passed.-Log, each hand-back outcome is printed.Validation
./gradlew test: 157 tests, 0 failures, 2 skipped.-Log, and the renewal script against the running Battle.net app:SetForegroundWindowin the "nothing in front" case. That state did not recur in the later runs.The same script goes to Run Map in wurstscript/WurstScript#1632.
grill runruns it with-FocusGame: once the watcher focuses the map's client, that client becomes the window it hands the foreground back to.