From 61476f5de49b20a6836186a82082bc2b7c70e971 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 3 Aug 2019 12:43:59 +0200 Subject: X11: Move input method to world --- pugl/detail/x11.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'pugl/detail/x11.c') diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c index aef2476..e0b3dea 100644 --- a/pugl/detail/x11.c +++ b/pugl/detail/x11.c @@ -82,6 +82,15 @@ puglInitWorldInternals(void) impl->atoms.NET_WM_STATE_DEMANDS_ATTENTION = XInternAtom(display, "_NET_WM_STATE_DEMANDS_ATTENTION", 0); + // Open input method + XSetLocaleModifiers(""); + if (!(impl->xim = XOpenIM(display, NULL, NULL, NULL))) { + XSetLocaleModifiers("@im="); + if (!(impl->xim = XOpenIM(display, NULL, NULL, NULL))) { + fprintf(stderr, "warning: XOpenIM failed\n"); + } + } + XFlush(display); return impl; @@ -167,16 +176,9 @@ puglCreateWindow(PuglView* view, const char* title) XSetTransientForHint(display, win, (Window)(view->transient_parent)); } - XSetLocaleModifiers(""); - if (!(impl->xim = XOpenIM(display, NULL, NULL, NULL))) { - XSetLocaleModifiers("@im="); - if (!(impl->xim = XOpenIM(display, NULL, NULL, NULL))) { - fprintf(stderr, "warning: XOpenIM failed\n"); - } - } - + // Create input context const XIMStyle im_style = XIMPreeditNothing | XIMStatusNothing; - if (!(impl->xic = XCreateIC(impl->xim, + if (!(impl->xic = XCreateIC(world->impl->xim, XNInputStyle, im_style, XNClientWindow, win, XNFocusWindow, win, @@ -208,9 +210,6 @@ puglFreeViewInternals(PuglView* view) if (view->impl->xic) { XDestroyIC(view->impl->xic); } - if (view->impl->xim) { - XCloseIM(view->impl->xim); - } view->backend->destroy(view); XDestroyWindow(view->impl->display, view->impl->win); XFree(view->impl->vi); @@ -221,6 +220,9 @@ puglFreeViewInternals(PuglView* view) void puglFreeWorldInternals(PuglWorld* world) { + if (world->impl->xim) { + XCloseIM(world->impl->xim); + } XCloseDisplay(world->impl->display); free(world->impl); } -- cgit v1.2.1