@@ -23,6 +23,7 @@ import {
2323 hoverables ,
2424 panel ,
2525 preedit ,
26+ theme ,
2627} from './selector'
2728import {
2829 setAccentColor ,
@@ -117,6 +118,10 @@ const arrowBack = common.replace('{}', '0 0 24 24').replace('{}', 'M16.62 2.99a1
117118const arrowForward = common . replace ( '{}' , '0 0 24 24' ) . replace ( '{}' , 'M7.38 21.01c.49.49 1.28.49 1.77 0l8.31-8.31a.996.996 0 0 0 0-1.41L9.15 2.98c-.49-.49-1.28-.49-1.77 0s-.49 1.28 0 1.77L14.62 12l-7.25 7.25c-.48.48-.48 1.28.01 1.76z' )
118119
119120function setCandidates ( cands : Candidate [ ] , highlighted : number , markText : string , pageable : boolean , hasPrev : boolean , hasNext : boolean , scrollState : SCROLL_STATE , scrollStart : boolean , scrollEnd : boolean ) {
121+ if ( cands . length ) {
122+ // Auto layout requires display: not none so that getBoundingClientRect works.
123+ theme . classList . remove ( 'fcitx-hidden' )
124+ }
120125 const isVertical = hoverables . classList . contains ( 'fcitx-vertical' )
121126 resetMouseMoveState ( )
122127 hideContextmenu ( )
@@ -267,12 +272,21 @@ function updateElement(element: Element, innerHTML: string) {
267272}
268273
269274function updateInputPanel ( preeditHTML : string , auxUpHTML : string , auxDownHTML : string ) {
275+ if ( preeditHTML || auxUpHTML || auxDownHTML ) {
276+ theme . classList . remove ( 'fcitx-hidden' )
277+ }
270278 hideContextmenu ( )
271279 updateElement ( preedit , preeditHTML )
272280 updateElement ( auxUp , auxUpHTML )
273281 updateElement ( auxDown , auxDownHTML )
274282}
275283
284+ function hidePanel ( ) {
285+ updateInputPanel ( '' , '' , '' )
286+ setCandidates ( [ ] , - 1 , '' , false , false , false , SCROLL_NONE , false , false )
287+ theme . classList . add ( 'fcitx-hidden' )
288+ }
289+
276290function copyHTML ( ) {
277291 const html = document . documentElement . outerHTML
278292 fcitx . _copyHTML ( html )
@@ -298,6 +312,7 @@ hoverables.addEventListener('wheel', (e) => {
298312fcitx . setCandidates = setCandidates
299313fcitx . setLayout = setLayout
300314fcitx . updateInputPanel = updateInputPanel
315+ fcitx . hidePanel = hidePanel
301316fcitx . resize = resize
302317fcitx . setTheme = setTheme
303318fcitx . setAccentColor = setAccentColor
0 commit comments