0
我有問題,我的睡眠功能禁用排隊C.執行用C
,當我在此code睡眠功能使用這樣的:
while(1) {
XNextEvent(display, &xevent);
switch (xevent.type) {
case MotionNotify:
break;
case ButtonPress:
printf("Button click: [%d, %d]\n", xevent.xmotion.x_root, xevent.xmotion.y_root);
sleep(5);
break;
case ButtonRelease:
break;
}
它不爲我工作得很好,因爲printf的(「按鈕點擊」)正在執行,但速度較慢。
如何打印「按鈕點擊x y」一次並停止點擊5秒鐘?
我不清楚你想要什麼 - 在事件循環中「睡覺」不是X所做的。 – tofro
當我點擊屏幕上的任何地方時,我收到消息「按鈕點擊x,y」 當我點擊快速5次時,我得到5條消息,但25秒後。即使我幾次,我也只想得到一條消息。 – Adrian