Open new window offset from last focused window (Credit: albinekb)#581
Open new window offset from last focused window (Credit: albinekb)#581MrRio merged 8 commits intovercel:masterfrom
Conversation
|
See #576 |
|
Looks good 👍 |
app/index.js
Outdated
| win.loadURL(url); | ||
|
|
||
| // Make sure this newly opened window is seen to now have focus | ||
| win.focusTime = process.uptime(); |
There was a problem hiding this comment.
The idea is perfect :)
However it's a risky design choice in my opinion. Maybe it would be better to just trigger win.focus() (if it works) or encapsulate both this win.focusTime = process.uptime(); and the one at line 287 in a function called registerFocusTime (or something similar).
So, if in a future someone will patch how the focus time is stored, it will only to change that function and getLastFocusedWindow().
My 2 cents ;)
|
I reckon we just emit the event when the window opens |
app/index.js
Outdated
| win.on('focus', () => { | ||
| win.focusTime = process.uptime(); | ||
| }); | ||
| win.emit('focus'); |
There was a problem hiding this comment.
Maybe add a comment on why this is here 🙈
There was a problem hiding this comment.
Hah, yeah you're right
|
@albinekb @lordgiotto If you guys are happy, I'll get this merged in |
app/index.js
Outdated
| }); | ||
| // The focus event doesn't fire on win.show, but we need | ||
| // this to track the most recent window in focusedWindow | ||
| win.emit('focus'); |
There was a problem hiding this comment.
Please don't hate me!! 🙈 Only a small and maybe irrelevant thing about the comment.
win.show triggers focus correctly, according to the electron docs: but we trigger win.show too late for our purposes.
|
The event does fire from Shell -> New Window, but not from Dock -> New Window, I've added a bug ticket for that. #583 |
* master: chore(package): update react to version 15.3.1 (vercel#637) Fix vercel#527: validate cursorColor value and apply default if it fails (vercel#590) Added customChildrenBefore to the tabs. (vercel#580) Fix for markdown files (vercel#618) Provide clear selection of text in terminal view (vercel#608) Added shellArgs to the config. (vercel#572) Fix international tilde character, and ` and ´ (vercel#584) chore(package): update electron-prebuilt to version 1.3.3 (vercel#604) chore(package): update should to version 11.0.0 (vercel#602) Comments for ignored stuff A little shorter Unneeded space Open new window offset from last focused window (Credit: albinekb) (vercel#581) Fix maximizing behaviour (vercel#176) Fix mapXDispatch and allow plugin to access onWheel (credit: lkzhao) (vercel#578) Use single quotes for better compatibility (vercel#575) Add config for bell (vercel#468) chore(package): update electron-prebuilt to version 1.3.2 (vercel#553) Moved "file-uri-to-path" dep to app package.json (vercel#569)
Full credit to albinekb -- this PR also fixes the issue with opening multi windows in a row.