[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - SetForegroundWindow not reliable on Win 7

SetForegroundWindow not reliable on Win 7

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

SetForegroundWindow not reliable on Win 7

Postby Baker » Fri Jun 15, 2012 5:09 am

Windows 7 security prevents Windows from making themselves the active app except under specific circumstance. This isn't a workaround for this and if there is, it shouldn't be used.

http://msdn.microsoft.com/en-us/library ... 85%29.aspx

The annoying behavior this can cause is if you switch to another Window while an engine is loading, the engine assumes that SetForegroundWindow will give it focus and do things with the mouse movement clipping and so forth.

The solution would be for engines to not assume they have the focus during mouse and video initialization and check to see if is Foreground window ( http://msdn.microsoft.com/en-us/library ... 85%29.aspx ). Maybe. There might be a better way looking at system messages and stuff.

This isn't that much of an annoyance, but upon discovery it is a bit perturbing.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: SetForegroundWindow not reliable on Win 7

Postby Spike » Fri Jun 15, 2012 9:20 pm

you should still get a WM_FOCUS or whatever it is message whether you're programmatically forcing focus or not.
the pain is with fullscreen apps.

fte suffers from this a lot. I'm hoping that a large part of that is 'just' because I'm usually running it in a debugger with lots of dlls being checked for debug info every single time its started...
But yeah, attempting to steal mouse input when you don't even have focus is a nasty side effect.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: SetForegroundWindow not reliable on Win 7

Postby mh » Sat Jun 16, 2012 12:19 am

User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: SetForegroundWindow not reliable on Win 7

Postby Baker » Wed Jul 11, 2012 11:11 pm

The only "pain" I suffer from this problem now is on video mode switch (single pass video startup largely eliminated the issue).

I've been thinking and I have what might be a solution:

1. On video mode change, release everything but do not do DestroyWindow.
2. Instead of doing CreateWindowEx, just resize the existing one.

Haven't tried this yet. But in theory, since the same window is continuously active there shouldn't be a loss of "focus" from the perspective of Windows 7.

What I think happens is after DestroyWindow, the operating system tries to "think" about what to do. Then the new create window doesn't receive "focus" and isn't the receiver of input events. If I skip the DestroyWindow/CreateWindowEx the aggravation might go away (having some other window in front of the Quake window).

/May try to decompose those styles to see what all the settings are if those work well.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: SetForegroundWindow not reliable on Win 7

Postby Spike » Wed Jul 11, 2012 11:42 pm

logically there's no need to destroy the window on mode changes.

on xp, you might find you have dodgy stuff going on when you resize the window without recreating the context, but vista no longer corrupts the video/texture memory randomly, so anything vista onwards should be fine with just resizing the window. No loss of focus, no loss of textures that then need reuploading etc.
the issue there, however, is that there are many reasons to do a vid_restart other than just a video mode change, and many of them are most easily implemented by letting the driver blow everything away for you, so recreating the gl context is still useful.
maybe add a vid_resize command that skips context destruction.

but you're correct. even if you do destroy the context, you don't have to destroy the window too (including on xp), and thus shouldn't loose focus.
You can still fail to gain focus at window creation time, however.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: SetForegroundWindow not reliable on Win 7

Postby Baker » Wed Jul 11, 2012 11:52 pm

The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: SetForegroundWindow not reliable on Win 7

Postby mh » Thu Jul 12, 2012 12:04 am

I'm just so happy that D3D handles all of this automatically for me. :)

And with 11 there's no more D3DERR_DEVICELOST either. :) :)
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: SetForegroundWindow not reliable on Win 7

Postby Baker » Fri Jul 13, 2012 5:43 am

The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 2 guests