OKを役に立てば幸いです。 私の唯一の良い答えは端末からの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メカニズムを使用しています。
これが役に立ちます。
時にはそれはあなたが テストコードしているときにサーバーをグラブ解放する時間の遅延処理を開始し、それが座って実行してみましょうとするのは良い 考えです、あなたは彼らに新しいしている場合にはXでグラブに注意してください数分ごとに解散してください。 サーバーを強制終了したり、サーバーから外して状態を外部リセットする必要がありません。
ここからは、レンデムを多重化する方法を決定するために残しておきます。開始するには、XGrabKeyboardのdocsとXEventのドキュメント を読んでください。 画面の角に小さなウィンドウが表示されている場合、コントローラーを選択するためのポインターを1つの角に詰めて することができます。 XWarpPointerは コードの1つにポインタを移動することもできます。
もう1つのポイント:ポインタと他のリソースをつかむことができます。 1つのコントローラが座っているボックスの上にある場合は、キーボードとマウス入力を使用して、異なるレンダラを持つオープンソケット間で切り替えることができます。この方法では、出力ウィンドウのサイズをフルスクリーンより小さくする必要はありません。さらに多くの作業で、SHAPEおよびCOMPOSITE拡張機能を使用して実際にアルファブレンディングされたオーバーレイをドロップして、ユーザーの入力に応じて素敵なオーバーレイ機能を得ることができます。
私は上記の説明につながった「答え」を削除しました...私は説明を残す必要があると思いますが、コメントであった可能性のある擬似回答を完全に削除することができます。 –