mirror of
				https://github.com/libsdl-org/SDL.git
				synced 2025-11-03 17:24:34 +00:00 
			
		
		
		
	Fix SDL not resizing window when Android screen resolution changes
This commit is contained in:
		@@ -194,7 +194,6 @@ Android_VideoQuit(_THIS)
 | 
			
		||||
    Android_QuitTouch();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* This function gets called before VideoInit() */
 | 
			
		||||
void
 | 
			
		||||
Android_SetScreenResolution(int width, int height, Uint32 format, float rate)
 | 
			
		||||
{
 | 
			
		||||
@@ -203,6 +202,22 @@ Android_SetScreenResolution(int width, int height, Uint32 format, float rate)
 | 
			
		||||
    Android_ScreenFormat = format;
 | 
			
		||||
    Android_ScreenRate = rate;
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
      Update the resolution of the desktop mode, so that the window
 | 
			
		||||
      can be properly resized. The screen resolution change can for
 | 
			
		||||
      example happen when the Activity enters or exists immersive mode,
 | 
			
		||||
      which can happen after VideoInit().
 | 
			
		||||
    */
 | 
			
		||||
    SDL_VideoDevice* device = SDL_GetVideoDevice();
 | 
			
		||||
    if (device && device->num_displays > 0)
 | 
			
		||||
    {
 | 
			
		||||
        SDL_VideoDisplay* display = &device->displays[0];
 | 
			
		||||
        display->desktop_mode.format = Android_ScreenFormat;
 | 
			
		||||
        display->desktop_mode.w = Android_ScreenWidth;
 | 
			
		||||
        display->desktop_mode.h = Android_ScreenHeight;
 | 
			
		||||
        display->desktop_mode.refresh_rate  = Android_ScreenRate;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (Android_Window) {
 | 
			
		||||
        SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, width, height);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user