Skip to content

Commit 4795983

Browse files
authored
Update ime.v
1 parent c34b1e7 commit 4795983

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

ime.v

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,37 @@ module gui
99
import sokol.sapp
1010
import vglyph
1111

12+
// IME holds per-window Input Method Editor state.
13+
// Created lazily because the native window is not ready during
14+
// init_fn.
15+
struct IME {
16+
mut:
17+
overlay voidptr = unsafe { nil }
18+
handler voidptr = unsafe { nil }
19+
initialized bool
20+
}
21+
22+
// ime_create_overlay creates the platform-specific IME overlay.
23+
// Returns nil on platforms without IME overlay support.
24+
fn ime_create_overlay() voidptr {
25+
$if macos {
26+
ns_window := sapp.macos_get_window()
27+
if ns_window == unsafe { nil } {
28+
return unsafe { nil }
29+
}
30+
return vglyph.ime_overlay_create_auto(ns_window)
31+
} $if windows {
32+
hwnd := sapp.win32_get_hwnd()
33+
if hwnd == unsafe { nil } {
34+
return unsafe { nil }
35+
}
36+
return hwnd
37+
} $else {
38+
// Linux: vglyph stubs return nil (no overlay yet).
39+
return unsafe { nil }
40+
}
41+
}
42+
1243
// init_ime lazily creates the IME overlay and registers
1344
// callbacks via VGlyph's StandardIMEHandler.
1445
fn (mut w Window) init_ime() {

0 commit comments

Comments
 (0)