PDA

View Full Version : SDL Window Manager



godbeast
11-07-2006, 10:50 PM
Hi. How to move window invoked via sdl window manager to a certain position? Windowed mode apps always start at the same position.

WILL
12-07-2006, 12:24 AM
I did a quick google search and found this http://www.libsdl.org/pipermail/sdl/2005-November/071173.html, however it's in C and I cannot tell what the XMoveWindow() function is from. Possibly a X11 or Linux API call?

The line

SDL_SysWMinfo info;
is just declaring the object, SDL_SysWMinfo. Which makes sense as the WM stands for Window(s?) Manager.

If you are using JEDI-SDL, have a look/search through the sdl.pas header file for a command within that section that deals with general initializations and such. Might be something there, cannot remember (been a while since I dug through the whole thing)

Dom? :)

technomage
12-07-2006, 06:58 AM
The SDL_SysWMInfo will give you platform specific windows information, this will include the Handle under Win32 and other bits needed for X11. I'm not sure if anyone has used it to move a window though.

There are environment variables you can set (I believe) to change the position. The WebUpdate example in the SDL_Net folder uses this to center the window but I think that only works under Win32.

tanffn
12-07-2006, 08:16 AM
If you don’t mind the OS specific code (win32) you can do this (I know it’s a bit cheating :) )

Create the window with:

CreateWindowEx(....)

and then you can move it with:

SetWindowPos(Handle, HWND_TOP, WindowPos.x, WindowPos.y, 0, 0, SWP_NOSIZE)

you can also do neat stuff on the window like (thats what I needed it for):

SetWindowRgn()

Let me know if you need more info.

godbeast
12-07-2006, 11:52 AM
Thanks lads, but unfortunatelly I have no windows programming knowledge (I'm sticking to fpc and I try to avoid any windows related programming, that's why I decided to use sdl :D). Anyway, I found a solution here (http://www.pascalgamedevelopment.com/forums/viewtopic.php?t=2823&sid=00e5c64c0081e6f589ffb23908c96971) 8) dunno if it'll work on other systems than win32, it suits my current needs.

The code goes like this if anyone is intrested (it has to be put before SDL_Init


SDL_putenv('SDL_VIDEO_WINDOW_POS=10,10');

or to center sdl window (only window area, it doesn't counts in the size of caption and borders)


SDL_putenv('SDL_VIDEO_WINDOW_POS=center');
SDL_putenv('SDL_VIDEO_CENTERED=1');

I'll read forums more carefully next time :twisted: