Skip to content

Commit cab0215

Browse files
committed
fix #616
1 parent a02c4d2 commit cab0215

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

Diff for: js/webviews.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ ipc.on('captureData', function (e, data) {
461461

462462
/* focus the view when the window is focused */
463463

464-
window.addEventListener('focus', function () {
464+
ipc.on('windowFocus', function () {
465465
if (document.activeElement === document.body) {
466466
webviews.focus()
467467
}

Diff for: main/main.js

+4
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ function createWindowWithBounds (bounds, shouldMaximize) {
128128
return true
129129
})
130130

131+
mainWindow.on("focus", function() {
132+
sendIPCToWindow(mainWindow, 'windowFocus')
133+
})
134+
131135
mainWindow.on('minimize', function () {
132136
sendIPCToWindow(mainWindow, 'minimize')
133137
})

Diff for: main/viewManager.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ function setBounds (id, bounds) {
6464
}
6565

6666
function focusView (id) {
67-
viewMap[id].webContents.focus()
67+
// empty views can't be focused because they won't propogate keyboard events correctly, see https://github.com/minbrowser/min/issues/616
68+
if (viewMap[id].webContents.getURL() !== '') {
69+
viewMap[id].webContents.focus()
70+
} else {
71+
mainWindow.webContents.focus()
72+
}
6873
}
6974

7075
function hideCurrentView () {

0 commit comments

Comments
 (0)