Browse Source

x: check we still have an XIC context before accessing it

master
Quentin Rameau 5 years ago
committed by Hiltjo Posthuma
parent
commit
cd785755f2
1 changed files with 5 additions and 2 deletions
  1. +5
    -2
      x.c

+ 5
- 2
x.c View File

@ -1061,6 +1061,7 @@ void
ximdestroy(XIM xim, XPointer client, XPointer call) ximdestroy(XIM xim, XPointer client, XPointer call)
{ {
xw.ime.xim = NULL; xw.ime.xim = NULL;
xw.ime.xic = NULL;
XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL, XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL,
ximinstantiate, NULL); ximinstantiate, NULL);
XFree(xw.ime.spotlist); XFree(xw.ime.spotlist);
@ -1692,13 +1693,15 @@ focus(XEvent *ev)
return; return;
if (ev->type == FocusIn) { if (ev->type == FocusIn) {
XSetICFocus(xw.ime.xic);
if (xw.ime.xic)
XSetICFocus(xw.ime.xic);
win.mode |= MODE_FOCUSED; win.mode |= MODE_FOCUSED;
xseturgency(0); xseturgency(0);
if (IS_SET(MODE_FOCUS)) if (IS_SET(MODE_FOCUS))
ttywrite("\033[I", 3, 0); ttywrite("\033[I", 3, 0);
} else { } else {
XUnsetICFocus(xw.ime.xic);
if (xw.ime.xic)
XUnsetICFocus(xw.ime.xic);
win.mode &= ~MODE_FOCUSED; win.mode &= ~MODE_FOCUSED;
if (IS_SET(MODE_FOCUS)) if (IS_SET(MODE_FOCUS))
ttywrite("\033[O", 3, 0); ttywrite("\033[O", 3, 0);


Loading…
Cancel
Save