考虑以下在线找到的最小窗口管理器。它可以很好地编译和运行。
#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加载终端(如xterm)和"onboard“屏幕上的键盘程序(服务器附加,安装了xinit )。在这个最小的窗口管理器中,板载屏幕键盘不向其他窗口发送按键输入(板载加载到屏幕底部区域)。
请注意,DWM最小化窗口管理器按预期工作(板载输入将发送到所有其他窗口)。我在DWM源代码中找不到考虑这种事情的地方。
我的问题是:如何让这个迷你窗口管理器允许板载屏幕键盘将输入发送到其他窗口?
发布于 2020-02-11 02:49:01
找到了解决方案。我应该已经在终端上使用了XSetInputFocus,然后输入就正确了。
//e.window is the program window for the program that should get the input.
XSetInputFocus(mDisplay, e.window, RevertToPointerRoot, CurrentTime);https://stackoverflow.com/questions/60132969
复制相似问题