Jump to content
  • Advertisement
Sign in to follow this  
mkelly4ca

Handling Loss of Focus in a Fullscreen App

This topic is 3496 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My app runs in fullscreen mode. When I alt-tab or click on another window (on another monitor) I lose focus and lose the device. I wait for TestCooperativeLevel to return D3DERR_DEVICENOTRESET and then call Reset. This works fine if I'm not changing the monitor's resolution. But if I am, then after my Reset call changes the monitor's resolution, other windows start updating, and they get focus for a moment, causing my app to once again be deactivated and minimized. The Direct3d samples have this same behavior. What can I do to work around this problem? Thanks, Mike.

Share this post


Link to post
Share on other sites
Advertisement
A few things to try:

Don't panic, but also realize that this is probably the single most annoying part of programming a d3d app. Direct3D + Windows message pump + fullscreen + either device lost or resize or mode switch = pure pain.

Manually spin a windows message pump loop until its empty before doing the reset.

Make sure all message pumps dispatch all messages, if you swallow some of them up direct3d breaks in mysterious ways.

For all the major game breaking events (resize, mode switch, focus lost, device lost) make sure the messages are being handled intelligently. Some of them can fight each other (a resizing mode switch for instance), and the messages do not all necessarily come in in the exact order that is nice to handle correctly either.

Share this post


Link to post
Share on other sites
Thanks! I solved the problem already by simulating a mouse click in my window after my reset, but that's a bit of a hack, and will probably not always work. Your solution sounds much better. :-) I'll give that a try.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!