修复在 Windows 系统下缩放比非100%时,拖动桌面歌词会自动加大桌面歌词窗口的问题
This commit is contained in:
@@ -67,29 +67,29 @@ const winEvent = lyricWindow => {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
let offset = 8
|
||||
const createWindow = () => {
|
||||
if (global.modules.lyricWindow) return
|
||||
if (!global.appSetting.desktopLyric.enable) return
|
||||
// const windowSizeInfo = getWindowSizeInfo(global.appSetting)
|
||||
let { x, y, width, height, isAlwaysOnTop } = global.appSetting.desktopLyric
|
||||
let { width: screenWidth, height: screenHeight } = global.envParams.workAreaSize
|
||||
screenWidth += 16
|
||||
screenHeight += 16
|
||||
screenWidth += offset * 2
|
||||
screenHeight += offset * 2
|
||||
if (x == null) {
|
||||
x = screenWidth - width - 8
|
||||
y = screenHeight - height - 8
|
||||
x = screenWidth - width - offset
|
||||
y = screenHeight - height - offset
|
||||
}
|
||||
/**
|
||||
* Initial window options
|
||||
*/
|
||||
global.modules.lyricWindow = new BrowserWindow({
|
||||
height: height > screenHeight ? screenHeight : height,
|
||||
width: width > screenWidth ? screenWidth : width,
|
||||
x: Math.max(-8, screenWidth < (width + x) ? screenWidth - width : x),
|
||||
y: Math.max(-8, screenHeight < (height + y) ? screenHeight - height : y),
|
||||
minWidth: 300,
|
||||
minHeight: 300,
|
||||
height: Math.max(height > screenHeight ? screenHeight : height, 80),
|
||||
width: Math.max(width > screenWidth ? screenWidth : width, 380),
|
||||
x: Math.max(-offset, screenWidth < (width + x) ? screenWidth - width : x),
|
||||
y: Math.max(-offset, screenHeight < (height + y) ? screenHeight - height : y),
|
||||
minWidth: 380,
|
||||
minHeight: 80,
|
||||
useContentSize: true,
|
||||
frame: false,
|
||||
transparent: true,
|
||||
|
||||
@@ -31,32 +31,33 @@ let winX
|
||||
let winY
|
||||
let wasW
|
||||
let wasY
|
||||
let offset = 8
|
||||
mainOn(ipcWinLyricNames.set_win_bounds, (event, { x = 0, y = 0, w = 0, h = 0 }) => {
|
||||
if (!global.modules.lyricWindow) return
|
||||
bounds = global.modules.lyricWindow.getBounds()
|
||||
wasW = global.envParams.workAreaSize.width
|
||||
wasY = global.envParams.workAreaSize.height + 8
|
||||
wasY = global.envParams.workAreaSize.height + offset
|
||||
|
||||
bounds.width = w + bounds.width
|
||||
bounds.height = h + bounds.height
|
||||
if (bounds.width > wasW - 8) {
|
||||
bounds.width = wasW - 8
|
||||
} else if (bounds.width < 300) {
|
||||
bounds.width = 300
|
||||
bounds.width = w
|
||||
bounds.height = h
|
||||
if (bounds.width > wasW - offset) {
|
||||
bounds.width = wasW - offset
|
||||
} else if (bounds.width < 380) {
|
||||
bounds.width = 380
|
||||
}
|
||||
if (bounds.height > wasY) {
|
||||
bounds.height = wasY + 8
|
||||
} else if (bounds.height < 120) {
|
||||
bounds.height = 120
|
||||
bounds.height = wasY + offset
|
||||
} else if (bounds.height < 80) {
|
||||
bounds.height = 80
|
||||
}
|
||||
|
||||
|
||||
if (x != 0) {
|
||||
winX = bounds.x + x
|
||||
if (winX > wasW - bounds.width + 8) {
|
||||
winX = wasW - bounds.width + 8
|
||||
} else if (winX < -8) {
|
||||
winX = -8
|
||||
if (winX > wasW - bounds.width + offset) {
|
||||
winX = wasW - bounds.width + offset
|
||||
} else if (winX < -offset) {
|
||||
winX = -offset
|
||||
}
|
||||
bounds.x = winX
|
||||
}
|
||||
@@ -64,12 +65,12 @@ mainOn(ipcWinLyricNames.set_win_bounds, (event, { x = 0, y = 0, w = 0, h = 0 })
|
||||
winY = bounds.y + y
|
||||
if (winY > wasY - bounds.height) {
|
||||
winY = wasY - bounds.height
|
||||
} else if (winY < -8) {
|
||||
winY = -8
|
||||
} else if (winY < -offset) {
|
||||
winY = -offset
|
||||
}
|
||||
bounds.y = winY
|
||||
}
|
||||
|
||||
// console.log(bounds)
|
||||
// console.log(bounds, x, y, w, h)
|
||||
global.modules.lyricWindow.setBounds(bounds)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user