Renamed SDL_HINT_IME_NATIVE_UI to SDL_HINT_IME_IMPLEMENTED_UI

This inverts the logic to make more sense from an application perspective.
This commit is contained in:
Sam Lantinga
2024-06-28 19:22:16 -07:00
parent e47179c4c7
commit 212a491f7c
7 changed files with 52 additions and 77 deletions

View File

@@ -237,16 +237,12 @@ static void SDLCALL Fcitx_SetCapabilities(void *data,
return;
}
if (!hint || !*hint || *hint == '1' || SDL_strstr(hint, "all")) {
// Let the OS handle IME UI
} else {
if (!SDL_strstr(hint, "composition")) {
caps |= (1 << 1); /* Preedit Flag */
caps |= (1 << 4); /* Formatted Preedit Flag */
}
if (!SDL_strstr(hint, "candidates")) {
// FIXME, turn off native candidate rendering
}
if (hint && SDL_strstr(hint, "composition")) {
caps |= (1 << 1); /* Preedit Flag */
caps |= (1 << 4); /* Formatted Preedit Flag */
}
if (hint && SDL_strstr(hint, "candidates")) {
// FIXME, turn off native candidate rendering
}
SDL_DBus_CallVoidMethod(FCITX_DBUS_SERVICE, client->ic_path, FCITX_IC_DBUS_INTERFACE, "SetCapability", DBUS_TYPE_UINT64, &caps, DBUS_TYPE_INVALID);
@@ -307,7 +303,7 @@ static SDL_bool FcitxClientCreateIC(FcitxClient *client)
NULL);
dbus->connection_flush(dbus->session_conn);
SDL_AddHintCallback(SDL_HINT_IME_NATIVE_UI, Fcitx_SetCapabilities, client);
SDL_AddHintCallback(SDL_HINT_IME_IMPLEMENTED_UI, Fcitx_SetCapabilities, client);
return SDL_TRUE;
}

View File

@@ -411,15 +411,11 @@ static void SDLCALL IBus_SetCapabilities(void *data, const char *name, const cha
if (IBus_CheckConnection(dbus)) {
Uint32 caps = IBUS_CAP_FOCUS;
if (!hint || !*hint || *hint == '1' || SDL_strstr(hint, "all")) {
// Let the OS handle IME UI
} else {
if (!SDL_strstr(hint, "composition")) {
caps |= IBUS_CAP_PREEDIT_TEXT;
}
if (!SDL_strstr(hint, "candidates")) {
// FIXME, turn off native candidate rendering
}
if (hint && SDL_strstr(hint, "composition")) {
caps |= IBUS_CAP_PREEDIT_TEXT;
}
if (hint && SDL_strstr(hint, "candidates")) {
// FIXME, turn off native candidate rendering
}
SDL_DBus_CallVoidMethodOnConnection(ibus_conn, ibus_service, input_ctx_path, ibus_input_interface, "SetCapabilities",
@@ -482,7 +478,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
(void)SDL_snprintf(matchstr, sizeof(matchstr), "type='signal',interface='%s'", ibus_input_interface);
SDL_free(input_ctx_path);
input_ctx_path = SDL_strdup(path);
SDL_AddHintCallback(SDL_HINT_IME_NATIVE_UI, IBus_SetCapabilities, NULL);
SDL_AddHintCallback(SDL_HINT_IME_IMPLEMENTED_UI, IBus_SetCapabilities, NULL);
dbus->bus_add_match(ibus_conn, matchstr, NULL);
dbus->connection_try_register_object_path(ibus_conn, input_ctx_path, &ibus_vtable, dbus, NULL);
dbus->connection_flush(ibus_conn);
@@ -639,7 +635,7 @@ void SDL_IBus_Quit(void)
/* !!! FIXME: should we close(inotify_fd) here? */
SDL_DelHintCallback(SDL_HINT_IME_NATIVE_UI, IBus_SetCapabilities, NULL);
SDL_DelHintCallback(SDL_HINT_IME_IMPLEMENTED_UI, IBus_SetCapabilities, NULL);
SDL_memset(&ibus_cursor_rect, 0, sizeof(ibus_cursor_rect));
}

View File

@@ -314,17 +314,12 @@ static int IME_Init(SDL_VideoData *videodata, SDL_Window *window)
return 0;
}
const char *hint = SDL_GetHint(SDL_HINT_IME_NATIVE_UI);
if (!hint || !*hint || *hint == '1' || SDL_strstr(hint, "all")) {
videodata->ime_native_composition = SDL_TRUE;
videodata->ime_native_candidates = SDL_TRUE;
} else {
if (SDL_strstr(hint, "composition")) {
videodata->ime_native_composition = SDL_TRUE;
}
if (SDL_strstr(hint, "candidates")) {
videodata->ime_native_candidates = SDL_TRUE;
}
const char *hint = SDL_GetHint(SDL_HINT_IME_IMPLEMENTED_UI);
if (hint && SDL_strstr(hint, "composition")) {
videodata->ime_internal_composition = SDL_TRUE;
}
if (hint && SDL_strstr(hint, "candidates")) {
videodata->ime_internal_candidates = SDL_TRUE;
}
videodata->ime_hwnd_main = hwnd;
@@ -545,7 +540,7 @@ static DWORD IME_GetId(SDL_VideoData *videodata, UINT uIndex)
SDL_assert(uIndex == 0);
dwLang = ((DWORD_PTR)hkl & 0xffff);
// FIXME: What does this do?
if (!videodata->ime_native_candidates && dwLang == LANG_CHT) {
if (videodata->ime_internal_candidates && dwLang == LANG_CHT) {
dwRet[0] = IMEID_CHT_VER_VISTA;
dwRet[1] = 0;
return dwRet[0];
@@ -988,14 +983,14 @@ SDL_bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam
SDL_DebugIMELog("WM_IME_SETCONTEXT\n");
LPARAM element_mask;
if (!videodata->ime_native_composition && !videodata->ime_native_candidates) {
if (videodata->ime_internal_composition && videodata->ime_internal_candidates) {
element_mask = 0;
} else {
element_mask = ISC_SHOWUIALL;
if (!videodata->ime_native_composition) {
if (videodata->ime_internal_composition) {
element_mask &= ~ISC_SHOWUICOMPOSITIONWINDOW;
}
if (!videodata->ime_native_candidates) {
if (videodata->ime_internal_candidates) {
element_mask &= ~ISC_SHOWUIALLCANDIDATEWINDOW;
}
}
@@ -1023,13 +1018,13 @@ SDL_bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam
break;
case WM_IME_STARTCOMPOSITION:
SDL_DebugIMELog("WM_IME_STARTCOMPOSITION\n");
if (!videodata->ime_native_composition) {
if (videodata->ime_internal_composition) {
trap = SDL_TRUE;
}
break;
case WM_IME_COMPOSITION:
SDL_DebugIMELog("WM_IME_COMPOSITION %x\n", lParam);
if (!videodata->ime_native_composition) {
if (videodata->ime_internal_composition) {
trap = SDL_TRUE;
himc = ImmGetContext(hwnd);
if (*lParam & GCS_RESULTSTR) {
@@ -1049,7 +1044,7 @@ SDL_bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam
break;
case WM_IME_ENDCOMPOSITION:
SDL_DebugIMELog("WM_IME_ENDCOMPOSITION\n");
if (!videodata->ime_native_composition) {
if (videodata->ime_internal_composition) {
trap = SDL_TRUE;
videodata->ime_composition[0] = 0;
videodata->ime_readingstring[0] = 0;
@@ -1079,14 +1074,14 @@ SDL_bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam
case IMN_OPENCANDIDATE:
case IMN_CHANGECANDIDATE:
SDL_DebugIMELog("%s\n", wParam == IMN_OPENCANDIDATE ? "IMN_OPENCANDIDATE" : "IMN_CHANGECANDIDATE");
if (!videodata->ime_native_candidates) {
if (videodata->ime_internal_candidates) {
trap = SDL_TRUE;
videodata->ime_update_candidates = SDL_TRUE;
}
break;
case IMN_CLOSECANDIDATE:
SDL_DebugIMELog("IMN_CLOSECANDIDATE\n");
if (!videodata->ime_native_candidates) {
if (videodata->ime_internal_candidates) {
trap = SDL_TRUE;
videodata->ime_update_candidates = SDL_FALSE;
IME_CloseCandidateList(videodata);

View File

@@ -423,6 +423,8 @@ struct SDL_VideoData
SDL_bool ime_initialized;
SDL_bool ime_enabled;
SDL_bool ime_available;
SDL_bool ime_internal_composition;
SDL_bool ime_internal_candidates;
HWND ime_hwnd_main;
HWND ime_hwnd_current;
SDL_bool ime_needs_clear_composition;
@@ -460,8 +462,6 @@ struct SDL_VideoData
BOOL (WINAPI *ImmUnlockIMCC)(HIMCC himcc);
/* *INDENT-ON* */ /* clang-format on */
SDL_bool ime_native_composition;
SDL_bool ime_native_candidates;
#endif /* !SDL_DISABLE_WINDOWS_IME */
BYTE pre_hook_key_state[256];