diff options
author | David Robillard <d@drobilla.net> | 2019-08-03 12:43:59 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-09-03 08:32:16 +0200 |
commit | 61476f5de49b20a6836186a82082bc2b7c70e971 (patch) | |
tree | 66cee2ae9f3a27bc027fae0dd7b95aed9edc4026 | |
parent | 9995566f3980ad6092428963b63558fb599bac8d (diff) | |
download | pugl-61476f5de49b20a6836186a82082bc2b7c70e971.tar.gz pugl-61476f5de49b20a6836186a82082bc2b7c70e971.tar.bz2 pugl-61476f5de49b20a6836186a82082bc2b7c70e971.zip |
X11: Move input method to world
-rw-r--r-- | pugl/detail/x11.c | 26 | ||||
-rw-r--r-- | pugl/detail/x11.h | 2 |
2 files changed, 15 insertions, 13 deletions
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); } diff --git a/pugl/detail/x11.h b/pugl/detail/x11.h index 54881af..34694fe 100644 --- a/pugl/detail/x11.h +++ b/pugl/detail/x11.h @@ -35,6 +35,7 @@ typedef struct { struct PuglWorldInternalsImpl { Display* display; PuglX11Atoms atoms; + XIM xim; }; struct PuglInternalsImpl { @@ -42,7 +43,6 @@ struct PuglInternalsImpl { int screen; XVisualInfo* vi; Window win; - XIM xim; XIC xic; PuglSurface* surface; }; |