bool x11_create_input_context(Display *dpy, Window win, XIM *xim, XIC *xic) { x11_destroy_input_context(xim, xic); g_x11_has_focus = true; *xim = XOpenIM(dpy, NULL, NULL, NULL); if (!*xim) { RARCH_ERR("[X11]: Failed to open input method.\n"); return false; } *xic = XCreateIC(*xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, win, NULL); if (!*xic) { RARCH_ERR("[X11]: Failed to create input context.\n"); return false; } XSetICFocus(*xic); return true; }
static void ctx_glx_destroy_resources(gfx_ctx_glx_data_t *glx) { driver_t *driver = driver_get_ptr(); if (!glx) return; x11_destroy_input_context(&glx->g_xim, &glx->g_xic); if (glx->g_dpy && glx->g_ctx) { glFinish(); glXMakeContextCurrent(glx->g_dpy, None, None, NULL); if (!driver->video_cache_context) { if (glx->g_hw_ctx) glXDestroyContext(glx->g_dpy, glx->g_hw_ctx); glXDestroyContext(glx->g_dpy, glx->g_ctx); glx->g_ctx = NULL; glx->g_hw_ctx = NULL; } } if (glx->g_win) { glXDestroyWindow(glx->g_dpy, glx->g_glx_win); glx->g_glx_win = 0; /* Save last used monitor for later. */ #ifdef HAVE_XINERAMA XWindowAttributes target; Window child; int x = 0, y = 0; XGetWindowAttributes(glx->g_dpy, glx->g_win, &target); XTranslateCoordinates(glx->g_dpy, glx->g_win, DefaultRootWindow(glx->g_dpy), target.x, target.y, &x, &y, &child); glx->g_screen = x11_get_xinerama_monitor(glx->g_dpy, x, y, target.width, target.height); RARCH_LOG("[GLX]: Saved monitor #%u.\n", glx->g_screen); #endif XUnmapWindow(glx->g_dpy, glx->g_win); XDestroyWindow(glx->g_dpy, glx->g_win); glx->g_win = None; } if (glx->g_cmap) { XFreeColormap(glx->g_dpy, glx->g_cmap); glx->g_cmap = None; } if (glx->g_should_reset_mode) { x11_exit_fullscreen(glx->g_dpy, &glx->g_desktop_mode); glx->g_should_reset_mode = false; } if (!driver->video_cache_context && glx->g_dpy) { XCloseDisplay(glx->g_dpy); glx->g_dpy = NULL; } g_pglSwapInterval = NULL; g_pglSwapIntervalSGI = NULL; g_pglSwapIntervalEXT = NULL; g_major = g_minor = 0; glx->g_core_es = false; }
static void gfx_ctx_xegl_destroy(void *data) { (void)data; x11_destroy_input_context(&g_xim, &g_xic); if (g_egl_dpy) { if (g_egl_ctx) { eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroyContext(g_egl_dpy, g_egl_ctx); } if (g_egl_hw_ctx) eglDestroyContext(g_egl_dpy, g_egl_hw_ctx); if (g_egl_surf) eglDestroySurface(g_egl_dpy, g_egl_surf); eglTerminate(g_egl_dpy); } g_egl_ctx = NULL; g_egl_hw_ctx = NULL; g_egl_surf = NULL; g_egl_dpy = NULL; g_egl_config = 0; if (g_win) { /* Save last used monitor for later. */ #ifdef HAVE_XINERAMA XWindowAttributes target; Window child; int x = 0, y = 0; XGetWindowAttributes(g_dpy, g_win, &target); XTranslateCoordinates(g_dpy, g_win, RootWindow(g_dpy, DefaultScreen(g_dpy)), target.x, target.y, &x, &y, &child); g_screen = x11_get_xinerama_monitor(g_dpy, x, y, target.width, target.height); RARCH_LOG("[X/EGL]: Saved monitor #%u.\n", g_screen); #endif XUnmapWindow(g_dpy, g_win); XDestroyWindow(g_dpy, g_win); g_win = None; } if (g_cmap) { XFreeColormap(g_dpy, g_cmap); g_cmap = None; } if (g_should_reset_mode) { x11_exit_fullscreen(g_dpy, &g_desktop_mode); g_should_reset_mode = false; } /* Do not close g_dpy. We'll keep one for the entire application * lifecycle to work-around nVidia EGL limitations. */ g_inited = false; }
void x11_input_ctx_destroy(void) { x11_destroy_input_context(&g_x11_xim, &g_x11_xic); }