From ff18fbb68a49959141969b63751684fa7538126b Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Fri, 16 Aug 2024 08:10:36 -0400 Subject: [PATCH] f5j: fix document pollution; place panel --- page/selector.ts | 2 +- page/ux.ts | 8 ++++---- src/platform/js.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/page/selector.ts b/page/selector.ts index 925db61..16efd60 100644 --- a/page/selector.ts +++ b/page/selector.ts @@ -1,5 +1,5 @@ export const theme = document.querySelector('#fcitx-theme')! -export const decoration = document.querySelector('.fcitx-decoration')! +export const decoration = document.querySelector('.fcitx-decoration')! as HTMLElement export const panel = document.querySelector('.fcitx-panel')! export const hoverables = panel.querySelector('.fcitx-hoverables')! export const preedit = document.querySelector('.fcitx-preedit')! diff --git a/page/ux.ts b/page/ux.ts index 066a8d1..ff47549 100644 --- a/page/ux.ts +++ b/page/ux.ts @@ -161,7 +161,7 @@ export function hideContextmenu () { contextmenu.style.display = 'none' } -document.addEventListener('mousedown', e => { +decoration.addEventListener('mousedown', e => { if (e.button !== 0) { return } @@ -173,7 +173,7 @@ document.addEventListener('mousedown', e => { dragOffset = 0 }) -document.addEventListener('mousemove', e => { +decoration.addEventListener('mousemove', e => { if (++mouseMoveState >= 2) { hoverables.classList.add('fcitx-mousemoved') } @@ -191,7 +191,7 @@ document.addEventListener('mousemove', e => { resize(dx, -dy, true, false) }) -document.addEventListener('mouseup', e => { +decoration.addEventListener('mouseup', e => { if (e.button !== 0) { return } @@ -235,7 +235,7 @@ export function answerActions (actions: CandidateAction[]) { showContextmenu(actionX, actionY, actionIndex, actions) } -document.addEventListener('contextmenu', e => { +decoration.addEventListener('contextmenu', e => { e.preventDefault() let target = e.target as Element if (!isInsideHoverables(target)) { diff --git a/src/platform/js.cpp b/src/platform/js.cpp index 4fa0e1d..6e66e94 100644 --- a/src/platform/js.cpp +++ b/src/platform/js.cpp @@ -26,6 +26,6 @@ void WebviewCandidateWindow::resize(double dx, double dy, double anchor_top, double anchor_right, double anchor_bottom, double anchor_left, double width, double height, bool dragging) { - std::cerr << "resize" << std::endl; + EM_ASM(fcitx.placePanel($0, $1, $2, $3), dx, dy, anchor_top, anchor_left); } } // namespace candidate_window