확인을 도움이되기를 바랍니다. 당신이 아니라면, 내 유일한 좋은 대답은 터미널에서 ncurses입니다. 여기
는 키보드에 이르기까지 모든 것을 잡아 다시 해제하는 방법은 다음과 같습니다
/* Demo code, needs more error checking, compile
* with "gcc nameofthisfile.c -lX11".
/* weird formatting for markdown follows. argh! */
#include <X11/Xlib.h>
int main(int argc, char **argv)
{
Display *dpy;
XEvent ev;
char *s;
unsigned int kc;
int quit = 0;
if (NULL==(dpy=XOpenDisplay(NULL))) {
perror(argv[0]);
exit(1);
}
/*
* You might want to warp the pointer to somewhere that you know
* is not associated with anything that will drain events.
* (void)XWarpPointer(dpy, None, DefaultRootWindow(dpy), 0, 0, 0, 0, x, y);
*/
XGrabKeyboard(dpy, DefaultRootWindow(dpy),
True, GrabModeAsync, GrabModeAsync, CurrentTime);
printf("KEYBOARD GRABBED! Hit 'q' to quit!\n"
"If this job is killed or you get stuck, use Ctrl-Alt-F1\n"
"to switch to a console (if possible) and run something that\n"
"ungrabs the keyboard.\n");
/* A very simple event loop: start at "man XEvent" for more info. */
/* Also see "apropos XGrab" for various ways to lock down access to
* certain types of info. coming out of or going into the server */
for (;!quit;) {
XNextEvent(dpy, &ev);
switch (ev.type) {
case KeyPress:
kc = ((XKeyPressedEvent*)&ev)->keycode;
s = XKeysymToString(XKeycodeToKeysym(dpy, kc, 0));
/* s is NULL or a static no-touchy return string. */
if (s) printf("KEY:%s\n", s);
if (!strcmp(s, "q")) quit=~0;
break;
case Expose:
/* Often, it's a good idea to drain residual exposes to
* avoid visiting Blinky's Fun Club. */
while (XCheckTypedEvent(dpy, Expose, &ev)) /* empty body */ ;
break;
case ButtonPress:
case ButtonRelease:
case KeyRelease:
case MotionNotify:
case ConfigureNotify:
default:
break;
}
}
XUngrabKeyboard(dpy, CurrentTime);
if (XCloseDisplay(dpy)) {
perror(argv[0]);
exit(1);
}
return 0;
}
터미널에서 실행이 모든 KBD 이벤트가 충돌한다. 난 Xorg 아래에서 테스트 중이지만, 유서 깊고 안정적인 Xlib 메커니즘을 사용합니다.
희망이 도움이됩니다.
때때로 그것은 당신이 테스트 코드가되면 서버를 ungrab하는 시간 지연 프로세스를 시작하고 앉아서 실행할 수 있도록하고 좋은 생각, 당신은 그들에게 새가되면이 X 잡고 조심 몇 분마다 해제하십시오. 서버를 강제 종료하거나 외부로 다시 설정하지 않아도됩니다.
여기에서 렌드를 다중 전송하는 방법을 결정하겠습니다. 시작하려면 XGrabKeyboard docs 및 XEvent 문서 을 읽으십시오. 작은 창문이 화면 모서리에 노출되어있는 경우 포인터를 한 모퉁이에 끼워 컨트롤러를 선택할 수 있습니다. XWarpPointer 코드에서 그들 중 하나뿐만 아니라 포인터를 밀 수 있습니다.
한 번 더 : 포인터와 다른 리소스를 가져올 수 있습니다. 하나의 컨트롤러가 앞에 앉아있는 상자에서 실행 중이면 키보드 및 마우스 입력을 사용하여 다른 렌더러가있는 열린 소켓간에이를 전환 할 수 있습니다.이 방식을 사용하면 출력 창 크기를 전체 화면보다 작게 조정할 필요가 없습니다. 더 많은 작업을 통해 SHAPE 및 COMPOSITE 확장을 사용하여 실제로 알파 블렌딩 된 오버레이를 드롭하여 사용자 입력에 대한 응답으로 멋진 오버레이 기능을 얻을 수 있습니다 (백합을 누적하는 것으로 간주 할 수 있음).
위의 설명을 이끌어 낸 "대답"이 삭제되었습니다. 설명을 유지해야한다고 생각하지만 주석이 될 수있는 의사 답변은 완전히 삭제 될 수 있습니다. –