繁体   English   中英

XLIB 窗口管理器中的终端未从屏幕键盘上的“OnBoard”接收按键

[英]Terminal in XLIB Window Manager not receiving key presses from "OnBoard" 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 = 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;
}

在这个窗口管理器中,我可以使用 ubuntu(服务器添加,安装了 xinit)加载终端(例如 xterm)和屏幕键盘程序的“板载”。 在这个最小的窗口管理器中,板载屏幕键盘不会将键输入发送到其他窗口(屏幕底部区域的板载负载)。

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

我的问题是:如何让这个最小化的窗口管理器允许板载屏幕键盘将输入发送到其他窗口?

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM