Sending events to SDL window

Hello,

Can anyone comment the following problem:
I’ve got a window and installed event filter. This filter
checks for SDL_VIDEORESIZE events ( which are received when
user resizes window with mouse ) and executes corresponding
resizing code ( SDL_FreeSurface(); SDL_CreateSurface() )
when it receives them.
Now I want to manually resize that window from other thread.
Resizing by calling SDL_FreeSurface() and SDL_CreateSurface()
is not accepted: I want to add SDL_VIDEORESIZE event to the
queue, so that resizing will be performed from event thread.
The following code:

SDL_Event ev;
ev.type=SDL_VIDEORESIZE;
ev.resize.w=…
ev.resize.h=…
SDL_PushEvent(&ev);

does not work ( SDL_PushEvent always fails ). I tried to delete
some events from queue by calling SDL_PeepEvents() before
SDL_PushEvent(). Now SDL_PushEvent() succeeds, but event filter
still does not receive resize event :frowning:

What am I doing wrong? How it can be done ( maybe by direct X11
call )? I don’t need portability, any solution that works with
Unix/X11 will be OK.

Thanks!–
Best regards,
Eugene mailto:divx at euro.ru

Now SDL_PushEvent() succeeds, but event filter still does not
receive resize event :frowning:

The filter isn’t called by the event queue code, it’s called by
the underlying video driver when a resize event happens, and uses
the information the filter returns to decide whether to place the
resize event on the event queue. Just call your filter directly
from the other thread. If you are worried about thread-safety,
then you should probably handle the resize event from your main
thread anyway. :slight_smile:

Oh, I just saw who was posting. Hi Eugene. :slight_smile:

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software