x11_common: fix behavior if XCreateIC() fails

This consists of 3 commits squashed and cherry-picked from master
(there were some minor conflicts):

vo/x11_common: Fail init with no valid XIM

XOpenIM can fail to find a valid input method, in which case it
returns NULL. Passing a NULL pointer to XCreateIC would cause a
crash, so fail VO init before that happens.

vo/x11_common: remove superfluous msg prefixes

Conflicts:
	video/out/x11_common.c

vo/x11_common: don't require a working input method

Normally, we need this for Xutf8LookupString(). But we can just fall
back to XLookupString(). In fact, the code for this was already there,
the code was just never tested and was actually crashing when active
(see commit 2115c4a).
This commit is contained in:
Martin Herkt 2013-09-19 20:08:34 +02:00 committed by wm4
parent 36fe16cc7e
commit 31a5fe6fa8
1 changed files with 11 additions and 5 deletions

View File

@ -455,6 +455,7 @@ int vo_x11_init(struct vo *vo)
if (!x11->display) {
mp_msg(MSGT_VO, MSGL_ERR,
"vo: couldn't open the X11 display (%s)!\n", dispName);
talloc_free(x11);
vo->x11 = NULL;
return 0;
@ -469,6 +470,9 @@ int vo_x11_init(struct vo *vo)
}
x11->xim = XOpenIM(x11->display, NULL, NULL, NULL);
if (!x11->xim)
mp_msg(MSGT_VO, MSGL_WARN,
"x11: XOpenIM() failed. Unicode input will not work.\n");
init_atoms(vo->x11);
@ -982,11 +986,13 @@ static void vo_x11_create_window(struct vo *vo, XVisualInfo *vis, int x, int y,
x11->mouse_cursor_hidden = false;
vo_set_cursor_hidden(vo, true);
}
x11->xic = XCreateIC(x11->xim,
XNInputStyle, XIMPreeditNone | XIMStatusNone,
XNClientWindow, x11->window,
XNFocusWindow, x11->window,
NULL);
if (x11->xim) {
x11->xic = XCreateIC(x11->xim,
XNInputStyle, XIMPreeditNone | XIMStatusNone,
XNClientWindow, x11->window,
XNFocusWindow, x11->window,
NULL);
}
vo_x11_update_window_title(vo);
}