Improvements to the IBus related code:
+ Handle HidePreeditText IBus signal. + Use SDL_GetKeyboardFocus instead of SDL_GetFocusWindow. + Move the X11 IBus SetFocus calls to the X11_DispatchFocus functions. + Simplify the IBus ifdefs when handling X11 KeyEvents. + Remove inotify watch when SDL_IBus_Quit is called.
This commit is contained in:
parent
64ba943a56
commit
1d87415440
3 changed files with 31 additions and 32 deletions
|
@ -347,6 +347,9 @@ X11_DispatchFocusIn(SDL_WindowData *data)
|
|||
X11_XSetICFocus(data->ic);
|
||||
}
|
||||
#endif
|
||||
#ifdef SDL_USE_IBUS
|
||||
SDL_IBus_SetFocus(SDL_TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -367,6 +370,9 @@ X11_DispatchFocusOut(SDL_WindowData *data)
|
|||
X11_XUnsetICFocus(data->ic);
|
||||
}
|
||||
#endif
|
||||
#ifdef SDL_USE_IBUS
|
||||
SDL_IBus_SetFocus(SDL_FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -646,11 +652,6 @@ X11_DispatchEvent(_THIS)
|
|||
}
|
||||
#ifdef DEBUG_XEVENTS
|
||||
printf("window %p: FocusIn!\n", data);
|
||||
#endif
|
||||
#ifdef SDL_USE_IBUS
|
||||
if(SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE){
|
||||
SDL_IBus_SetFocus(SDL_TRUE);
|
||||
}
|
||||
#endif
|
||||
if (data->pending_focus == PENDING_FOCUS_OUT &&
|
||||
data->window == SDL_GetKeyboardFocus()) {
|
||||
|
@ -688,11 +689,6 @@ X11_DispatchEvent(_THIS)
|
|||
}
|
||||
#ifdef DEBUG_XEVENTS
|
||||
printf("window %p: FocusOut!\n", data);
|
||||
#endif
|
||||
#ifdef SDL_USE_IBUS
|
||||
if(SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE){
|
||||
SDL_IBus_SetFocus(SDL_FALSE);
|
||||
}
|
||||
#endif
|
||||
data->pending_focus = PENDING_FOCUS_OUT;
|
||||
data->pending_focus_time = SDL_GetTicks() + PENDING_FOCUS_OUT_TIME;
|
||||
|
@ -725,16 +721,11 @@ X11_DispatchEvent(_THIS)
|
|||
KeySym keysym = NoSymbol;
|
||||
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
|
||||
Status status = 0;
|
||||
#ifdef SDL_USE_IBUS
|
||||
Bool handled = False;
|
||||
#endif
|
||||
SDL_bool handled_by_ime = SDL_FALSE;
|
||||
|
||||
#ifdef DEBUG_XEVENTS
|
||||
printf("window %p: KeyPress (X11 keycode = 0x%X)\n", data, xevent.xkey.keycode);
|
||||
#endif
|
||||
#ifndef SDL_USE_IBUS
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]);
|
||||
#endif
|
||||
#if 1
|
||||
if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN && keycode) {
|
||||
int min_keycode, max_keycode;
|
||||
|
@ -762,7 +753,7 @@ X11_DispatchEvent(_THIS)
|
|||
#endif
|
||||
#ifdef SDL_USE_IBUS
|
||||
if(SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE){
|
||||
if(!(handled = SDL_IBus_ProcessKeyEvent(keysym, keycode))){
|
||||
if(!(handled_by_ime = SDL_IBus_ProcessKeyEvent(keysym, keycode))){
|
||||
#endif
|
||||
if(*text){
|
||||
SDL_SendKeyboardText(text);
|
||||
|
@ -770,11 +761,11 @@ X11_DispatchEvent(_THIS)
|
|||
#ifdef SDL_USE_IBUS
|
||||
}
|
||||
}
|
||||
|
||||
if (!handled) {
|
||||
#endif
|
||||
if (!handled_by_ime) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue