Hello. I am trying to write an image viewer library for the R framework
(www.r-project.org) based on SDL (which I call “rsdl”). (R has rich
graphics plotting capabilities, but rendering large-ish images is quite
slow).
I am able to display an image loaded in R in an SDL window without any
problem. This is via a shared library which R loads (when I load my
rsdl library within R), containing the SDL related code (“rsdl.so”). My
problem is that I am not able to filter events. From within R I call an
sdl.open() function which in turn calls the sdlOpen symbol defined in
the shared library. The sdlOpen function creates the SDL window, and
installs an event filter like this:
…
screen = SDL_SetVideoMode(INTEGER(w)[0], INTEGER(h)[0], 32,
SDL_SWSURFACE|SDL_ANYFORMAT|SDL_RESIZABLE);
SDL_EventState(SDL_KEYDOWN, SDL_IGNORE);
SDL_EventState(SDL_KEYUP, SDL_IGNORE);
SDL_EventState(SDL_VIDEORESIZE, SDL_ENABLE);
printf("events enabled...\n");
SDL_SetEventFilter((SDL_EventFilter)filterEvents);
…
But the filter never gets (visibly) triggered. Here is my filter:
int filterEvents(SDL_Event *event) {
printf(“Caught Event…”);
if (event->type == SDL_VIDEOEXPOSE) {
printf(“Screen needs refresh…”);
SDL_UpdateRect(screen, 0, 0, screen->w, screen->h);
return(0);
}
if (event->type == SDL_VIDEORESIZE) {
printf(“Resizing…”);
if (paint)
repaint();
SDL_UpdateRect(screen, 0, 0, screen->w, screen->h);
return(0);
}
return(1);
}
When I click in the window or resize it, I never see the "Caught event"
message, and it is apparent from subsequent rendering that the program
still thinks the window is its original size.
My sense is that the problem is that the window was created from another
thread (R’s thread), and I am not able to filter events from that
thread. Is it apparent to anyone how I might work around this?
Thanks,
Eric
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient(s) please contact the sender by reply email and destroy all copies of the original message. Thank you.