SDL_WINDOWID and xscreensaver

Hello,

I have looked through almost all the site libsdl.org and at the
documentation project, but still have the question unresolved.
I am writing a new screensaver for xscreensaver and xscreensaver passes
2 parameters for my proggy:
Window win and Display *dpy
I am setting SDL_WINDOWID environment variable with the value of window
variable, but after initializing SDL,
it creates another window and works with it, rather than with window
which was passed as an environment variable.

My code is looking about this way:
—cut—
//…
XOpenDisplay(…);
//…
screenhack(display, window);
///…

screenhack(Display *dpy, Window win)
{
//…
char SDL_vidvar[256];
snprintf(SDL_vidvar, 256, “SDL_WINDOWID=%ld”, win);
putenv(SDL_vidvar);
flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;
if (SDL_Init(flags))
{
fprintf(stderr, “Could not init SDL\n”);
exit(1);
}
//…
screen = SDL_SetVideoMode(width, height, 0, other_flags);
// … more code showing video stream …
}
—cut—

So SDL_Init does not fail and SDL_SetVideoMode does not fail.
But my video stream does not appear in win window but in newly created one.

What could be wrong with setting SDL_WINDOWID?

Sincerely,

Denis Frolov