Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #731 #887,修复桌面歌词与主窗口阴影残留 #1869

Merged
merged 5 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion publish/changeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

- 修复存在多级弹窗时的背景显示问题
- 增大在线导入自定义源文件的大小限制问题(#1857)
- 在歌词滚动结束后清理窗口阴影,缓解Mac下桌面歌词出现残留阴影的问题
- 在歌词滚动结束后清理窗口阴影,缓解Mac下桌面歌词出现残留阴影的问题(#1869, Thanks @zclorne)

### 变更

Expand Down
1 change: 0 additions & 1 deletion src/common/ipcNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ const modules = {
key_down: 'key_down',
request_main_window_channel: 'request_main_window_channel',
provide_main_window_channel: 'provide_main_window_channel',
invalidate_shadow: 'invalidate_shadow',
},
hotKey: {
enable: 'enable',
Expand Down
1 change: 1 addition & 0 deletions src/main/modules/userApi/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const createWindow = async(userApi: LX.UserApi.UserApiInfo) => {
minimizable: false,
maximizable: false,
fullscreenable: false,
hasShadow: false,
show: false,
webPreferences: {
contextIsolation: true,
Expand Down
6 changes: 1 addition & 5 deletions src/main/modules/winLyric/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export const createWindow = () => {
useContentSize: true,
frame: false,
transparent: true,
hasShadow: false,
// enableRemoteModule: false,
// icon: join(global.__static, isWin ? 'icons/256x256.ico' : 'icons/512x512.png'),
resizable: false,
Expand Down Expand Up @@ -194,11 +195,6 @@ export const getMainFrame = (): Electron.WebFrameMain | null => {
return browserWindow.webContents.mainFrame
}

export const invalidateShadow = () => {
if (!browserWindow) return
browserWindow.invalidateShadow()
}

interface AlwaysOnTopTools {
timeout: NodeJS.Timeout | null
setAlwaysOnTop: (isLoop: boolean) => void
Expand Down
6 changes: 1 addition & 5 deletions src/main/modules/winLyric/rendererEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { mainOn, mainHandle } from '@common/mainIpc'
import { WIN_LYRIC_RENDERER_EVENT_NAME } from '@common/ipcNames'
import { buildLyricConfig, getLyricWindowBounds } from './utils'
import { sendNewDesktopLyricClient } from '@main/modules/winMain'
import { getBounds, getMainFrame, invalidateShadow, sendEvent, setBounds } from './main'
import { getBounds, getMainFrame, sendEvent, setBounds } from './main'
import { MessageChannelMain } from 'electron'


Expand All @@ -29,10 +29,6 @@ export default () => {
setBounds(getLyricWindowBounds(getBounds(), options))
})

mainOn(WIN_LYRIC_RENDERER_EVENT_NAME.invalidate_shadow, () => {
invalidateShadow()
})

mainOn(WIN_LYRIC_RENDERER_EVENT_NAME.request_main_window_channel, ({ event }) => {
if (event.senderFrame !== getMainFrame()) return
// Create a new channel ...
Expand Down
1 change: 1 addition & 0 deletions src/main/modules/winMain/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const createWindow = () => {
width: windowSizeInfo.width,
frame: false,
transparent: !global.envParams.cmdParams.dt,
hasShadow: global.envParams.cmdParams.dt,
// enableRemoteModule: false,
// icon: join(global.__static, isWin ? 'icons/256x256.ico' : 'icons/512x512.png'),
resizable: false,
Expand Down
11 changes: 3 additions & 8 deletions src/renderer-lyric/components/layout/LyricHorizontal/useLyric.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ref, onMounted, onBeforeUnmount, watch, nextTick } from '@common/utils/
import { scrollTo } from '@common/utils/renderer'
import { lyric } from '@lyric/store/lyric'
import { isPlay, setting } from '@lyric/store/state'
import { invalidateShadow, setWindowBounds } from '@lyric/utils/ipc'
import { setWindowBounds } from '@lyric/utils/ipc'

const getOffsetTop = (contentHeight, lineHeight) => {
switch (setting['desktopLyric.scrollAlign']) {
Expand Down Expand Up @@ -45,13 +45,9 @@ export default (isComputeHeight) => {
offset = prevActiveLine < lyric.line ? ((dom_lines[prevActiveLine]?.clientHeight ?? 0) - prevLineHeight) : 0
// console.log(prevActiveLine, dom_lines[prevActiveLine]?.clientHeight ?? 0, prevLineHeight, offset)
}
cancelScrollFn = scrollTo(dom_lyric.value, dom_p ? (dom_p.offsetTop - offset - getOffsetTop(dom_lyric.value.clientHeight, dom_p.clientHeight)) : 0, duration, () => {
invalidateShadow()
})
cancelScrollFn = scrollTo(dom_lyric.value, dom_p ? (dom_p.offsetTop - offset - getOffsetTop(dom_lyric.value.clientHeight, dom_p.clientHeight)) : 0, duration)
} else {
cancelScrollFn = scrollTo(dom_lyric.value, 0, duration, () => {
invalidateShadow()
})
cancelScrollFn = scrollTo(dom_lyric.value, 0, duration)
}
}
const clearLyricScrollTimeout = () => {
Expand Down Expand Up @@ -162,7 +158,6 @@ export default (isComputeHeight) => {
setLyric(lines)
} else {
cancelScrollFn = scrollTo(dom_lyric.value, 0, 300, () => {
invalidateShadow()
if (lyric.lines !== lines) return
setLyric(lines)
}, 50)
Expand Down
11 changes: 3 additions & 8 deletions src/renderer-lyric/components/layout/LyricVertical/useLyric.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ref, onMounted, onBeforeUnmount, watch, nextTick } from '@common/utils/
import { scrollXRTo } from '@common/utils/renderer'
import { lyric } from '@lyric/store/lyric'
import { isPlay, setting } from '@lyric/store/state'
import { invalidateShadow, setWindowBounds } from '@lyric/utils/ipc'
import { setWindowBounds } from '@lyric/utils/ipc'

const getOffsetTop = (contentWidth, lineWidth) => {
switch (setting['desktopLyric.scrollAlign']) {
Expand Down Expand Up @@ -45,13 +45,9 @@ export default (isComputeWidth) => {
offset = prevActiveLine < lyric.line ? ((dom_lines[prevActiveLine]?.clientWidth ?? 0) - prevLineWidth) : 0
// console.log(prevActiveLine, dom_lines[prevActiveLine]?.clientHeight ?? 0, prevLineWidth, offset)
}
cancelScrollFn = scrollXRTo(dom_lyric.value, dom_p ? (dom_p.offsetLeft + offset - getOffsetTop(dom_lyric.value.clientWidth, dom_p.clientWidth)) : 0, duration, () => {
invalidateShadow()
})
cancelScrollFn = scrollXRTo(dom_lyric.value, dom_p ? (dom_p.offsetLeft + offset - getOffsetTop(dom_lyric.value.clientWidth, dom_p.clientWidth)) : 0, duration)
} else {
cancelScrollFn = scrollXRTo(dom_lyric.value, 0, duration, () => {
invalidateShadow()
})
cancelScrollFn = scrollXRTo(dom_lyric.value, 0, duration)
}
}
const clearLyricScrollTimeout = () => {
Expand Down Expand Up @@ -162,7 +158,6 @@ export default (isComputeWidth) => {
setLyric(lines)
} else {
cancelScrollFn = scrollXRTo(dom_lyric.value, 0, 300, () => {
invalidateShadow()
if (lyric.lines !== lines) return
setLyric(lines)
}, 50)
Expand Down
5 changes: 0 additions & 5 deletions src/renderer-lyric/utils/ipc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { rendererSend, rendererInvoke, rendererOn, rendererOff } from '@common/rendererIpc'
import { CMMON_EVENT_NAME, WIN_LYRIC_RENDERER_EVENT_NAME } from '@common/ipcNames'
import { isMac } from '@common/utils'

type RemoveListener = () => void

Expand All @@ -19,10 +18,6 @@ export const onSettingChanged = (listener: LX.IpcRendererEventListenerParams<Par
export const setWindowBounds = (bounds: LX.DesktopLyric.NewBounds) => {
rendererSend<LX.DesktopLyric.NewBounds>(WIN_LYRIC_RENDERER_EVENT_NAME.set_win_bounds, bounds)
}
export const invalidateShadow = () => {
if (!isMac) return
rendererSend(WIN_LYRIC_RENDERER_EVENT_NAME.invalidate_shadow)
}

export const sendConnectMainWindowEvent = () => {
rendererSend(WIN_LYRIC_RENDERER_EVENT_NAME.request_main_window_channel)
Expand Down