Automatically move surface

Does anyone know, if there’s a function to move a surface to specific, give coordinates?

Thanks for helping

(looking around to make sure he’s not making a fool of himself)

Uh… You mean, like, SDL_BlitSurface() ???

-bill!On Sat, Nov 23, 2002 at 03:23:21AM +0100, Nils Frohm?ller wrote:

Does anyone know, if there’s a function to move a surface to specific, give coordinates?

Thanks for helping

This works for XWindow system, but not for Windows. I suspect there’s a way
to do it in WIndows, but I haven’t discovered it yet. Hope this helps.

#ifndef WIN32 // put the window where we want it
int isX11 = FALSE;
int x, y, w, h;
int x11screen;
SDL_SysWMinfo info;

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;
	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 22 November 2002 06:23 pm, you wrote:

Does anyone know, if there’s a function to move a surface to specific, give
coordinates?

Oh, did he mean a WINDOW? (Not a surface)

-bill!On Fri, Nov 22, 2002 at 08:46:11PM -0800, j_post wrote:

On Friday 22 November 2002 06:23 pm, you wrote:

Does anyone know, if there’s a function to move a surface to specific, give
coordinates?

This works for XWindow system, but not for Windows. I suspect there’s a way
to do it in WIndows, but I haven’t discovered it yet. Hope this helps.

Does anyone know, if there’s a function to move a surface to specific,
give coordinates?

Oh, did he mean a WINDOW? (Not a surface)

That was my guess, based on the context. But I could be wrong :wink:

JeffOn Friday 22 November 2002 09:15 pm, you wrote: