mirror of https://github.com/keeweb/keeweb.git
focus issues fix
This commit is contained in:
parent
b2f439ff0b
commit
ab0da3f49c
|
@ -6,18 +6,20 @@ const FocusDetector = {
|
||||||
init() {
|
init() {
|
||||||
this.isFocused = true;
|
this.isFocused = true;
|
||||||
this.detectsFocusWithEvents = !FeatureDetector.isDesktop && !FeatureDetector.isMobile;
|
this.detectsFocusWithEvents = !FeatureDetector.isDesktop && !FeatureDetector.isMobile;
|
||||||
window.addEventListener('focus', () => {
|
if (this.detectsFocusWithEvents) {
|
||||||
if (!FocusDetector.isFocused) {
|
window.addEventListener('focus', () => {
|
||||||
FocusDetector.isFocused = true;
|
if (!FocusDetector.isFocused) {
|
||||||
Backbone.trigger('focus');
|
FocusDetector.isFocused = true;
|
||||||
}
|
Backbone.trigger('main-window-focus');
|
||||||
});
|
}
|
||||||
window.addEventListener('blur', () => {
|
});
|
||||||
if (FocusDetector.isFocused) {
|
window.addEventListener('blur', () => {
|
||||||
FocusDetector.isFocused = false;
|
if (FocusDetector.isFocused) {
|
||||||
Backbone.trigger('blur');
|
FocusDetector.isFocused = false;
|
||||||
}
|
Backbone.trigger('main-window-blur');
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
hasFocus() {
|
hasFocus() {
|
||||||
|
|
|
@ -69,7 +69,7 @@ const OpenView = Backbone.View.extend({
|
||||||
KeyHandler.onKey(Keys.DOM_VK_RETURN, this.enterKeyPress, this);
|
KeyHandler.onKey(Keys.DOM_VK_RETURN, this.enterKeyPress, this);
|
||||||
KeyHandler.onKey(Keys.DOM_VK_DOWN, this.moveOpenFileSelectionDown, this);
|
KeyHandler.onKey(Keys.DOM_VK_DOWN, this.moveOpenFileSelectionDown, this);
|
||||||
KeyHandler.onKey(Keys.DOM_VK_UP, this.moveOpenFileSelectionUp, this);
|
KeyHandler.onKey(Keys.DOM_VK_UP, this.moveOpenFileSelectionUp, this);
|
||||||
this.listenTo(Backbone, 'focus', this.windowFocused.bind(this));
|
this.listenTo(Backbone, 'main-window-focus', this.windowFocused.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function () {
|
render: function () {
|
||||||
|
|
|
@ -175,6 +175,7 @@ function createMainWindow() {
|
||||||
mainWindow.on('move', delaySaveMainWindowPosition);
|
mainWindow.on('move', delaySaveMainWindowPosition);
|
||||||
mainWindow.on('restore', coerceMainWindowPositionToConnectedDisplay);
|
mainWindow.on('restore', coerceMainWindowPositionToConnectedDisplay);
|
||||||
mainWindow.on('close', updateMainWindowPositionIfPending);
|
mainWindow.on('close', updateMainWindowPositionIfPending);
|
||||||
|
mainWindow.on('focus', mainWindowFocus);
|
||||||
mainWindow.on('blur', mainWindowBlur);
|
mainWindow.on('blur', mainWindowBlur);
|
||||||
mainWindow.on('closed', () => {
|
mainWindow.on('closed', () => {
|
||||||
mainWindow = null;
|
mainWindow = null;
|
||||||
|
@ -282,6 +283,10 @@ function mainWindowBlur() {
|
||||||
emitBackboneEvent('main-window-blur');
|
emitBackboneEvent('main-window-blur');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mainWindowFocus() {
|
||||||
|
emitBackboneEvent('main-window-focus');
|
||||||
|
}
|
||||||
|
|
||||||
function emitBackboneEvent(e, arg) {
|
function emitBackboneEvent(e, arg) {
|
||||||
if (mainWindow && mainWindow.webContents) {
|
if (mainWindow && mainWindow.webContents) {
|
||||||
arg = JSON.stringify(arg);
|
arg = JSON.stringify(arg);
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
Release notes
|
Release notes
|
||||||
-------------
|
-------------
|
||||||
|
##### v1.7.7 (2019-02-09)
|
||||||
|
`-` another attempt to fix focus issues
|
||||||
|
|
||||||
##### v1.7.6 (2019-02-07)
|
##### v1.7.6 (2019-02-07)
|
||||||
`-` fixed focus issues in desktop apps
|
`-` fixed focus issues in desktop apps
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue