static void x11_connect (void) { char *c; int nitems; if (x11_connected) return; XInitThreads (); GUI_display = XOpenDisplay (0); if (!GUI_display) errx (EXIT_FAILURE, "Failed to open GUI_display"); XSynchronize (GUI_display, True); GUI_screenidx = DefaultScreen (GUI_display); GUI_screen = DefaultScreenOfDisplay (GUI_display); GUI_visual = DefaultVisual (GUI_display, GUI_screenidx); GUI_visual_info = XGetVisualInfo (GUI_display, VisualNoMask, &GUI_visual_template, &nitems); xa_wm_delete_window = XInternAtom (GUI_display, "WM_DELETE_WINDOW", False); xa_clipboard = XInternAtom (GUI_display, "CLIPBOARD", False); xa_utf8_string = XInternAtom (GUI_display, "UTF8_STRING", False); xa_prop_paste = XInternAtom (GUI_display, "BRA_PASTE", False); xim = 0; if ((c = XSetLocaleModifiers ("")) && *c) xim = XOpenIM (GUI_display, 0, 0, 0); if (!xim && (c = XSetLocaleModifiers ("@im=none")) && *c) xim = XOpenIM (GUI_display, 0, 0, 0); if (!xim) errx (EXIT_FAILURE, "Failed to open X Input Method"); xrenderpictformat = XRenderFindVisualFormat (GUI_display, GUI_visual); if (!xrenderpictformat) errx (EXIT_FAILURE, "XRenderFindVisualFormat failed"); argb32pictformat = XRenderFindStandardFormat (GUI_display, PictStandardARGB32); a8pictformat = XRenderFindStandardFormat (GUI_display, PictStandardA8); if (!a8pictformat) errx (EXIT_FAILURE, "XrenderFindStandardFormat failed for PictStandardA8"); XSynchronize (GUI_display, False); x11_connected = 1; }
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; }
// Xft text box, optionally editable textbox* textbox_create(Window parent, unsigned long flags, short x, short y, short w, short h, char *font, char *fg, char *bg, char *text, char *prompt) { textbox *tb = calloc(1, sizeof(textbox)); tb->flags = flags; tb->parent = parent; tb->x = x; tb->y = y; tb->w = MAX(1, w); tb->h = MAX(1, h); XColor color; Colormap map = DefaultColormap(display, DefaultScreen(display)); unsigned int cp = XAllocNamedColor(display, map, bg, &color, &color) ? color.pixel: None; tb->window = XCreateSimpleWindow(display, tb->parent, tb->x, tb->y, tb->w, tb->h, 0, None, cp); // need to preload the font to calc line height textbox_font(tb, font, fg, bg); tb->prompt = strdup(prompt ? prompt: ""); textbox_text(tb, text ? text: ""); // auto height/width modes get handled here textbox_moveresize(tb, tb->x, tb->y, tb->w, tb->h); // edit mode controls if (tb->flags & TB_EDITABLE) { tb->xim = XOpenIM(display, NULL, NULL, NULL); tb->xic = XCreateIC(tb->xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, tb->window, XNFocusWindow, tb->window, NULL); } return tb; }
static void InitI18N(Widget ctxw) { LoginWidget ctx = (LoginWidget)ctxw; XIM xim = (XIM) NULL; char *p; ctx->login.xic = (XIC) NULL; if ((p = XSetLocaleModifiers("@im=none")) != NULL && *p) xim = XOpenIM(XtDisplay(ctx), NULL, NULL, NULL); if (!xim) { LogError("Failed to open input method\n"); return; } ctx->login.xic = XCreateIC(xim, XNInputStyle, (XIMPreeditNothing|XIMStatusNothing), XNClientWindow, ctx->core.window, XNFocusWindow, ctx->core.window, NULL); if (!ctx->login.xic) { LogError("Failed to create input context\n"); XCloseIM(xim); } return; }
//////////////////////////////////////////////////////////// /// Open the display (if not already done) //////////////////////////////////////////////////////////// bool WindowImplX11::OpenDisplay(bool AddWindow) { // If no display has been opened yet, open it if (ourDisplay == NULL) { ourDisplay = XOpenDisplay(NULL); if (ourDisplay) { ourScreen = DefaultScreen(ourDisplay); // Get the input method (XIM) object ourInputMethod = XOpenIM(ourDisplay, NULL, NULL, NULL); } else { std::cerr << "Failed to open a connection with the X server" << std::endl; } } // Increase the number of windows if (AddWindow) ourWindowsCount++; return ourDisplay != NULL; }
bool StXDisplay::open() { hDisplay = XOpenDisplay(NULL); // get first display on server from DISPLAY in env //hDisplay = XOpenDisplay(":0.0"); //hDisplay = XOpenDisplay("somehost:0.0"); //hDisplay = XOpenDisplay("192.168.1.10:0.0"); if(isOpened()) { initAtoms(); hInputMethod = XOpenIM(hDisplay, NULL, NULL, NULL); if(hInputMethod == NULL) { return true; } XIMStyles* anIMStyles = NULL; char* anIMValues = XGetIMValues(hInputMethod, XNQueryInputStyle, &anIMStyles, NULL); if(anIMValues != NULL || anIMStyles == NULL || anIMStyles->count_styles <= 0) { // input method doesn't support any styles if(anIMStyles != NULL) { XFree(anIMStyles); } return true; } const XIMStyle anIMStyle = anIMStyles->supported_styles[0]; XFree(anIMStyles); hInputCtx = XCreateIC(hInputMethod, XNInputStyle, anIMStyle, NULL); return true; } return false; }
/* initialize info->im */ static void xim_info_try_im (GtkOXIMInfo *info) { GdkScreen *screen = info->screen; GdkDisplay *display = gdk_screen_get_display (screen); g_assert (info->im == NULL); if (info->reconnecting) return; if (XSupportsLocale ()) { if (!XSetLocaleModifiers ("@im=oxim")) g_warning ("Unable to set locale modifiers with XSetLocaleModifiers()"); info->im = XOpenIM (GDK_DISPLAY_XDISPLAY (display), NULL, NULL, NULL); if (!info->im) { XRegisterIMInstantiateCallback (GDK_DISPLAY_XDISPLAY(display), NULL, NULL, NULL, xim_instantiate_callback, (XPointer)info); info->reconnecting = TRUE; return; } setup_im (info); } }
// Xft text box, optionally editable textbox* textbox_create(Window parent, bitmap flags, short x, short y, short w, short h, char *font, char *fg, char *bg, char *text, char *prompt) { textbox *tb = allocate_clear(sizeof(textbox)); tb->flags = flags; tb->parent = parent; tb->x = x; tb->y = y; tb->w = MAX(1, w); tb->h = MAX(1, h); tb->window = XCreateSimpleWindow(display, tb->parent, tb->x, tb->y, tb->w, tb->h, 0, None, color_get(bg)); // need to preload the font to calc line height textbox_font(tb, font, fg, bg); tb->prompt = strdup(prompt ? prompt: ""); textbox_text(tb, text ? text: ""); // auto height/width modes get handled here textbox_moveresize(tb, tb->x, tb->y, tb->w, tb->h); // edit mode controls if (tb->flags & TB_EDITABLE) { tb->xim = XOpenIM(display, NULL, NULL, NULL); tb->xic = XCreateIC(tb->xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, tb->window, XNFocusWindow, tb->window, NULL); } return tb; }
bool X11Window::internalSetupWindowInput() { // try to set a latin1 locales, otherwise fallback to standard C locale static char locales[4][32] = { "en_US.iso88591", "iso88591", "en_US", "C" }; for(int i=0;i<4;++i) { if(setlocale(LC_ALL, locales[i])) break; } // create input context (to have better key input handling) if(!XSupportsLocale()) { g_logger.error("X11 doesn't support the current locale"); return false; } XSetLocaleModifiers(""); m_xim = XOpenIM(m_display, NULL, NULL, NULL); if(!m_xim) { g_logger.error("XOpenIM failed"); return false; } m_xic = XCreateIC(m_xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, m_window, NULL); if(!m_xic) { g_logger.error("Unable to create the input context"); return false; } return true; }
void CXWindowsPrimaryScreen::onPostOpen() { assert(m_window != None); // get cursor info m_screen->getCursorPos(m_x, m_y); m_screen->getCursorCenter(m_xCenter, m_yCenter); // get the input method CDisplayLock display(m_screen); m_im = XOpenIM(display, NULL, NULL, NULL); if (m_im == NULL) { return; } // find the appropriate style. synergy supports XIMPreeditNothing // only at the moment. XIMStyles* styles; if (XGetIMValues(m_im, XNQueryInputStyle, &styles, NULL) != NULL || styles == NULL) { LOG((CLOG_WARN "cannot get IM styles")); return; } XIMStyle style = 0; for (unsigned short i = 0; i < styles->count_styles; ++i) { style = styles->supported_styles[i]; if ((style & XIMPreeditNothing) != 0) { if ((style & (XIMStatusNothing | XIMStatusNone)) != 0) { break; } } } XFree(styles); if (style == 0) { LOG((CLOG_WARN "no supported IM styles")); return; } // create an input context for the style and tell it about our window m_ic = XCreateIC(m_im, XNInputStyle, style, XNClientWindow, m_window, NULL); if (m_ic == NULL) { LOG((CLOG_WARN "cannot create IC")); return; } // find out the events we must select for and do so unsigned long mask; if (XGetICValues(m_ic, XNFilterEvents, &mask, NULL) != NULL) { LOG((CLOG_WARN "cannot get IC filter events")); return; } XWindowAttributes attr; XGetWindowAttributes(display, m_window, &attr); XSelectInput(display, m_window, attr.your_event_mask | mask); // no previous keycode m_lastKeycode = 0; }
int X11_VideoInit(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; /* Get the window class name, usually the name of the application */ data->classname = get_classname(); /* Get the process PID to be associated to the window */ data->pid = getpid(); /* Open a connection to the X input manager */ #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { data->im = XOpenIM(data->display, NULL, data->classname, data->classname); } #endif /* Look up some useful Atoms */ #define GET_ATOM(X) data->X = XInternAtom(data->display, #X, False) GET_ATOM(WM_PROTOCOLS); GET_ATOM(WM_DELETE_WINDOW); GET_ATOM(_NET_WM_STATE); GET_ATOM(_NET_WM_STATE_HIDDEN); GET_ATOM(_NET_WM_STATE_FOCUSED); GET_ATOM(_NET_WM_STATE_MAXIMIZED_VERT); GET_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ); GET_ATOM(_NET_WM_STATE_FULLSCREEN); GET_ATOM(_NET_WM_ALLOWED_ACTIONS); GET_ATOM(_NET_WM_ACTION_FULLSCREEN); GET_ATOM(_NET_WM_NAME); GET_ATOM(_NET_WM_ICON_NAME); GET_ATOM(_NET_WM_ICON); GET_ATOM(_NET_WM_PING); GET_ATOM(UTF8_STRING); /* Detect the window manager */ X11_CheckWindowManager(_this); if (X11_InitModes(_this) < 0) { return -1; } X11_InitXinput2(_this); if (X11_InitKeyboard(_this) != 0) { return -1; } X11_InitMouse(_this); X11_InitTouch(_this); #if SDL_USE_LIBDBUS X11_InitDBus(_this); #endif return 0; }
void x_init_input() { X.xim = XOpenIM(X.dpy, NULL, NULL, NULL); X.xic = XCreateIC(X.xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, X.window, XNFocusWindow, X.window, NULL); }
__attribute__((constructor)) static void init() { dpy = XOpenDisplay(0); screen = DefaultScreen(dpy); root = RootWindow(dpy, screen); im = XOpenIM(dpy, 0, 0, 0); ic = XCreateIC(im, XNInputStyle, XIMPreeditNothing|XIMStatusNothing, 0); XSync(dpy, 0); }
static Bool scalefilterInitDisplay (CompPlugin *p, CompDisplay *d) { ScaleFilterDisplay *fd; CompPlugin *scale = findActivePlugin ("scale"); CompOption *option; int nOption; if (!scale || !scale->vTable->getDisplayOptions) return FALSE; option = (*scale->vTable->getDisplayOptions) (scale, d, &nOption); if (getIntOptionNamed (option, nOption, "abi", 0) != SCALE_ABIVERSION) { compLogMessage (d, "scalefilter", CompLogLevelError, "scale ABI version mismatch"); return FALSE; } scaleDisplayPrivateIndex = getIntOptionNamed (option, nOption, "index", -1); if (scaleDisplayPrivateIndex < 0) return FALSE; fd = malloc (sizeof (ScaleFilterDisplay)); if (!fd) return FALSE; fd->screenPrivateIndex = allocateScreenPrivateIndex (d); if (fd->screenPrivateIndex < 0) { free (fd); return FALSE; } fd->xim = XOpenIM (d->display, NULL, NULL, NULL); if (fd->xim) fd->xic = XCreateIC (fd->xim, XNClientWindow, d->screens->root, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, NULL); else fd->xic = NULL; if (fd->xic) setlocale (LC_CTYPE, ""); WRAP (fd, d, handleEvent, scalefilterHandleEvent); WRAP (fd, d, handleEcompEvent, scalefilterHandleEcompEvent); d->privates[displayPrivateIndex].ptr = fd; return TRUE; }
void BrowserControl::createInputMethodAndInputContext() { m_im = XOpenIM(m_display, 0, 0, 0); if (!m_im) fprintf(stderr, "Could not open input method\n"); m_ic = XCreateIC(m_im, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, m_browserWindow->window(), 0); if (!m_ic) fprintf(stderr, "Could not open input context\n"); }
int _glfwPlatformInit(void) { // HACK: If the current locale is C, apply the environment's locale // This is done because the C locale breaks character input if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0) setlocale(LC_CTYPE, ""); XInitThreads(); _glfw.x11.display = XOpenDisplay(NULL); if (!_glfw.x11.display) { _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to open X display"); return GL_FALSE; } _glfw.x11.screen = DefaultScreen(_glfw.x11.display); _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen); _glfw.x11.context = XUniqueContext(); if (!initExtensions()) return GL_FALSE; _glfw.x11.cursor = createNULLCursor(); if (XSupportsLocale()) { XSetLocaleModifiers(""); _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, 0, 0); if (_glfw.x11.im) { if (!hasUsableInputMethodStyle()) { XCloseIM(_glfw.x11.im); _glfw.x11.im = NULL; } } } if (!_glfwInitContextAPI()) return GL_FALSE; if (!_glfwInitJoysticks()) return GL_FALSE; _glfwInitTimer(); return GL_TRUE; }
void setup() { XSetWindowAttributes attributes; XWindowAttributes window_attributes; Visual *vis; Colormap cmap; int ignore; display = XOpenDisplay(NULL); screen = DefaultScreen(display); vis = XDefaultVisual(display, screen); cmap = DefaultColormap(display, screen); if (XGetGeometry(display, RootWindow(display, screen), &root, &ignore, &ignore, &max_width, &max_height, &ignore, &ignore) == False) die("Failed to get root Geometry!"); if (!XftColorAllocName(display, vis, cmap, fg_name, &fg)) die("Failed to allocate foreground color"); if (!XftColorAllocName(display, vis, cmap, bg_name, &bg)) die("Failed to allocate background color"); /* Setup and map window */ attributes.border_pixel = fg.pixel; attributes.background_pixel = bg.pixel; attributes.override_redirect = True; attributes.event_mask = ExposureMask|KeyPressMask|ButtonPressMask|ButtonReleaseMask; win = XCreateWindow(display, root, 0, 0, 1, 1, BORDER_WIDTH, DefaultDepth(display, 0), CopyFromParent, CopyFromParent, CWBackPixel|CWOverrideRedirect|CWEventMask|CWBorderPixel, &attributes); xim = XOpenIM(display, NULL, NULL, NULL); xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, win, XNFocusWindow, win, NULL); gc = XCreateGC(display, win, 0, 0); buf = XCreatePixmap(display, win, 1, 1, DefaultDepth(display, screen)); draw = XftDrawCreate(display, buf, vis, cmap); load_font(font_str); }
int glwtInit( const GLWTConfig *config, void (*error_callback)(const char *msg, void *userdata), void *userdata) { glwt.error_callback = error_callback; glwt.userdata = userdata; XInitThreads(); XSetIOErrorHandler(xlib_io_error); XSetErrorHandler(xlib_error); glwt.x11.xcontext = XUniqueContext(); if((glwt.x11.display = XOpenDisplay(NULL)) == NULL) { glwtErrorPrintf("XOpenDisplay failed"); return -1; } glwt.x11.screen_num = DefaultScreen(glwt.x11.display); int xkb_major = XkbMajorVersion, xkb_minor = XkbMinorVersion; int xkb_opcode = -1, xkb_event = -1, xkb_error = -1; if(!XkbQueryExtension(glwt.x11.display, &xkb_opcode, &xkb_event, &xkb_error, &xkb_major, &xkb_minor)) { glwtErrorPrintf("Xkb extension missing"); goto error; } if((glwt.x11.xim = XOpenIM(glwt.x11.display, NULL, NULL, NULL)) == NULL) { glwtErrorPrintf("XOpenIM failed"); goto error; } if(init_x11_atoms() != 0) goto error; #ifdef GLWT_USE_EGL glwt.egl.display = eglGetDisplay(glwt.x11.display); if(glwtInitEGL(config) != 0) #else if(glwtInitGLX(config) != 0) #endif goto error; XVisualInfo template;
void WindowContextBase::enableOrResetIME() { Display *display = gdk_x11_display_get_xdisplay(glass_gdk_window_get_display(gdk_window)); if (xim.im == NULL || xim.ic == NULL) { xim.im = XOpenIM(display, NULL, NULL, NULL); if (xim.im == NULL) { return; } XIMStyle styles = get_best_supported_style(xim.im); if (styles == 0) { return; } XIMCallback startCallback = {(XPointer) jview, (XIMProc) im_preedit_start}; XIMCallback doneCallback = {(XPointer) jview, im_preedit_done}; XIMCallback drawCallback = {(XPointer) jview, im_preedit_draw}; XIMCallback caretCallback = {(XPointer) jview, im_preedit_caret}; XVaNestedList list = XVaCreateNestedList(0, XNPreeditStartCallback, &startCallback, XNPreeditDoneCallback, &doneCallback, XNPreeditDrawCallback, &drawCallback, XNPreeditCaretCallback, &caretCallback, NULL); xim.ic = XCreateIC(xim.im, XNInputStyle, styles, XNClientWindow, GDK_WINDOW_XID(gdk_window), XNPreeditAttributes, list, NULL); XFree(list); if (xim.ic == NULL) { return; } } if (xim.enabled) { //called when changed focus to different input XmbResetIC(xim.ic); } XSetICFocus(xim.ic); xim.enabled = TRUE; }
int X11_VideoInit(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; /* Get the window class name, usually the name of the application */ data->classname = get_classname(); /* Open a connection to the X input manager */ #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { data->im = XOpenIM(data->display, NULL, data->classname, data->classname); } #endif /* Look up some useful Atoms */ #define GET_ATOM(X) data->X = XInternAtom(data->display, #X, False) GET_ATOM(WM_DELETE_WINDOW); GET_ATOM(_NET_WM_STATE); GET_ATOM(_NET_WM_STATE_HIDDEN); GET_ATOM(_NET_WM_STATE_MAXIMIZED_VERT); GET_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ); GET_ATOM(_NET_WM_STATE_FULLSCREEN); GET_ATOM(_NET_WM_NAME); GET_ATOM(_NET_WM_ICON_NAME); GET_ATOM(_NET_WM_ICON); GET_ATOM(UTF8_STRING); /* Detect the window manager */ X11_CheckWindowManager(_this); if (X11_InitModes(_this) < 0) { return -1; } #if SDL_VIDEO_RENDER_X11 X11_AddRenderDriver(_this); #endif if (X11_InitKeyboard(_this) != 0) { return -1; } X11_InitMouse(_this); return 0; }
i32 xwl_startup() { i32 i; xwl_window_handle_t * wh; for( i = 0; i < XWL_MAX_WINDOW_HANDLES; ++i ) { wh = &xwl_windowHandles[i]; memset( wh, 0, sizeof(xwl_window_handle_t) ); } #ifdef _WIN32 // initialize key map lshift = MapVirtualKey(VK_LSHIFT, MAPVK_VK_TO_VSC); #endif #if LINUX { Bool detectable; currentDisplay = XOpenDisplay( 0 ); if ( currentDisplay ) { currentScreen = DefaultScreen( currentDisplay ); currentInputMethod = XOpenIM( currentDisplay, 0, 0, 0 ); } else { return 0; } // disable auto-repeats // "The standard behavior of the X server is to generate a KeyRelease event for every KeyPress event." // #include <X11/XKBlib.h> //XkbSetDetectableAutorepeat( currentDisplay, True, &detectable ); } #endif #if __APPLE__ xwl_osx_startup(); #endif return 1; }
void CUnixEventEmitter::createIM() { _im = XOpenIM(_dpy, NULL, NULL, NULL); if (_im) { _ic = XCreateIC(_im, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, _win, XNFocusWindow, _win, NULL); // XSetICFocus(_ic); } else { _ic = 0; nlwarning("XCreateIM failed"); } if (!_ic) { nlwarning("XCreateIC failed"); } }
static void xim_instantiate_callback (Display *display, XPointer client_data, XPointer call_data) { GtkOXIMInfo *info = (GtkOXIMInfo*)client_data; XIM im = NULL; im = XOpenIM (display, NULL, NULL, NULL); if (!im) return; info->im = im; setup_im (info); XUnregisterIMInstantiateCallback (display, NULL, NULL, NULL, xim_instantiate_callback, (XPointer)info); info->reconnecting = FALSE; }
static Display* _initX11Package() { Display* display = XOpenDisplay( 0 ); if ( display ) { X11Package::ourScreen = DefaultScreen( display ); X11Package::ourRootWindow = DefaultRootWindow( display ); Bool Supported; XkbSetDetectableAutoRepeat( display, True, &Supported ); XFlush( display ); X11Package::ourInputMethod = XOpenIM( display, 0, 0, 0 ); } else throw; atexit( _cleanX11Package ); return display; }
void xim_init(void) { GSList *it; gchar *aname, *aclass; aname = g_strdup(g_get_prgname()); if(!aname) aname = g_strdup("obt"); aclass = g_strdup(aname); if(g_ascii_islower(aclass[0])) aclass[0] = g_ascii_toupper(aclass[0]); xim = XOpenIM(t_display, NULL, aname, aclass); if(!xim) g_message("Failed to open an Input Method"); else { XIMStyles *xim_styles = NULL; char *r; r = XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL); if(r || !xim_styles) g_message("Input Method does not support any styles"); if(xim_styles) { int i; for(i = 0; i < xim_styles->count_styles; ++i) { if(xim_styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing)) { xim_style = xim_styles->supported_styles[i]; break; } } XFree(xim_styles); } if(!xim_style) { g_message("Input Method does not support a usable style"); XCloseIM(xim); xim = NULL; } } for(it = xic_all; it; it = g_slist_next(it)) t_keyboard_context_renew(it->data); g_free(aclass); g_free(aname); }
void ui_init(void) { /* * In order to enable the creation of a transparent window, * the depth needs to be set to 32. * The following window attributes are also needed: * - background_pixel = 0; * - border_pixel = 0; * - colormap */ ui = xcalloc(1, sizeof(*ui)); ui->dpy = XOpenDisplay(NULL); if (!ui->dpy) die("cannot open display"); ui->xim = XOpenIM(ui->dpy, NULL, NULL, NULL); XMatchVisualInfo(ui->dpy, DefaultScreen(ui->dpy), 32, TrueColor, &ui->vinfo); ui->screen = DefaultScreen(ui->dpy); ui->root = RootWindow(ui->dpy, ui->screen); }
int cvrun(int argc, char ** argv) { int attr[] = { GLX_RGBA, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DEPTH_SIZE, 1, None}; XVisualInfo * vi; g_dpy = XOpenDisplay(0); g_xim = XOpenIM(g_dpy, 0, 0, 0); cvInject(CVE_INIT, 0, 0); openwin(cvInject(CVQ_XPOS, 0, 0), cvInject(CVQ_YPOS, 0, 0), cvInject(CVQ_WIDTH, 0, 0), cvInject(CVQ_HEIGHT, 0, 0), 1); vi = glXChooseVisual(g_dpy, scr(), attr); g_ctx = glXCreateContext(g_dpy, vi, 0, True); XFree(vi); map(); ((int(*)(int))glXGetProcAddress((GLubyte*)"glXSwapIntervalSGI"))(1); cvInject(CVE_GLINIT, 0, 0); while (!g_done) { XEvent e; if (XCheckWindowEvent(g_dpy, g_win, EVMASK, &e) || XCheckTypedWindowEvent(g_dpy, g_win, ClientMessage, &e)) handle(g_dpy, g_win, g_xic, &e); glXSwapBuffers(g_dpy, g_win); cvInject(CVE_UPDATE, 0, 0); } cvInject(CVE_GLTERM, 0, 0); closewin(); glXDestroyContext(g_dpy, g_ctx); XCloseIM(g_xim); XCloseDisplay(g_dpy); return cvInject(CVE_TERM, 0, 0); }
bool X11Window::internalSetupWindowInput() { // create input context (to have better key input handling) if(!XSupportsLocale()) { g_logger.error("X11 doesn't support the current locale"); return false; } XSetLocaleModifiers(""); m_xim = XOpenIM(m_display, NULL, NULL, NULL); if(!m_xim) { g_logger.error("XOpenIM failed"); return false; } m_xic = XCreateIC(m_xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, m_window, NULL); if(!m_xic) { g_logger.error("Unable to create the input context"); return false; } return true; }
void initdisplay(void) { display = XOpenDisplay(nil); if(display == nil) fatal("Can't open display"); scr.screen = DefaultScreen(display); scr.colormap = DefaultColormap(display, scr.screen); scr.visual = DefaultVisual(display, scr.screen); scr.gc = DefaultGC(display, scr.screen); scr.depth = DefaultDepth(display, scr.screen); scr.root.xid = RootWindow(display, scr.screen); scr.root.visual = scr.visual; scr.root.r = Rect(0, 0, DisplayWidth(display, scr.screen), DisplayHeight(display, scr.screen)); scr.rect = scr.root.r; scr.root.parent = &scr.root; scr.xim = XOpenIM(display, nil, nil, nil); windowmap.bucket = wbucket; windowmap.nhash = nelem(wbucket); atommap.bucket = abucket; atommap.nhash = nelem(abucket); atomnamemap.bucket = anamebucket; atomnamemap.nhash = nelem(anamebucket); fmtinstall('A', Afmt); fmtinstall('L', Lfmt); fmtinstall('R', Rfmt); fmtinstall('P', Pfmt); fmtinstall('W', Wfmt); xlib_errorhandler = XSetErrorHandler(errorhandler); }
void creategui() { int x, y, w = width, h = height; XSetWindowAttributes wa; if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) fputs("no locale support\n", stderr); screen = DefaultScreen(dpy); root = RootWindow(dpy, screen); initfont(font); cursor = XCreateFontCursor(dpy, XC_left_ptr); dc.norm[ColBG] = getcolor(normbgcolor); dc.norm[ColFG] = getcolor(normfgcolor); dc.sel[ColBG] = getcolor(selbgcolor); dc.sel[ColFG] = getcolor(selfgcolor); dc.drawable = XCreatePixmap(dpy, root, w, 2 * h, DefaultDepth(dpy, screen)); dc.gc = XCreateGC(dpy, root, 0, NULL); XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); if (!dc.font.set) XSetFont(dpy, dc.gc, dc.font.xfont->fid); wa.cursor = cursor; wa.background_pixel = dc.norm[ColBG]; XChangeWindowAttributes(dpy, root, CWBackPixel|CWCursor, &wa); x = (DisplayWidth(dpy, screen) - w) / 2; y = DisplayHeight(dpy, screen) / 2; createinput(userprompt, x, y - h, w, h, innerpx, False); createinput(passprompt, x, y, w, h, innerpx, True); im = XOpenIM(dpy, NULL, NULL, NULL); ic = XCreateIC(im, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, inputs->win, XNFocusWindow, inputs->win, NULL); }