Skip to content

Commit

Permalink
f5j: fix contextmenu 2x offset (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj authored Sep 17, 2024
1 parent 50ca9a2 commit f173318
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions page/ux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,18 +253,22 @@ receiver.addEventListener('contextmenu', (e) => {
if (!isInsideHoverables(target)) {
return
}

const x = e.clientX - (window.fcitx.distribution === 'fcitx5-js' ? theme.getBoundingClientRect().left : 0)
const y = e.clientY - (window.fcitx.distribution === 'fcitx5-js' ? theme.getBoundingClientRect().top : 0)

while (target.parentElement !== hoverables) {
target = target.parentElement!
}
const i = getCandidateIndex(target)
if (i >= 0 && getScrollState() === 2) {
actionX = e.clientX
actionY = e.clientY
actionX = x
actionY = y
actionIndex = i
return window.fcitx._askActions(i)
}
if (i >= 0 && actions[i].length > 0) {
showContextmenu(e.clientX, e.clientY, i, actions[i])
showContextmenu(x, y, i, actions[i])
}
else {
hideContextmenu()
Expand Down

0 comments on commit f173318

Please sign in to comment.