Moving a window

When I create a window/surface with SDL, it creates the window in the top,
left corner of the screen. Is there a way to programmatically specify the
location of the window? Thank you for your help.

#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) // center the window on the screen
{
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;
y = (h - screen->h) / 2;
if (x >= 0 && y >= 0)
XMoveWindow(info.info.x11.display, info.info.x11.wmwindow, x, y);
info.info.x11.unlock_func();
}
#endifOn Sunday 09 March 2003 03:23 pm, you wrote:

When I create a window/surface with SDL, it creates the window in the top,
left corner of the screen. Is there a way to programmatically specify the
location of the window? Thank you for your help.

j_post wrote:> On Sunday 09 March 2003 03:23 pm, you wrote:

When I create a window/surface with SDL, it creates the window in the top,
left corner of the screen. Is there a way to programmatically specify the
location of the window? Thank you for your help.

#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) // center the window on the screen
{
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;
y = (h - screen->h) / 2;
if (x >= 0 && y >= 0)
XMoveWindow(info.info.x11.display, info.info.x11.wmwindow, x, y);
info.info.x11.unlock_func();
}
#endif

is there any plans for SDL functions to handle this sort of thing?

Hi,

I’m using “SDL_SetVideoMode( …, SDL_NOFRAME)”, which creates a
window without a title bar and leave no way for the user to move the
window to another part of the screen. To solve this I want to use
SDL_MOUSEMOTION (xrel and yrel) so that the user can click on parts of
the window and drag the window around the screen.

I’m trying to find a way to move an SDL window on the OS’s screen,
plus a way to find out how big the screen is and where the window
currently is on the screen (so that I don’t shift the window past an
edge of the screen).

Is there a portable way to do this?

Thanks,

Brendan