True borderless fullscreen behaviour


#1

Here’s the problem, I initialise my window as a normal window, then upon a certain keypress I call SDL_SetWindowFullscreen(fb.window, SDL_WINDOW_FULLSCREEN_DESKTOP);, which switches to fullscreen. Except it doesn’t work quite as it should. Here’s what it does:

-Flash both screens to black
-Set it to fullscreen on the main screen (as desired)
when I click on the secondary screen (where let’s say I have a web browser open):
-Flashes both screens to black again
-My SDL window disappears from the main screen (which it shouldn’t) and what is shown (the other programs in the background) has compositing issues, like GUI elements being black (apparently a normal Windows compositing bug related to having something in fullscreen)
when I switch back to my SDL program:
-Black flash again from switching to fullscreen (but not as bad as when you use true fullscreen)
-Compositing on the secondary screen is all screwed up and stays really screwed up until I switch back out of my SDL program

My point is this doesn’t behave like a true borderless window fullscreen mode in which the switch between programs is seamless. The way it currently works isn’t it, it’s some kind of fullscreen mode. So how can I obtain the desired behaviour? Not using SDL_SetWindowFullscreen() and instead using SDL_SetWindowResizable(), SDL_SetWindowBordered(), SDL_SetWindowPosition() and SDL_SetWindowSize() to the screen’s size give the same result, it seems that if you try to make a borderless window that is the size of the screen then it switches to a fullscreen mode even though that’s specifically what I don’t want.

I’m using OpenGL on Windows 7 with SDL 2.0.8.


#2

Does it work if you create the window as fullscreen from the beginning?


#3

I just tried initialising with the flags SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_OPENGL in SDL_CreateWindow() and the problem is the same.


#4

Try SDL_WINDOW_FULLSCREEN instead.


#5

It’s worse since it does the resolution switching thing (even though the resolution doesn’t change).


#6

Ok, but does it still turn the other monitor black?


#7

Yes.

(Okay this is ridiculous but this thing won’t just let me reply with “Yes” because it’s not enough characters.)


#8

Ok, so I tried an older application on mine and I used: window=SDL_CreateWindow(“1 million particles”, 100, 100, windows_x_len, windows_y_len, SDL_WINDOW_FULLSCREEN_DESKTOP);

I got an effect similar to what you described, but not the same. The app was full screen on my main monitor, and the other monitor was left alone. However I think there might have been a problem with the mouse coordinates.

When I clicked on the other monitor, the app window was minimized, but when I clicked back on the taskbar it went back to full screen mode.


#9

I bet not everyone has the same compositing glitches as I have, but it says something about how the fullscreen mode is achieved (for instance it depends on games, though these days most games do it properly). A way to do it manually is like this:

SDL_SetWindowResizable(fb.window, SDL_FALSE);
SDL_SetWindowBordered(fb.window, SDL_FALSE);
SDL_SetWindowPosition(fb.window, 0, 0);
SDL_SetWindowSize(fb.window, sdl_get_display_dim(0).x, sdl_get_display_dim(0).y);

If you use the screen resolution in the SDL_SetWindowSize() call then it’s as if using SDL_WINDOW_FULLSCREEN_DESKTOP, however if you set a smaller size then you get the proper result, which is a borderless window (but obviously that doesn’t take up the full screen) that doesn’t do any of the glitches mentioned. So there’s definitely something being done when the window dimensions are detected to be those of the screen resolution.


#10

I am now on Windows 10 and while I don’t have flashes or compositing problems anymore I can confirm that it also minimises itself when I click on the second screen outside of my SDL app. This is pretty inconvenient, I can’t find a way to change that behaviour.