Hi Everyone,
Can you make SDL create a surface as a child of a x11 window? Can you set
the x,y coordinates that the window places itself in on creation?
Thanks in advance,
Julie.
Hi Everyone,
Can you make SDL create a surface as a child of a x11 window? Can you set
the x,y coordinates that the window places itself in on creation?
Thanks in advance,
Julie.
Hi Julie,
I don’t know if it is possible to place the surface as a child of the x11
window but there is the SDL_WINDOWID hack which can be useful. If you set the
the SDL_WINDOWID environmental variable to contains the id of the window you
want to put SDL surface in the SDL should do it.
For the plain SDL_Surface you can set it’s creation position using the
following code
#include “SDL_syswm.h”
#ifndef WIN32
bool isX11 = FALSE;
int x, y, w, h;
int x11screen;
SDL_SysWMinfo info;
#endif
if (SDL_Init(SDL_INIT_VIDEO ) != 0)
{
printf("\nUnable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
init_video(SCREEN_PIXEL_WIDTH, SCREEN_PIXEL_HEIGHT,
SCREEN_PIXEL_DEPTH);
#ifndef WIN32 // put the window where we want it
SDL_VERSION(&info.version);
if (SDL_GetWMInfo(&info) > 0)
{
if (info.subsystem == SDL_SYSWM_X11)
isX11 = TRUE;
}
if (isX11)
{
info.info.x11.lock_func();
x11screen = DefaultScreen(info.info.x11.display);
w = DisplayWidth(info.info.x11.display, x11screen);
h = DisplayHeight(info.info.x11.display, x11screen);
x = (w - screen->w) / 2;
if (x + screen->w > w) // if
centering x won’t fit,
x = WINDOW_X_POSITION; // use
arbitrary horizontal position
y = (h - screen->h) / 2;
if (y + screen->h > h) // if
centering y won’t fit,
y = WINDOW_Y_POSITION; // use
arbitrary vertical position
if (x >= 0 && y >= 0)
XMoveWindow(info.info.x11.display,
info.info.x11.wmwindow, x, y);
info.info.x11.unlock_func();
}
#endifOn Friday 26. of September 2003 03:24, Julie Russell wrote:
Hi Everyone,
Can you make SDL create a surface as a child of a x11 window? Can you set
the x,y coordinates that the window places itself in on creation?Thanks in advance,
Julie.
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl