Restore original screen resolution after fullscreen?

Hi, I’m using Xfree86 with Debian linux, and if I create a fullscreen
window with SDL_SetVideoMode(screen_width, screen_height, 24,
SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN | SDL_NOFRAME);

The screen loads up and works well. I run my desktop in 1024x768
resolution. If the fullscreen that I load up in SDL is different than
this, like 640x480, then when I exit the window, at which time I call
SDL_QuitSubSystem(SDL_INIT_VIDEO), SDL does not restore my desktop
resolution back to 1024x768, but keeps it at whatever my fullscreen was,
such as 640x480. Even after I completely exit my program, if
I want to restore my desktop resolution, I have to run my SDL program and
have it open up a fullscreen at 1024x768. Then when I exit it stays at
1024x768.

Now, in order to fix this I either need to know some function or trick I
can do, or I at least need to know how to find the desktop resolution so
that I can resize the fullscreen to it automatically on exit.

Thank you,
Matt

Hi, I’m using Xfree86 with Debian linux, and if I create a fullscreen
window with SDL_SetVideoMode(screen_width, screen_height, 24,
SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN | SDL_NOFRAME);
Now, in order to fix this I either need to know some function or trick I
can do, or I at least need to know how to find the desktop resolution so
that I can resize the fullscreen to it automatically on exit.

What you do seems correct to me.

When I want to quit my program I usually just call SDL_Quit() and
exit(0). It’s not clean, but it works perfectly well, restores my
desktop to the right resolution.

The problem may be more in your X server configuration or graphic’s
drivers. Unless something else in your code creates the problem.

PS: You may drop SDL_NOFRAME, fullscreen implies no frame.

HTH, Simon

FWIW, I have apps that dynamically switch to full screen
mode. They work fine switching in and out whilst the app
is running, and also switch back to desktop correctly
even when SDL terminates in full screen mode.

Using Debian based system: Ubuntu Breezy. If I understand
correctly that’s NOT using Xfree86 but Xorg (but I’m not
any kind of expert on that). If so perhaps that helps
narrow down the problem.On Mon, 2006-03-13 at 23:27 -0500, Matthew David Parker wrote:

Hi, I’m using Xfree86 with Debian linux

The screen loads up and works well. I run my desktop in 1024x768
resolution. If the fullscreen that I load up in SDL is different than
this, like 640x480, then when I exit the window, at which time I call
SDL_QuitSubSystem(SDL_INIT_VIDEO), SDL does not restore my desktop
resolution back to 1024x768,


John Skaller
Async PL, Realtime software consultants
Checkout Felix: http://felix.sourceforge.net

Using Debian based system: Ubuntu Breezy. If I understand
correctly that’s NOT using Xfree86 but Xorg (but I’m not
any kind of expert on that). If so perhaps that helps
narrow down the problem.

I’m programming on two different PCs with Win2000, WinXP and Linux:
Slackware (which uses Xorg). I get exactly the same results (except
of course, windows doesn’t like opengl resizes) on all platforms.

Xorg works fine, but it may be misconfigured… it may also be an
issue with the window manager, but I’m no expert on this either…

Good luck!
Simon

OK, I think my problem may have had something to do with loading the SDL
window from a scheme interpreter. I fixed it by dynamically switching
back to a window mode using SDL_SetVideoMode right before I shut down the
video subsystem.

Thanks for your suggestion,
MattOn Tue, 14 Mar 2006, skaller wrote:

On Mon, 2006-03-13 at 23:27 -0500, Matthew David Parker wrote:

Hi, I’m using Xfree86 with Debian linux

The screen loads up and works well. I run my desktop in 1024x768
resolution. If the fullscreen that I load up in SDL is different than
this, like 640x480, then when I exit the window, at which time I call
SDL_QuitSubSystem(SDL_INIT_VIDEO), SDL does not restore my desktop
resolution back to 1024x768,

FWIW, I have apps that dynamically switch to full screen
mode. They work fine switching in and out whilst the app
is running, and also switch back to desktop correctly
even when SDL terminates in full screen mode.

Using Debian based system: Ubuntu Breezy. If I understand
correctly that’s NOT using Xfree86 but Xorg (but I’m not
any kind of expert on that). If so perhaps that helps
narrow down the problem.


John Skaller
Async PL, Realtime software consultants
Checkout Felix: http://felix.sourceforge.net


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

On Linux … why would that matter? I’m also dynamically
loading SDL … from Felix flx_run driver. SDL embeds
on Linux, no mainline stuff is needed. My code is also C++ not C.On Tue, 2006-03-14 at 12:36 -0500, Matthew David Parker wrote:

OK, I think my problem may have had something to do with loading the SDL
window from a scheme interpreter.


John Skaller
Async PL, Realtime software consultants
Checkout Felix: http://felix.sourceforge.net

Hello skaller,

Tuesday, March 14, 2006, 6:29:01 PM, you wrote:

s> On Tue, 2006-03-14 at 12:36 -0500, Matthew David Parker wrote:

OK, I think my problem may have had something to do with loading the SDL
window from a scheme interpreter.

s> On Linux … why would that matter? I’m also dynamically
s> loading SDL … from Felix flx_run driver. SDL embeds
s> on Linux, no mainline stuff is needed. My code is also C++ not C.

It sounds like to me that SDL_Quit is not being called. The only time
i ever had issues on Ubuntu with SDL not restoring the display was
when my crash handler wasn’t calling SDL_Quit.–
Best regards,
Peter mailto:@Peter_Mulholland

Well, I just looked a little further and the reason that mine didn’t
restore seems to be because I had opened the SDL window in a thread, and,
since you have to close the SDL window from that same thread, I just had a
loop in that thread that checked to see if a certain flag was set, and
when it was set, it would close. However, in my program that sets
the flag to quit, it immediately exited without delay after it set the
flag, so the SDL thread never had much chance to quit. Now I fixed that,
but still I have to
reset the screen to windowed mode before I exit or else it gives me a
segmentation fault, though it does reset the screen back to the original
desktop resolution properly.

MattOn Tue, 14 Mar 2006, Peter Mulholland wrote:

Hello skaller,

Tuesday, March 14, 2006, 6:29:01 PM, you wrote:

s> On Tue, 2006-03-14 at 12:36 -0500, Matthew David Parker wrote:

OK, I think my problem may have had something to do with loading the SDL
window from a scheme interpreter.

s> On Linux … why would that matter? I’m also dynamically
s> loading SDL … from Felix flx_run driver. SDL embeds
s> on Linux, no mainline stuff is needed. My code is also C++ not C.

It sounds like to me that SDL_Quit is not being called. The only time
i ever had issues on Ubuntu with SDL not restoring the display was
when my crash handler wasn’t calling SDL_Quit.


Best regards,
Peter mailto:darkmatter at freeuk.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

By “close the SDL window”, are you talking about calling SDL_Quit?
Like another person mentioned, if an app crashes before SDL_Quit can get
called, your fullscreen app can cause X to remain ‘stuck’ at the app’s
(usually lower) resolution.

-bill!On Tue, Mar 14, 2006 at 02:23:29PM -0500, Matthew David Parker wrote:

Well, I just looked a little further and the reason that mine didn’t
restore seems to be because I had opened the SDL window in a thread, and,
since you have to close the SDL window from that same thread,

Oh, I mean I close the SDL fullscreen, and I don’t call SDL_Quit, I just
call SDL_QuitSubSystem(SDL_INIT_VIDEO) because I still want the audio
portion to be available. This way I can open up another window if I want
too. This isn’t for a particular program, but I’m making an SDL interface
to scheme, so my user’s may want to close and reopen windows.

MattOn Tue, 14 Mar 2006, Bill Kendrick wrote:

On Tue, Mar 14, 2006 at 02:23:29PM -0500, Matthew David Parker wrote:

Well, I just looked a little further and the reason that mine didn’t
restore seems to be because I had opened the SDL window in a thread, and,
since you have to close the SDL window from that same thread,

By “close the SDL window”, are you talking about calling SDL_Quit?
Like another person mentioned, if an app crashes before SDL_Quit can get
called, your fullscreen app can cause X to remain ‘stuck’ at the app’s
(usually lower) resolution.

-bill!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl