Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On Windows, in SDL 3.2.8, there is a delay in updating the rendering viewport after minimizing multiple windows. #12525

Open
pipiwoaini opened this issue Mar 12, 2025 · 1 comment

Comments

@pipiwoaini
Copy link

This test code reproduces a bug where minimizing window, maximizing window1, and then restoring window causes a delay in updating the rendering viewport of window.

int main(int argc, char* argv[]) {
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* window = SDL_CreateWindow("SDL", 640.00f, 540.00f, SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS | SDL_WINDOW_TRANSPARENT);

SDL_PropertiesID m_props = SDL_CreateProperties();
SDL_SetPointerProperty(m_props, SDL_PROP_RENDERER_CREATE_WINDOW_POINTER, window);
SDL_SetNumberProperty(m_props, SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER, SDL_COLORSPACE_SRGB);
SDL_SetNumberProperty(m_props, SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER, 2); 
SDL_SetStringProperty(m_props, SDL_PROP_RENDERER_CREATE_NAME_STRING, "direct3d11");

SDL_Renderer* renderer = SDL_CreateRendererWithProperties(m_props);
if (!renderer) {
	std::cerr << "SDL_CreateRenderer Error: " << SDL_GetError() << std::endl;
	SDL_DestroyWindow(window);
	SDL_Quit();
	return 1;
}

SDL_Window* window1 = SDL_CreateWindow("SDL1", 640.00f, 540.00f, SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS | SDL_WINDOW_TRANSPARENT);

SDL_PropertiesID m_props1 = SDL_CreateProperties();
SDL_SetPointerProperty(m_props1, SDL_PROP_RENDERER_CREATE_WINDOW_POINTER, window1);
SDL_SetNumberProperty(m_props1, SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER, SDL_COLORSPACE_SRGB);
SDL_SetNumberProperty(m_props1, SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER, 2); 
SDL_SetStringProperty(m_props1, SDL_PROP_RENDERER_CREATE_NAME_STRING, "direct3d11");

SDL_Renderer* renderer1 = SDL_CreateRendererWithProperties(m_props1);
if (!renderer1) {
	std::cerr << "SDL_CreateRenderer Error: " << SDL_GetError() << std::endl;
	SDL_DestroyWindow(window);
	SDL_Quit();
	return 1;
}

SDL_MinimizeWindow(window);
SDL_MaximizeWindow(window1);
SDL_RestoreWindow(window);
//SDL_RestoreWindow(window1);

bool running = true;
SDL_Rect t_rect;
SDL_Event event;
while (running) {
	while (SDL_PollEvent(&event)) {
		if (event.type == SDL_EVENT_WINDOW_RESTORED) {
			if (window == SDL_GetWindowFromEvent(&event)) {
				SDL_Rect t_rect;
				SDL_GetRenderViewport(renderer, &t_rect);
				printf("SDL_EVENT_WINDOW_RESTORED %d %d %d %d\n", t_rect.x, t_rect.y, t_rect.w, t_rect.h);
				SDL_GetWindowSize(window, &t_rect.w, &t_rect.h);
				printf("SDL_GetWindowSize %d %d\n", t_rect.w, t_rect.h);
			}
		}
	}

	SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);
	SDL_RenderClear(renderer);
	SDL_RenderPresent(renderer);

	SDL_SetRenderDrawColor(renderer1, 0, 0, 255, 255);
	SDL_RenderClear(renderer1);
	SDL_RenderPresent(renderer1);
}

SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();

return 0;

}

@pipiwoaini
Copy link
Author

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant