SDL_SYSWMEVENT on windowsXP

I have an SDL videowindow where I only process SDL_VIDEORESIZE and SDL_QUIT events.
Processing the messages works at acceptable speed.
I also need to process the window move event. Since there is no SDL event for that I catch the SDL_SYSWMEVENT event, and perform an action when I receive a WM_MOVE. Basically it all works, but as soon as I start listening to SDL_SYSWMEVENT events, the event processing goes very slow.
(I takes almost 2 seconds to process a resize message) It seems I receive a big number of SDL_SYSWMEVENT events continuously. If I process these events or not has no influence on the speed. I notice that my WM_MOVE message arrives 6 times in the eventqueue, while I would expect it only once.
Are there known issues with SDL_SYSWMEVENT on windows?
Is there perhaps another way to catch videowindow move events without using SDL_SYSWMEVENT?

Basically I do this (Maybe this is not how its supposed to be?):

SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
while (SDL_WaitEvent(&event))
{
switch(event.type)
{
case SDL_SYSWMEVENT:
if (event.syswm.msg->msg == WM_MOVE)
{
//ACTION
}
break;
//SNIP…
}

I have an SDL videowindow where I only process SDL_VIDEORESIZE and SDL_QUIT events.
Processing the messages works at acceptable speed.
I also need to process the window move event. Since there is no SDL event for that I catch the SDL_SYSWMEVENT event, and perform an action when I receive a WM_MOVE. Basically it all works, but as soon as I start listening to SDL_SYSWMEVENT events, the event processing goes very slow.
(I takes almost 2 seconds to process a resize message) It seems I receive a big number of SDL_SYSWMEVENT events continuously. If I process these events or not has no influence on the speed. I notice that my WM_MOVE message arrives 6 times in the eventqueue, while I would expect it only once.
Are there known issues with SDL_SYSWMEVENT on windows?
Is there perhaps another way to catch videowindow move events without using SDL_SYSWMEVENT?

Basically I do this (Maybe this is not how its supposed to be?):

SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
while (SDL_WaitEvent(&event))
{
switch(event.type)
{
case SDL_SYSWMEVENT:
if (event.syswm.msg->msg == WM_MOVE)
{
//ACTION
}
break;
//SNIP…
}

Hi all,

I’ve been using SDL (also ttf, net and mixer) library for my hobby
project and I must say I’ve absolutely loved the minimalistic API design
principle. It gives such a low learning curve that I haven’t gotten
frustrated with it, which happens with most libraries. Lots of Kudos to
you for that!

Anyway, I noticed that there are some safety issues with how macro
function arguments are used in some parts of SDL. The SDL_net.h is the
worst where there are usually no parenthesis at all around the
arguments. The main library seems to be almost clean, but I found one
place in there as well which might result in some erroneous behaviour.

I know that macros can never be truly safe (have you considered using
innline functions, btw?), but I think you should thrive for as much
safety as is possible.

Anyway, here’s one example of the problem (found in SDL_net.h):
#define SDLNet_Write16(value, areap)
do
{
Uint8 *area = (Uint8 *)(areap);
area[0] = (value >> 8) & 0xFF;
area[1] = value & 0xFF;
} while ( 0 )

Now imagine I use this macro in my code like this:
SDLNet_Write16(a | b >> 8, ptr);

The area[1] = value & 0xFF; line will get replaced with the following:
area[1] = a | b & 0xFF;
Now, due to the the order of precedence rules in C this is equal to:
area[1] = a | (b & 0xFF);
Which is clearly wrong.

The problematic case of:
SDLNet_Write16(a++, ptr)
Could also be handled by taking a local copy of ‘value’ inside the
macro, just like how ‘areap’ is handled, i.e.:
Uint16 v = (Uint16)(value);
area[0] = (v >> 8) & 0xFF;
area[1] = v & 0xFF;

This situation is repeated in all the SDLNet_Write*() macros.

Some more cases below. These do not seem that serious, but it usually
pays off to be extra cauteous with macros, especially when someone else
than the writer is using them. I’m assuming that to be the case as these
are public headers.

SDL_version.h:
#define SDL_VERSIONNUM(X, Y, Z)
(X)*1000 + (Y)*100 + (Z)
should add one set of parenthesis around this function:
((X)*1000 + (Y)*100 + (Z))
Otherwise the following code will break:
SDL_VERSIONNUM(1, 2, 3)*100

SDL_mouse.h:
#define SDL_BUTTON(X) (SDL_PRESSED << (X-1))
->
#define SDL_BUTTON(X) (SDL_PRESSED << ((X)-1))

SDL_cdrom.h:#define CD_INDRIVE(status) ((int)status > 0)
->
SDL_cdrom.h:#define CD_INDRIVE(status) ((int)(status) > 0)

Cheers,
Petri–
o Petri Kero, Systems Architect
o Hybrid Graphics, Ltd.
o Mobile: +358 40 722 2239