openGL fullscreen switching


In my OpenGL program I wish to toggle between fullscreen and window modes.
Currently I shut down Video subsystem and reinitialize in the new mode.
Everthing works perfectly EXCEPT the SDL_KEYUP event is lost on entering
fullscreen mode ie:

if ((event.type) == SDL_KEYDOWN) && (event.key.keysym.sym == SDLK_F8))
toggle_fullscreen(r, 640, 480);

when executing the above code SDL enters fullscreen mode but hasn’t
realized that the F8 key has been released!! It is then necessary to
press the F8 key twice in order to switch back to windowed mode.
Suprisingly the event is not lost when toggling the other way.

Using the KEY_UP event works correctly but is awkward if the user decides
to keep the key depressed and waits for the mode to switch.

Does anybody have a work around for this?? I have tried pumping the event
queue but it doesn’t help.

I am on a linux system using SDL version 1.2 if that makes any difference.

Thanks in advance