C XLIB窗口管理器中的终端未接收来自“的按键”;船上“;屏幕键盘

C XLIB窗口管理器中的终端未接收来自“的按键”;船上“;屏幕键盘,c,xlib,window-managers,on-screen-keyboard,C,Xlib,Window Managers,On Screen Keyboard,考虑以下在线找到的最小窗口管理器。它编译和运行良好 #include <X11/Xlib.h> #include <stdio.h> #include <stdlib.h> int main() { Display *display; Window window; XEvent event; int s; /* open connection with the server */ display = XOpe

考虑以下在线找到的最小窗口管理器。它编译和运行良好

#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
    Display *display;
    Window window;
    XEvent event;
    int s;

    /* open connection with the server */
    display = XOpenDisplay(NULL);
    if (display == NULL)
    {
        fprintf(stderr, "Cannot open display\n");
        exit(1);
    }

    s = DefaultScreen(display);

    /* create window */
    window = XCreateSimpleWindow(display, RootWindow(display, s), 10, 10, 200, 200, 1,
                           BlackPixel(display, s), WhitePixel(display, s));

    /* select kind of events we are interested in */
    XSelectInput(display, window, KeyPressMask | KeyReleaseMask );

    /* map (show) the window */
    XMapWindow(display, window);

    /* event loop */
    while (1)
    {
        XNextEvent(display, &event);

        /* keyboard events */
        if (event.type == KeyPress)
        {
            printf( "KeyPress: %x\n", event.xkey.keycode );

            /* exit on ESC key press */
            if ( event.xkey.keycode == 0x09 )
                break;
        }
        else if (event.type == KeyRelease)
        {
            printf( "KeyRelease: %x\n", event.xkey.keycode );
        }
    }

    /* close connection to server */
    XCloseDisplay(display);

    return 0;
}
#包括
#包括
#包括
int main()
{
显示*显示;
窗口窗口;
XEvent事件;
int-s;
/*打开与服务器的连接*/
display=XOpenDisplay(空);
如果(显示==NULL)
{
fprintf(stderr,“无法打开显示\n”);
出口(1);
}
s=默认屏幕(显示);
/*创建窗口*/
window=XCreateSimpleWindow(显示,根窗口(显示,s),10,10,200,200,1,
黑色像素(显示器),白色像素(显示器);
/*选择我们感兴趣的活动类型*/
XSelectInput(显示、窗口、按键掩码|按键释放掩码);
/*绘制(显示)窗口地图*/
XMapWindow(显示,窗口);
/*事件循环*/
而(1)
{
XNextEvent(显示和事件);
/*键盘事件*/
如果(event.type==KeyPress)
{
printf(“按键:%x\n”,event.xkey.keycode);
/*按ESC键退出*/
如果(event.xkey.keycode==0x09)
打破
}
else if(event.type==keyrease)
{
printf(“密钥释放:%x\n”,event.xkey.keycode);
}
}
/*关闭与服务器的连接*/
XCloseDisplay(显示);
返回0;
}
在这个窗口管理器中,我可以加载一个终端(比如xterm)和带有ubuntu的“板载”屏幕键盘程序(添加了服务器,安装了xinit)。在这个最小窗口管理器中,板载屏幕键盘不会向其他窗口发送按键输入(板载负载位于屏幕底部区域)

请注意,DWM极简主义窗口管理器按预期工作(板载输入被发送到所有其他窗口)。我无法在DWM源代码中找到考虑这种事情的地方


我的问题是:如何使这个minialist窗口管理器允许板载屏幕键盘向其他窗口发送输入?

找到了解决方案。我应该在终端上使用XSetInputFocus,然后输入正确

//e.window is the program window for the program that should get the input.
XSetInputFocus(mDisplay, e.window, RevertToPointerRoot, CurrentTime);

找到了解决办法。我应该在终端上使用XSetInputFocus,然后输入正确

//e.window is the program window for the program that should get the input.
XSetInputFocus(mDisplay, e.window, RevertToPointerRoot, CurrentTime);

嗨,巴德,刚刚删除了可访问性标签,因为这与残疾用户的可访问性有关。希望你能找到人来回答这个问题!嗨,巴德,刚刚删除了可访问性标签,因为这与残疾用户的可访问性有关。希望你能找到人来回答这个问题!