I have problem with my sleep function in C.
When i use in this code sleep function like this:
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;
}
It doesn't works well for me because printf("button click") is executing all time but slower.
How to print "button click x y" once and stop listening for click for 5 second?