@@ -362,6 +362,9 @@ ProcessKey(key, mask, this_hotkey) {
362
362
}
363
363
364
364
if context := rime.get_context(session_id) {
365
+ static prev_show := false
366
+ static prev_x := 4
367
+ static prev_y := 4
365
368
if context.composition.length > 0 {
366
369
DetectHiddenWindows True
367
370
local start_menu := WinActive (" ahk_class Windows.UI.Core.CoreWindow ahk_exe StartMenuExperienceHost.exe" )
@@ -380,37 +383,46 @@ ProcessKey(key, mask, this_hotkey) {
380
383
}
381
384
if ! show_at_left_top && GetCaretPos(& caret_x, & caret_y, & caret_w, & caret_h) {
382
385
box.Build(context, & box_width, & box_height)
383
- new_x := caret_x + caret_w
384
- new_y := caret_y + caret_h + 4
385
-
386
- hWnd := WinExist (" A" )
387
- hMon := MonitorManage.MonitorFromWindow(hWnd)
388
- info := MonitorManage.GetMonitorInfo(hMon)
389
- if info {
390
- if new_x + box_width > info.work.right
391
- new_x := info.work.right - box_width
392
- if new_y + box_height > info.work.bottom
393
- new_y := caret_y - 4 - box_height
386
+ if RabbitConfig.fix_candidate_box && prev_show {
387
+ new_x := prev_x
388
+ new_y := prev_y
394
389
} else {
395
- workspace_width := SysGet (16 ) ; SM_CXFULLSCREEN
396
- workspace_height := SysGet (17 ) ; SM_CYFULLSCREEN
397
- if new_x + box_width > workspace_width
398
- new_x := workspace_width - box_width
399
- if new_y + box_height > workspace_height
400
- new_y := caret_y - 4 - box_height
390
+ new_x := caret_x + caret_w
391
+ new_y := caret_y + caret_h + 4
392
+
393
+ hWnd := WinExist (" A" )
394
+ hMon := MonitorManage.MonitorFromWindow(hWnd)
395
+ info := MonitorManage.GetMonitorInfo(hMon)
396
+ if info {
397
+ if new_x + box_width > info.work.right
398
+ new_x := info.work.right - box_width
399
+ if new_y + box_height > info.work.bottom
400
+ new_y := caret_y - 4 - box_height
401
+ } else {
402
+ workspace_width := SysGet (16 ) ; SM_CXFULLSCREEN
403
+ workspace_height := SysGet (17 ) ; SM_CYFULLSCREEN
404
+ if new_x + box_width > workspace_width
405
+ new_x := workspace_width - box_width
406
+ if new_y + box_height > workspace_height
407
+ new_y := caret_y - 4 - box_height
408
+ }
401
409
}
402
410
if ! last_is_hide
403
411
box.Show(" AutoSize NA x" . new_x . " y" . new_y)
412
+ prev_x := new_x
413
+ prev_y := new_y
404
414
} else if ! show_at_left_top {
405
415
has_selected := GetCompositionText(context.composition, & pre_selected, & selected, & post_selected)
406
416
preedit_text := pre_selected
407
417
if has_selected
408
418
preedit_text := preedit_text . " [" . selected " ]" . post_selected
409
419
ToolTip (preedit_text . " `r`n" . GetMenuText(context.menu ))
410
420
}
421
+ prev_show := true
411
422
} else {
412
423
ToolTip ()
413
424
box.Show(" Hide" )
425
+ prev_show := false
414
426
}
415
427
rime.free_context(context)
416
428
}
0 commit comments