Having troubles using XkbKeycodeToKeysym
Lucien Gentis
lucien.gentis at univ-lorraine.fr
Thu May 2 10:47:28 UTC 2024
Hello,
I guess you declare "window" variable as a pointer to MWWindowstructure ?
Le 01/05/2024 à 11:39, Mibi88 a écrit :
>
> Hello,
>
> I hope that I'm asking on the right place for help, if not, where
> should I ask for help about XLib?
>
> I'm writing a program that uses opengl, glx and xlib. Everything works
> fine, I can get the mouse position, the mouse button press events etc.
> But when I try to get Symcodes from keycodes, my program just
> segfaults. I checked the arguments I'm passing multiple times, I tried
> using XKeycodeToKeysym...
>
> I tested it on another computer, and I had the same issue.
>
> I'm getting the event like this:
>
> if(XPending(window->display)){
>
> XNextEvent(window->display, &window->event);
>
> if(window->event.type== KeymapNotify){
>
> XRefreshKeyboardMapping(&(window->event.xmapping));
>
> }
>
> return1;
>
> }
>
> return0;
>
Perhaps replace "&window->event" by "&(window->event)"
>
> I'm getting the keysyms as following:
>
> KeySymkeysym;
>
> keysym = XkbKeycodeToKeysym(window->display,
> window->event.xkey.keycode, 0,
>
> window->event.xkey.state);
>
> That's how I create my window:
>
> GLintvisual_attributes[] = {
>
> GLX_RGBA,
>
> GLX_DEPTH_SIZE,
>
> 8,
>
> GLX_DOUBLEBUFFER,
>
> None /* Always ends with None */
>
> };
>
> window->display= XOpenDisplay(NULL);
>
> if(window->display== NULL){
>
> puts("[MibiEngine] Failed to connect to the X server!");
>
> return1;
>
> }
>
> window->root= DefaultRootWindow(window->display);
>
> window->visual_info= glXChooseVisual(window->display, 0,
>
> visual_attributes);
>
> if(!window->visual_info){
>
> puts("[MibiEngine] No visual found!");
>
> return2;
>
> }
>
> window->color_map= XCreateColormap(window->display, window->root,
>
> window->visual_info->visual, AllocNone);
>
> window->set_window_attributes.colormap= window->color_map;
>
> window->set_window_attributes.event_mask= MW_EVENT_MASKS;
>
> window->window= XCreateWindow(window->display, window->root, 0, 0, width,
>
> height, 0, window->visual_info->depth,
>
> InputOutput, window->visual_info->visual,
>
> CWColormap | CWEventMask,
>
> &window->set_window_attributes);
>
> XSelectInput(window->display, window->window, MW_EVENT_MASKS);
>
> /* Make the window appear */
>
> XMapWindow(window->display, window->window);
>
> /* Set the text in the title bar */
>
> XStoreName(window->display, window->window, title);
>
> /* Create the OpenGL context */
>
> window->glx_context= glXCreateContext(window->display,
> window->visual_info,
>
> NULL, GL_TRUE);
>
> glXMakeCurrent(window->display, window->window, window->glx_context);
>
> window->wm_delete= XInternAtom(window->display, "WM_DELETE_WINDOW", True);
>
> XSetWMProtocols(window->display, window->window, &window->wm_delete, 1);
>
> The window struct I'm using everywhere is defined as following:
>
> typedefstruct{
>
> Display*display;
>
> Windowroot;
>
> XVisualInfo*visual_info;
>
> Colormapcolor_map;
>
> XSetWindowAttributesset_window_attributes;
>
> Windowwindow;
>
> GLXContextglx_context;
>
> XWindowAttributeswindow_attributes;
>
> XEventevent;
>
> Atomwm_delete;
>
> XIMxim;
>
> XICxic;
>
> longmask;
>
> } MWWindow;
>
> Thanks
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.x.org/archives/xorg/attachments/20240502/0647dc9c/attachment-0001.htm>
More information about the xorg
mailing list