PDA

View Full Version : (SDL) Window Position in X



linux freepascal
14-12-2005, 06:17 PM
help...i need help...

can anybody can say me how to position an SDL window
in freepascal ...MoveSDLwindow(x,y) ?

i can't arrive to do it , except with
SDL_VIDEO_WINDOW_POS under shell
but that is not a good solution...

thanks a lot ...
very important for my project ...
:x

technomage
14-12-2005, 07:24 PM
The SDL_VIDEO_WINDOW_POS is the best solution for that. But don't do it manually in the shell. Use the function

SDL_putenv

at the start of you application to set the SDL_VIDEO_WINDOW_POS environment variable. This way you don't have to do it manually in a shell script. It should work under windows as well.

Dean

cragwolf
09-05-2006, 06:49 AM
Actually, I just tried this in Windows and it didn't work. It works fine in Linux. So then what I did was manually set the SDL_VIDEO_WINDOW_POS environment variable via Control Panel-System-Environment Variables and then rebooted my system. Then when I ran my program it placed the window in the position I entered in the environment variable value. Only, what it actually did was place the client-area in the desired position, not the window itself. I chose 10,10, so the top part of the window, i.e. the window caption bar, was off the screen. Weird. But anyway it seems that the SDL_putenv function doesn't work in Windows, at least with my version of the SDL library (1.2.9).

grudzio
10-05-2006, 11:00 AM
You can use SDL_GetWMInfo. It should return window manager specific information (according to SDL docs). In Windows it returns window handle,
so you can use Win API to set position of your window. I suppose the same can be done under linux with some X - Window calls.

cragwolf
11-05-2006, 02:22 AM
If using SDL_GetWMInfo and MoveWindow (or XMoveWindow for X), the window firstly shows up at some position decided by the window manager, and then it moves to your desired position. For me, this is an annoying cosmetic problem that I would prefer to avoid. Using SDL_putenv and SDL_VIDEO_WINDOW_POS avoids this problem, but unfortunately this technique doesn't seem to work on win32 (at least on my system). I'm not too worried by this, because my concern for win32 support is secondary to making sure my stuff works on linux. :) But I thought I would raise this issue to see if anybody knows of a solution. Thanks for the suggestion.

technomage
11-05-2006, 09:14 AM
It's odd the the POS env variable does not work , I know SDL_VIDEO_CENTERED does work as I have used this on some demos, and it works on Windows. I'll have a look into the SDL_VIDEO_WINDOW_POS, see if I can get it working on win 32.

grudzio
11-05-2006, 11:55 AM
There is a comment in SDL docs, that on win32 SDL_VIDEO_CENTERED should be set before sdl window is created. Maybe this is the same issue with SDL_VIDEO_POS? Anyway, we can use fullscreen mode and the problem is gone. Or better to say - covered :D

technomage
12-05-2006, 08:43 PM
There is a comment in SDL docs, that on win32 SDL_VIDEO_CENTERED should be set before sdl window is created. Maybe this is the same issue with SDL_VIDEO_POS? Anyway, we can use fullscreen mode and the problem is gone. Or better to say - covered :D

I would say yes for certain. I would assume that SDL reads the environment variables on initialization of the window and not each "tick".