Vista powersaves mid-game and messes up

BlitzMax Forums/BlitzMax Programming/Vista powersaves mid-game and messes up

Grey Alien(Posted 2007) [#1]
One of the testers for my game reported this:

"While game is in fullscreen or active application, the machine shouldn't enter powersaver mode in Vista (Xp functioned correctly). However both failed when they were in windowed mode and active application, screensaver would start.

Also, in Vista, after resuming from powersaver mode, game had closed down and desktop resolution was reset to 800X600. "

Anyone come across this before? Perhaps there is a way to let windows know not to screensave and not to powersave?


Grey Alien(Posted 2007) [#2]
Let me clarify this, there are two issues:

1) Is it possible to prevent powersaving in Vista when the app is full-screen or windowed? If not, then is it possible to prevent the crash on returning from power saving mode (I may need to write a simple test app to see if it's some piece of complex code in my game crashing on return from power save, or if it's something very simple that can be shown up with a basic graphics window).

2) Is it possible to stop the windows screensaver from coming up if your game is active (in windowed mode - I think it doesn't come up already in full-screen mode). This issue is not vital in my opinion.

Thanks all for any help :-)


DStastny(Posted 2007) [#3]
I cant remember off the top of my head but your application needs to handle WM_POWERSAVE or something like. I am on vacation and cant really access the source that I need. But you will need to modify the source or get mark to of the core windows message pump to handle.

Doug Stastny


Gabriel(Posted 2007) [#4]
2) Yes, but you need to be handling the windows message pump yourself, as Budman already mentioned. You need to monitor for WM_SYSCOMMAND and if you get one, check if it's the SC_SCREENSAVE message. When this happens, this basically Windows saying "Hey, I think I'm gonna start the screensaver now. Do you mind?" If you return True from your WndProc, you're saying you don't mind. If you mind, you return False.

I guess BlitzMax needs a DisableScreensaver() and EnableScreensaver() pair of functions, because I don't think you can do this without creating your own window and managing it, which I'm guessing would be incompatible with your framework, and if Mark just sets BMax to tell the screensaver not to start always, he'll get complaints from people who don't want their applications stopping the screensaver.

Personally, I think it's a bad practice to disable the screensaver in an application, but a bad practice *not* to disable it in a game. I hate when games don't disable the screensaver. Only on the rare occasion I've reformatted and not completely disabled it, of course, but still. Don't like it.


skidracer(Posted 2007) [#5]
Win32 OpenGL was fixed along time ago so joystick players didn't suffer from this problem, perhaps the dx window message pump needs the fix also, from glgraphics.win32.c[86]:
	case WM_SYSCOMMAND:
		if (wp==SC_SCREENSAVE) return 1;
		if (wp==SC_MONITORPOWER) return 1;
		break;




Grey Alien(Posted 2007) [#6]
sounds like a good solution. Who is in chare of the dx code? Can they make it standard? And this deals with the power save issue too right? I mean is SC_MONITORPOWER the main power saving flag that will kick in when power saving kicks in or are there others?

Thanks


Grey Alien(Posted 2007) [#7]
Can anyone at BRL implement this then please? Thanks