AutoRepeat trouble

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

2 posts / 0 new
Last post
AutoRepeat trouble

Submitted by Lorenzo Chomp on Mon, 02/27/2006 - 18:24. General Questions
Hi, I'm new on this forum. Currently, I'm programming a small game, and using Motif for the GUI (I have a MainWindow, a menubar, menu items and a few dialogs). The MainW's client area is filled with a DrawingArea widget (the game itself is displayed there). I didn't had any problem with the drawing and the general input events, but I needed to disabled the AutoRepeat for the keys (in order to stop a cascade of KeyPress events). I decided to do that when the window loses the input focus (I thought that using just the EnterNotify and EnterLeave was too limited). To make it more clear, this is the code of my game loop:
........
for( ; ; ) {
if(XtAppPending(_hAppcontext)) {
XtAppNextEvent (_hAppcontext, &sEvent);
if(sEvent.type == FocusIn) {
printf("\nFocus In!\n");
XAutoRepeatOff(XtDisplay(_hDraw));
}
if(sEvent.type == FocusOut) {
printf("\nFocus Out!\n");
XAutoRepeatOn(XtDisplay(_hDraw));
}

XtDispatchEvent (&sEvent);
}
else { ......... }
}//END

_hDraw is the Drawing Area Widget. This code works while the program is running, but when the game exits, the AutoRepeat remains disabled (that's pretty bad). I tried to use other events (UnmapNotify, DestroyNotify), but it didn't work at all. The weird thing is that I don't receive any other messages when I exit (I'm always talking about closing the window with the "X" button). Does somebody know what I'm doing wrong?

PS: I tried with OpenMotif 2.2.3, and also with Lesstif 0.9.4.4

Lorenzo Chomp

Ok, I've noticed something...the code above never executes til the end. I did this:

int main (int argc, char *argv[])
{ /* stuff */
...............
GameLoop(); // here the code I posted before
printf("\nThis is getting annoying\n");
return 0;
}

The matter is that the printf call never executes at all. So I must assume that the program exits inside the GameLoop. It worked for the drawing stuff, but I guess that is not quite right.