src/video/windows/SDL_windowswindow.c
changeset 6782 582d35419e8a
parent 6662 698c2e533a7e
child 6784 8fd20f04d5d9
     1.1 --- a/src/video/windows/SDL_windowswindow.c	Sun Dec 30 19:05:50 2012 -0800
     1.2 +++ b/src/video/windows/SDL_windowswindow.c	Mon Dec 31 09:30:15 2012 -0800
     1.3 @@ -28,6 +28,7 @@
     1.4  
     1.5  #include "SDL_windowsvideo.h"
     1.6  #include "SDL_windowswindow.h"
     1.7 +#include "SDL_hints.h"
     1.8  
     1.9  /* Dropfile support */
    1.10  #include <shellapi.h>
    1.11 @@ -73,6 +74,22 @@
    1.12      return style;
    1.13  }
    1.14  
    1.15 +static SDL_bool
    1.16 +ShouldAllowTopMost()
    1.17 +{
    1.18 +    const char *hint;
    1.19 +
    1.20 +    /* If the user has specified a software renderer we can't use a
    1.21 +       texture framebuffer, or renderer creation will go recursive.
    1.22 +     */
    1.23 +    hint = SDL_GetHint(SDL_HINT_ALLOW_TOPMOST);
    1.24 +    if (hint && hint[0] == '0' ) {
    1.25 +        return SDL_FALSE;
    1.26 +    }
    1.27 +
    1.28 +	return SDL_TRUE;
    1.29 +}
    1.30 +
    1.31  static int
    1.32  SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
    1.33  {
    1.34 @@ -354,8 +371,8 @@
    1.35      int w, h;
    1.36  
    1.37      /* Figure out what the window area will be */
    1.38 -    if (window->flags & SDL_WINDOW_FULLSCREEN) {
    1.39 -        top = HWND_TOPMOST;
    1.40 +    if ( ShouldAllowTopMost() && (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS)) == (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS )) {
    1.41 +		top = HWND_TOPMOST;
    1.42      } else {
    1.43          top = HWND_NOTOPMOST;
    1.44      }
    1.45 @@ -406,11 +423,11 @@
    1.46      HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
    1.47      HWND top;
    1.48  
    1.49 -    if (window->flags & SDL_WINDOW_FULLSCREEN) {
    1.50 -        top = HWND_TOPMOST;
    1.51 -    } else {
    1.52 -        top = HWND_NOTOPMOST;
    1.53 -    }
    1.54 +	if ( ShouldAllowTopMost() && (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS)) == (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS )) {
    1.55 +		top = HWND_TOPMOST;
    1.56 +	} else {
    1.57 +		top = HWND_NOTOPMOST;
    1.58 +	}
    1.59      SetWindowPos(hwnd, top, 0, 0, 0, 0, (SWP_NOMOVE | SWP_NOSIZE));
    1.60  }
    1.61  
    1.62 @@ -467,11 +484,12 @@
    1.63      int x, y;
    1.64      int w, h;
    1.65  
    1.66 -    if (fullscreen) {
    1.67 -        top = HWND_TOPMOST;
    1.68 -    } else {
    1.69 -        top = HWND_NOTOPMOST;
    1.70 -    }
    1.71 +	if ( ShouldAllowTopMost() && (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS)) == (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS )) {
    1.72 +		top = HWND_TOPMOST;
    1.73 +	} else {
    1.74 +		top = HWND_NOTOPMOST;
    1.75 +	}
    1.76 +
    1.77      style = GetWindowLong(hwnd, GWL_STYLE);
    1.78      style &= ~STYLE_MASK;
    1.79      style |= GetWindowStyle(window);
    1.80 @@ -551,6 +569,23 @@
    1.81      } else {
    1.82          ClipCursor(NULL);
    1.83      }
    1.84 +
    1.85 +	if ( window->flags & SDL_WINDOW_FULLSCREEN )
    1.86 +	{
    1.87 +		HWND top;
    1.88 +		SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    1.89 +		HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
    1.90 +		UINT flags = SWP_NOMOVE | SWP_NOSIZE;
    1.91 +
    1.92 +		if ( ShouldAllowTopMost() && (window->flags & SDL_WINDOW_INPUT_FOCUS ) ) {
    1.93 +			top = HWND_TOPMOST;
    1.94 +		} else {
    1.95 +			top = HWND_NOTOPMOST;
    1.96 +			flags |= SWP_NOZORDER;
    1.97 +		}
    1.98 +		
    1.99 +		SetWindowPos(hwnd, top, 0, 0, 0, 0, flags);
   1.100 +	}
   1.101  }
   1.102  
   1.103  void