fix(desktop): prevent Korean character swallowing in terminal and xterm.js surfaces (INPUT-04, INPUT-19)
This commit is contained in:
parent
f18cebaa24
commit
61123b5ad8
11 changed files with 264 additions and 50 deletions
|
|
@ -251,7 +251,41 @@ def _caret_rect_and_offset(auto: Any, control: Any) -> tuple[Optional[dict], Opt
|
|||
|
||||
|
||||
_woken_hwnds: dict[int, float] = {}
|
||||
_WAKE_TTL_SECONDS = 60.0
|
||||
_WAKE_TTL_SECONDS = 86400.0
|
||||
|
||||
|
||||
def _foreground_window_meta() -> tuple[Optional[str], Optional[dict]]:
|
||||
"""Win32 API 로 포그라운드 창 제목과 사각형을 즉시 읽는다 (UIA 부모 트리 순회 COM 호출 제거)."""
|
||||
try:
|
||||
import ctypes # noqa: PLC0415
|
||||
from ctypes import wintypes # noqa: PLC0415
|
||||
|
||||
user32 = ctypes.windll.user32
|
||||
hwnd = int(user32.GetForegroundWindow() or 0)
|
||||
if not hwnd:
|
||||
return (None, None)
|
||||
|
||||
title: Optional[str] = None
|
||||
buf = ctypes.create_unicode_buffer(302)
|
||||
length = int(user32.GetWindowTextW(wintypes.HWND(hwnd), buf, 300) or 0)
|
||||
if length > 0:
|
||||
title = buf.value[:300]
|
||||
|
||||
rect = wintypes.RECT()
|
||||
rect_dict: Optional[dict] = None
|
||||
if user32.GetWindowRect(wintypes.HWND(hwnd), ctypes.byref(rect)):
|
||||
width = int(rect.right) - int(rect.left)
|
||||
height = int(rect.bottom) - int(rect.top)
|
||||
if width >= 0 and height >= 0:
|
||||
rect_dict = {
|
||||
"x": int(rect.left),
|
||||
"y": int(rect.top),
|
||||
"width": width,
|
||||
"height": height,
|
||||
}
|
||||
return (title, rect_dict)
|
||||
except Exception:
|
||||
return (None, None)
|
||||
|
||||
|
||||
def _wake_chromium_accessibility(force: bool = False) -> bool:
|
||||
|
|
@ -366,13 +400,29 @@ def _snapshot() -> dict:
|
|||
except Exception:
|
||||
result["processId"] = None
|
||||
|
||||
try:
|
||||
top = control.GetTopLevelControl()
|
||||
if top is not None:
|
||||
result["windowTitle"] = str(top.Name or "")[:300]
|
||||
result["elementRect"] = _rect_to_dict(top.BoundingRectangle) or result["elementRect"]
|
||||
except Exception:
|
||||
pass
|
||||
fg_title, fg_rect = _foreground_window_meta()
|
||||
if fg_title:
|
||||
result["windowTitle"] = fg_title
|
||||
if fg_rect is not None:
|
||||
result["elementRect"] = fg_rect
|
||||
|
||||
class_name_lower = str(result["className"] or "").lower()
|
||||
control_name_lower = str(result["controlName"] or "").strip().lower()
|
||||
is_xterm_helper = (
|
||||
"xterm-helper-textarea" in class_name_lower
|
||||
or control_name_lower in ("terminal input", "터미널 입력")
|
||||
)
|
||||
|
||||
if not is_xterm_helper and (result["windowTitle"] is None or result["elementRect"] is None):
|
||||
try:
|
||||
top = control.GetTopLevelControl()
|
||||
if top is not None:
|
||||
if result["windowTitle"] is None:
|
||||
result["windowTitle"] = str(top.Name or "")[:300]
|
||||
if result["elementRect"] is None:
|
||||
result["elementRect"] = _rect_to_dict(top.BoundingRectangle) or result["elementRect"]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
result["elementRect"] = _rect_to_dict(control.BoundingRectangle) or result["elementRect"]
|
||||
|
|
@ -383,6 +433,19 @@ def _snapshot() -> dict:
|
|||
result["textSource"] = source
|
||||
result["text"] = text
|
||||
|
||||
if is_xterm_helper:
|
||||
# xterm.js 의 숨김 IME 입력창(xterm-helper-textarea)에서 TextPattern 선택·문자 확장·TextEditPattern
|
||||
# 조합 조회를 호출하면 Chromium 렌더러 스레드가 블로킹(최대 1500ms 타임아웃)되고 한글 조합 중인
|
||||
# 글자가 삼켜진다. ValuePattern 값과 편집 가능 여부만 즉시 반환한다.
|
||||
result["isEditable"] = True
|
||||
result["caretRect"] = None
|
||||
result["caretOffset"] = None
|
||||
result["isComposing"] = False
|
||||
result["hasSelection"] = False
|
||||
result["capturedAt"] = int(time.time() * 1000)
|
||||
result["elapsedMs"] = int((time.monotonic() - started) * 1000)
|
||||
return result
|
||||
|
||||
is_readonly = False
|
||||
try:
|
||||
if value_pattern is not None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue