How to check if a window is fullscreen?


I’m wondering if there is a simple “true-false” type return function in SDL which gives information about fullscreen status of a window? I.e. something like

SDL_IsWindowFullscreen(SDL_Window* window)

I couldn’t seem to find anything directly related to this? The only other way I can think of is manually checking the window dimensions against maximum screen dimensions. But I’d like to avoid that if SDL offers a direct method of querying.


I think I’ve find a solution (not sure how good it is), by using SDL_GetWindowFlags and some bitwise logic:

	auto flag = SDL_GetWindowFlags(window);
	auto is_fullscreen  = flag&SDL_WINDOW_FULLSCREEN;
	if(is_fullscreen == SDL_WINDOW_FULLSCREEN){
		//is fullscreen

Seems to work. But any other ways which have better syntax are welcome !:slight_smile:

See SDL_GetWindowFlags - SDL Wiki

Uint32 windowFlags = SDL_GetWindowFlags(window);
    printf("Window using desktop fullscreen mode\n");
} else if((windowFlags & SDL_WINDOW_FULLSCREEN) {
    printf("Window using normal fullscreen mode\n");
} else { // (windowFlags & SDL_WINDOW_FULLSCREEN) == 0
    printf("Window in windowed mode\n");

Note that SDL_WINDOW_FULLSCREEN_DESKTOP has two bits set, the one of SDL_WINDOW_FULLSCREEN and another one to tell it apart from “normal” fullscreen mode, so the full check for “normal” fullscreen (if it’s not an else-case of an if checking for windowed fullscreen) would be if( (windowFlags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN)

After all, you set the fullscreen mode, so without any special functions, you should know if you did …

1 Like

@ROSY Saves me having to store my own vars and make functions to see what the user did to fullscreen mode. It’s more practical to have a one-liner in SDL which does all this :wink:

Thanks very much for the explanation! :slight_smile:

You’re right, it’s a pity 1 byte. Better to combine with some functions, it’s very practical …:wink:

@ROSY it wouldn’t make sense to add an extra “1 byte”, if it’s already done by SDL. Implementing extra code and checks, which are already provided by SDL (like SDL_GetWindowFlags), doesn’t make much sense (unless you have a good reason to do so, which I don’t) :slight_smile: