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