Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

windows restore in the correct order to ensure correct focused window #13161

Merged
merged 1 commit into from
Feb 19, 2018

Conversation

petemill
Copy link
Member

@petemill petemill commented Feb 16, 2018

Do not merge before #12438 since it's best to test this fix with those changes too as that PR changes a lot of window logic. This PR should only show 1 commit to merge.

Fix #13158

Note that this test plan may never be 100% robust, but this gets us closer.
There will be additional cases that cannot reproduce success (i.e. if a window is macOS fullscreen), but the code to 'fix' those scenarios would likely introduce new issues and/or not be maintainable, for arguably small benefit.

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.
  • Request a security/privacy review as needed. (Ask a Brave employee to help if you cannot access this document.)

Test Plan:

On #13158

Reviewer Checklist:

  • Request a security/privacy review as needed if one was not already requested.

Tests

  • Adequate test coverage exists to prevent regressions
  • Tests should be independent and work correctly when run individually or as a suite ref
  • New files have MPL2 license header

@codecov-io
Copy link

codecov-io commented Feb 16, 2018

Codecov Report

Merging #13161 into master will decrease coverage by 0.02%.
The diff coverage is 34.37%.

@@            Coverage Diff             @@
##           master   #13161      +/-   ##
==========================================
- Coverage   56.18%   56.15%   -0.03%     
==========================================
  Files         279      279              
  Lines       27873    27895      +22     
  Branches     4560     4564       +4     
==========================================
+ Hits        15660    15665       +5     
- Misses      12213    12230      +17
Flag Coverage Δ
#unittest 56.15% <34.37%> (-0.03%) ⬇️
Impacted Files Coverage Δ
js/stores/windowStore.js 27.95% <14.28%> (-0.05%) ⬇️
app/browser/windows.js 33.62% <40%> (-0.38%) ⬇️

@petemill petemill force-pushed the fix/window-restore-focus branch from 5eda49a to 8d2a42e Compare February 16, 2018 19:08
@petemill petemill added the bug label Feb 16, 2018
@@ -77,6 +77,9 @@ ipc.on(messages.INITIALIZE_WINDOW, (e, mem) => {
const windowValue = message.windowValue

currentWindow.setWindowId(windowValue.id)
if (process.env.NODE_ENV === 'development') {
console.debug(`This Window's ID is:`, windowValue.id)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a little something in each window's console.log to aid window debugging (when in dev mode, and set to show debug messages).

@@ -752,21 +750,18 @@ const doAction = (action) => {
}
break
}
case windowConstants.WINDOW_ON_WINDOW_UPDATE:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constant does not exist

let windowValue = makeImmutable(action.windowValue)

if (windowValue.get('focused')) {
windowValue = windowValue.set('focusTime', performance.timing.navigationStart + performance.now())
Copy link
Member Author

@petemill petemill Feb 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be set whenever window is updated (not only when it's ready) as we want to save when each window last had focus. Also we can use new Date().getTime() as milliseconds are perfectly fine, we don't need to resolve to a microsecond for this.

…dex is restored and the previously-focused window gets focus

Fix #13158
@bsclifton bsclifton force-pushed the fix/window-restore-focus branch from 8d2a42e to a0133fe Compare February 19, 2018 06:17
Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look great- I tested before and after and confirmed the fix 😄 👍

@bsclifton bsclifton merged commit 1f4058e into master Feb 19, 2018
@bsclifton bsclifton deleted the fix/window-restore-focus branch February 19, 2018 06:27
bsclifton added a commit that referenced this pull request Feb 19, 2018
windows restore in the correct order to ensure correct focused window
bsclifton added a commit that referenced this pull request Feb 19, 2018
windows restore in the correct order to ensure correct focused window
@bsclifton
Copy link
Member

master 1f4058e
0.22.x 7fd3c16
0.21.x 9d1d278

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Focused window does not have focus when restarting
3 participants