src/video/SDL_video.c
changeset 7953 255ca6c77e58
parent 7950 85dc78d922db
child 7954 712d8544f8a1
equal deleted inserted replaced
7952:5ac1a895b313 7953:255ca6c77e58
  2132     }
  2132     }
  2133 
  2133 
  2134     SDL_UpdateWindowGrab(window);
  2134     SDL_UpdateWindowGrab(window);
  2135 }
  2135 }
  2136 
  2136 
  2137 static SDL_bool ShouldMinimizeOnFocusLoss()
  2137 static SDL_bool
  2138 {
  2138 ShouldMinimizeOnFocusLoss(SDL_Window * window)
       
  2139 {
       
  2140     SDL_bool default_minimize;
       
  2141 
       
  2142     if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
       
  2143         return SDL_FALSE;
       
  2144     }
       
  2145 
       
  2146     if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
       
  2147         /* We're not doing a mode switch, so it's okay to stay around */
       
  2148         default_minimize = SDL_FALSE;
       
  2149     } else {
       
  2150         default_minimize = SDL_TRUE;
       
  2151     }
       
  2152 
  2139     const char *hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS);
  2153     const char *hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS);
  2140     if (hint) {
  2154     if (hint) {
  2141         if (*hint == '0') {
  2155         if (*hint == '0') {
  2142             return SDL_FALSE;
  2156             return SDL_FALSE;
  2143         } else {
  2157         } else {
  2144             return SDL_TRUE;
  2158             return SDL_TRUE;
  2145         }
  2159         }
  2146     }
  2160     }
  2147     return SDL_TRUE;
  2161 
       
  2162     return default_minimize;
  2148 }
  2163 }
  2149 
  2164 
  2150 void
  2165 void
  2151 SDL_OnWindowFocusLost(SDL_Window * window)
  2166 SDL_OnWindowFocusLost(SDL_Window * window)
  2152 {
  2167 {
  2154         _this->SetWindowGammaRamp(_this, window, window->saved_gamma);
  2169         _this->SetWindowGammaRamp(_this, window, window->saved_gamma);
  2155     }
  2170     }
  2156 
  2171 
  2157     SDL_UpdateWindowGrab(window);
  2172     SDL_UpdateWindowGrab(window);
  2158 
  2173 
  2159     /* If we're fullscreen and lose focus, minimize unless the hint tells us otherwise */
  2174     if (ShouldMinimizeOnFocusLoss(window)) {
  2160     if ((window->flags & SDL_WINDOW_FULLSCREEN) && ShouldMinimizeOnFocusLoss()) {
       
  2161         SDL_MinimizeWindow(window);
  2175         SDL_MinimizeWindow(window);
  2162     }
  2176     }
  2163 }
  2177 }
  2164 
  2178 
  2165 SDL_Window *
  2179 SDL_Window *