Skip to content

Commit 8000f12

Browse files
committed
* sdl2/ui_display.[ch]: Add ui_display_set_use_text_input() and
ui_display_set_text_input_spot(). * sdl2/ui_xic.c: Link to wayland/ui_xic.c instead of fb/ui_xic.c. * wayland/ui_xic.c: Add support for sdl2. * ui_xic.h: ui_xic_t supports sdl2.
1 parent 933e61d commit 8000f12

6 files changed

Lines changed: 47 additions & 4 deletions

File tree

ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2026-06-27 Araki Ken <arakiken@user.sf.net>
2+
3+
* sdl2/ui_display.[ch]: Add ui_display_set_use_text_input() and
4+
ui_display_set_text_input_spot().
5+
6+
* sdl2/ui_xic.c: Link to wayland/ui_xic.c instead of fb/ui_xic.c.
7+
8+
* wayland/ui_xic.c: Add support for sdl2.
9+
10+
* ui_xic.h: ui_xic_t supports sdl2.
11+
112
2026-06-21 Araki Ken <arakiken@user.sf.net>
213

314
* ui_font_ft.c: cairo_font_open_intern() enables italic fonts forcibly.

uitoolkit/sdl2/ui_display.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,8 +1169,6 @@ static ui_display_t *open_display(char *disp_name, u_int depth) {
11691169
is_framebuffer = 1;
11701170
}
11711171

1172-
SDL_StartTextInput();
1173-
11741172
pty_event_type = SDL_RegisterEvents(1);
11751173

11761174
main_tid = SDL_GetThreadID(NULL);
@@ -1698,6 +1696,28 @@ void ui_display_set_title(ui_display_t *disp, const u_char *name) {
16981696
SDL_SetWindowTitle(disp->display->window, name);
16991697
}
17001698

1699+
void ui_display_set_use_text_input(ui_display_t *disp, int use) {
1700+
if (use) {
1701+
#if 0
1702+
SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");
1703+
SDL_SetHint(SDL_HINT_IME_INTERNAL_EDITING, "0");
1704+
#endif
1705+
SDL_StartTextInput();
1706+
} else {
1707+
SDL_StopTextInput();
1708+
}
1709+
}
1710+
1711+
void ui_display_set_text_input_spot(ui_display_t *disp, int x, int y) {
1712+
SDL_Rect rect;
1713+
1714+
rect.x = x;
1715+
rect.y = y;
1716+
rect.w = 1;
1717+
rect.h = 1;
1718+
SDL_SetTextInputRect(&rect);
1719+
}
1720+
17011721
void ui_display_trigger_pty_read(void) {
17021722
SDL_Event ev;
17031723

uitoolkit/sdl2/ui_display.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ void ui_display_set_title(ui_display_t *disp, const u_char *name);
4949

5050
void ui_display_set_maximized(ui_display_t *disp, int flag);
5151

52+
void ui_display_set_use_text_input(ui_display_t *disp, int use);
53+
54+
void ui_display_set_text_input_spot(ui_display_t *disp, int x, int y);
55+
5256
#ifdef USE_BG_TEXTURE
5357
void ui_display_set_bg_color(ui_display_t *disp, u_long bg);
5458

uitoolkit/sdl2/ui_xic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../fb/ui_xic.c
1+
../wayland/ui_xic.c

uitoolkit/ui_xic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ typedef struct ui_xic {
1818
#if defined(USE_WIN32GUI)
1919
WORD prev_keydown_wparam;
2020
ef_parser_t *parser;
21-
#elif defined(USE_QUARTZ) || defined(USE_BEOS) || defined(USE_WAYLAND)
21+
#elif defined(USE_QUARTZ) || defined(USE_BEOS) || defined(USE_WAYLAND) || defined(USE_SDL2)
2222
ef_parser_t *parser;
2323
#elif defined(USE_XLIB)
2424
XFontSet fontset;

uitoolkit/wayland/ui_xic.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,21 @@ int ui_xic_set_spot(ui_window_t *win) {
7777
return 0;
7878
}
7979

80+
#ifdef USE_WAYLAND
8081
ui_display_set_text_input_spot(win->disp, x, y,
8182
win->xim_listener->get_line_height
8283
? (*win->xim_listener->get_line_height)(win->xim_listener->self)
8384
: 20);
85+
#else /* USE_SDL2 */
86+
ui_display_set_text_input_spot(win->disp, x, y);
87+
#endif
8488

8589
return 1;
8690
}
8791

8892
size_t ui_xic_get_str(ui_window_t *win, u_char *seq, size_t seq_len, ef_parser_t **parser,
8993
KeySym *keysym, XKeyEvent *event) {
94+
#ifdef USE_WAYLAND
9095
if (win->xic == NULL || event->utf8 == NULL) {
9196
*parser = NULL;
9297

@@ -101,6 +106,9 @@ size_t ui_xic_get_str(ui_window_t *win, u_char *seq, size_t seq_len, ef_parser_t
101106

102107
return len;
103108
}
109+
#else /* USE_SDL2 */
110+
return 0;
111+
#endif
104112
}
105113

106114
size_t ui_xic_get_utf8_str(ui_window_t *win, u_char *seq, size_t seq_len, ef_parser_t **parser,

0 commit comments

Comments
 (0)