修复'失去焦点隐藏'有时无效的问题。

This commit is contained in:
unknown 2024-11-09 16:39:26 +08:00
parent 07912ea276
commit 0c2ae8ae5b

View File

@ -215,6 +215,8 @@ function createMainWindow() {
// 中间单击
showHideMouseWheelClick();
}
// 失去焦点隐藏
onBlurHide();
}
});
// 禁用标题栏右键
@ -229,6 +231,49 @@ function createMainWindow() {
});
}
/**
*
*/
function onBlurHide() {
if (
mainWindow.isVisible() &&
global.setting.general.hideLoseFocus &&
!global.setting.general.alwaysTop &&
mainWindow.getChildWindows().length === 0 &&
!global.mainWindowShowDialog &&
!hasCursorPosWindow(mainWindow)
) {
// 隐藏窗口
hideMainWindow();
}
}
/**
*
*/
function hasCursorPosWindow(window: BrowserWindow) {
if (window && !window.isDestroyed() && window.isVisible()) {
// 获取鼠标位置
let point = screen.getCursorScreenPoint();
// 窗口位置信息
let bounds = window.getBounds();
// 判断鼠标是否在窗口以外
if (
point.x < bounds.x ||
point.x > bounds.x + bounds.width ||
point.y < bounds.y ||
point.y > bounds.y + bounds.height
) {
// 窗口以外
return false;
} else {
// 窗口以内
return true;
}
}
return false;
}
/**
*
* @param blurHide