SDL 1.3 event queue

Hello guys,

I’m playing a little more with SDL on Mac and using Cocoa for main
menu. However I noticed one strange thing.

If user goes to the main menu on Mac, or some modal (alert) dialog is
displayed from SDL application, after few seconds SDL event queue is
somehow locked or inactive and fails to get new events through
SDL_PushEvent.
SDL_PushEvent starts to return -1 and will not accept new events until
I leave the menu.

Basically if I’m fast in the menu I can choose Quit for example, but
if I spend few seconds in the menu, event queue is locked and even
Quit event won’t make it to the queue and will report -1.

How could I fix this? I tried SDL_INIT_EVENTTHREAD but then my
application freezed on startup.

thanks,—
Pavel Kanzelsberger


E-Mail: pavel at kanzelsberger.com
Jabber: kanzelsberger at jabber.org, ICQ: 20990633

Do you mean SDL_PollEvent? SDL_PushEvent is for adding events to the
queue, not getting them out. If SDL_PushEvent returns -1 it means the
event queue is full and not accepting new events.

Cocoa and SDL would both be trying to get events from the OS at the
same time. If Cocoa gets an event, SDL doesn’t and vice versa; they
don’t go to both.On 29 April 2010 03:19, Pavel Kanzelsberger wrote:

Hello guys,
I’m playing a little more with SDL on Mac and using Cocoa for main menu.

If user goes to the main menu on Mac, or some modal (alert) dialog is
displayed from SDL application, after few seconds SDL event queue is somehow
locked or inactive and fails to get new events through SDL_PushEvent.
SDL_PushEvent starts to return -1 and will not accept new events until I
leave the menu.

Hello,

thank you very much for your clarification, now I understood it correctly.

So the problem is now like this. When you access Cocoa menu, SDL event queue is stopped, however I have few threads that keep running in the background and they push new events to SDL event queue, it then gets full very quickly, because nobody is processing them until I quit the menu.

Is there a way to detect this event queue state and not flood it while it’s locked? Or is it possible for SDL_PushEvent to not accept new events while event queue is in this state?? That would be the best behaviour probably…

PavelOn 29.4.2010, at 16:05, Kenneth Bull wrote:

On 29 April 2010 03:19, Pavel Kanzelsberger <@Pavel_Kanzelsberger> wrote:

Hello guys,
I’m playing a little more with SDL on Mac and using Cocoa for main menu.

If user goes to the main menu on Mac, or some modal (alert) dialog is
displayed from SDL application, after few seconds SDL event queue is somehow
locked or inactive and fails to get new events through SDL_PushEvent.
SDL_PushEvent starts to return -1 and will not accept new events until I
leave the menu.

Do you mean SDL_PollEvent? SDL_PushEvent is for adding events to the
queue, not getting them out. If SDL_PushEvent returns -1 it means the
event queue is full and not accepting new events.

Cocoa and SDL would both be trying to get events from the OS at the
same time. If Cocoa gets an event, SDL doesn’t and vice versa; they
don’t go to both.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

That is exactly what SDL_PushEvent is doing. It informs you that the
queue is full by returning -1 and does not add the new event to the
queue.

The best thing for you to do would be to set a flag when you access
the menu and clear it when you’re done, and do not try to add new
events while the flag is set.On 29 April 2010 14:54, Pavel Kanzelsberger wrote:

Is there a way to detect this event queue state and not flood it while it’s locked? Or is it possible for SDL_PushEvent to not accept new events while event queue is in this state?? That would be the best behaviour probably…