SDL2 Fullscreen Oddities on linux

I’m trying to use SDL2 in my future game ports (Improved keyboard support, window control, and separation of GL context creation are BIG wins for me on this), however fullscreen support seems to be utterly broken in SDL2.

I have the issue described here http://bugzilla.libsdl.org/show_bug.cgi?id=1571 where the users desktop resolution does not restore. A workaround seems to be disabling Xinerama support and making sure I position the window @ 0,0 when creating it. Other issues that have been reported are issues with Ubuntu’s Unity desktop where the resolution will change but the window will not go properly into full-screen mode.

In an ideal world (and ideal API) I would like to query both monitors independently (i.e. Xinerama give me this) and allow the user to choose which monitor goes full-screen (kinda like we did back in SDL1.2 via the SDL_VIDEO_FULLSCREEN_DISPLAY env var). There seems to be no API to choose which “display” I make the window go fullscreen on? (unless I am missing something)…

The game that is having all of these lovely issues is Torchlight in the current humble bundle. I’m going to try my “disabling” xinerama and set position hacks to see if that resolves many of the issues. but it seems there are some more serious deep rooted issues in the fullscreen code in SDL2 that need some major cleanup… Any insight into the code there would be grateful as I will most likely be digging into this mess as I plan on using SDL2 still for 6 more game ports over the next few months.

2012/9/23 urkle

**
I’m trying to use SDL2 in my future game ports (Improved keyboard support,
window control, and separation of GL context creation are BIG wins for me
on this), however fullscreen support seems to be utterly broken in SDL2.

I have the issue described here
Desktop resolution not restored when destroying window · Issue #639 · libsdl-org/SDL · GitHub where the users desktop
resolution does not restore. A workaround seems to be disabling Xinerama
support and making sure I position the window @ 0,0 when creating it. Other
issues that have been reported are issues with Ubuntu’s Unity desktop where
the resolution will change but the window will not go properly into
full-screen mode.

In an ideal world (and ideal API) I would like to query both monitors
independently (i.e. Xinerama give me this) and allow the user to choose
which monitor goes full-screen (kinda like we did back in SDL1.2 via the
SDL_VIDEO_FULLSCREEN_DISPLAY env var). There seems to be no API to choose
which “display” I make the window go fullscreen on? (unless I am missing
something)…

The game that is having all of these lovely issues is Torchlight in the
current humble bundle. I’m going to try my “disabling” xinerama and set
position hacks to see if that resolves many of the issues. but it seems
there are some more serious deep rooted issues in the fullscreen code in
SDL2 that need some major cleanup… Any insight into the code there would
be grateful as I will most likely be digging into this mess as I plan on
using SDL2 still for 6 more game ports over the next few months.

I’m using SDL2 under Ubuntu with Nvidia Twinview and it works very well on
fullscreen for me (you need fairly recent binary Nvidia drivers, as old
drivers didn’t had the proper Xrandr support). I contributed a few patches
for this issue a while back because it was really broken, and at least as
far as I can see it’s working fine (I can position my window full screen on
both monitors, regular windows across both screens, etc).
On a system with two monitors, you should get two video displays, one for
each monitor, and you select which display you want to be fullscreen at by
using the x,y position of the window and the SDL_WINDOWPOS_UNDEFINED_MASK
This is my window setup code (it’s Cython, but you may be able to get an
idea of what I’m doing anyway).

ndisplays = SDL_GetNumVideoDisplays()
if display > ndisplays-1:
display = 0
x = SDL_WINDOWPOS_UNDEFINED_MASK | display
y = SDL_WINDOWPOS_UNDEFINED_MASK | display
SDL_GetDesktopDisplayMode(display, &dm)
width = dm.w
height = dm.h
self.window = SDL_CreateWindow(“Ignifuga”,x, y,width, height,
SDL_WINDOW_FULLSCREEN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL)–
Gabriel.

2012/9/23 urkle <@Edward_Rudd>
I’m trying to use SDL2 in my future game ports (Improved keyboard support, window control, and separation of GL context creation are BIG wins for me on this), however fullscreen support seems to be utterly broken in SDL2.

I have the issue described here Desktop resolution not restored when destroying window · Issue #639 · libsdl-org/SDL · GitHub where the users desktop resolution does not restore. A workaround seems to be disabling Xinerama support and making sure I position the window @ 0,0 when creating it. Other issues that have been reported are issues with Ubuntu’s Unity desktop where the resolution will change but the window will not go properly into full-screen mode.

In an ideal world (and ideal API) I would like to query both monitors independently (i.e. Xinerama give me this) and allow the user to choose which monitor goes full-screen (kinda like we did back in SDL1.2 via the SDL_VIDEO_FULLSCREEN_DISPLAY env var). There seems to be no API to choose which “display” I make the window go fullscreen on? (unless I am missing something)…

The game that is having all of these lovely issues is Torchlight in the current humble bundle. I’m going to try my “disabling” xinerama and set position hacks to see if that resolves many of the issues. but it seems there are some more serious deep rooted issues in the fullscreen code in SDL2 that need some major cleanup… Any insight into the code there would be grateful as I will most likely be digging into this mess as I plan on using SDL2 still for 6 more game ports over the next few months.

I’m using SDL2 under Ubuntu with Nvidia Twinview and it works very well on fullscreen for me (you need fairly recent binary Nvidia drivers, as old drivers didn’t had the proper Xrandr support). I contributed a few patches for this issue a while back because it was really broken, and at least as far as I can see it’s working fine (I can position my window full screen on both monitors, regular windows across both screens, etc).
On a system with two monitors, you should get two video displays, one for each monitor, and you select which display you want to be fullscreen at by using the x,y position of the window and the SDL_WINDOWPOS_UNDEFINED_MASK
This is my window setup code (it’s Cython, but you may be able to get an idea of what I’m doing anyway).

ndisplays = SDL_GetNumVideoDisplays()
if display > ndisplays-1:
display = 0
x = SDL_WINDOWPOS_UNDEFINED_MASK | display
y = SDL_WINDOWPOS_UNDEFINED_MASK | display
SDL_GetDesktopDisplayMode(display, &dm)
width = dm.w
height = dm.h
self.window = SDL_CreateWindow(“Ignifuga”,x, y,width, height, SDL_WINDOW_FULLSCREEN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL)

Ahh, so that’s what those macros are for… Wouldn’t you just use the helper SDL_WINDOWPOS_UNDEFINED_DISPLAY(display) :). Oh way… Cython…

I am running the latest stable nvidia driver (304.37). Which one difference between what I’m doing and you, is that I have not been setting the resizable flag. Which that right there has been the cause of MUCH frustration among ubuntu users of Torchlight. I have actually put together a patch for this bug [Linux] Fullscreen window not going fullscreen · Issue #380 · libsdl-org/SDL · GitHub which works around Compiz’s “odd behavior” of not allowing a window to go fullscreen unless it is resizable.

However the issue I still have with enabling xinerama is that the desktop resolution does not restore. I have similar issues with SDL 1.2 and have xinerama disabled there as well. From further debugging into things… When SDL tries to restore the desktop resolution with Xinerama enabled it only tries to restore one monitor to it’s original resolution, not both. And for some reason that fails. The other difference between my code and your’s is you are changing to the Desktop resolution, where Torchlight isn’t always going to do that (if I go w/ the desktop resolution on my box everything works fine as well)

Thanks for the input and sample code.


Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Edward Rudd
OutOfOrder.cc
Skype: outoforder_cc
317-674-3296On Sep 27, 2012, at 9:24 , Gabriel Jacobo wrote:

2012/9/27 Edward Rudd

2012/9/23 urkle

**
I’m trying to use SDL2 in my future game ports (Improved keyboard
support, window control, and separation of GL context creation are BIG wins
for me on this), however fullscreen support seems to be utterly broken in
SDL2.

I have the issue described here
Desktop resolution not restored when destroying window · Issue #639 · libsdl-org/SDL · GitHub where the users desktop
resolution does not restore. A workaround seems to be disabling Xinerama
support and making sure I position the window @ 0,0 when creating it. Other
issues that have been reported are issues with Ubuntu’s Unity desktop where
the resolution will change but the window will not go properly into
full-screen mode.

In an ideal world (and ideal API) I would like to query both monitors
independently (i.e. Xinerama give me this) and allow the user to choose
which monitor goes full-screen (kinda like we did back in SDL1.2 via the
SDL_VIDEO_FULLSCREEN_DISPLAY env var). There seems to be no API to choose
which “display” I make the window go fullscreen on? (unless I am missing
something)…

The game that is having all of these lovely issues is Torchlight in the
current humble bundle. I’m going to try my “disabling” xinerama and set
position hacks to see if that resolves many of the issues. but it seems
there are some more serious deep rooted issues in the fullscreen code in
SDL2 that need some major cleanup… Any insight into the code there would
be grateful as I will most likely be digging into this mess as I plan on
using SDL2 still for 6 more game ports over the next few months.

I’m using SDL2 under Ubuntu with Nvidia Twinview and it works very well on
fullscreen for me (you need fairly recent binary Nvidia drivers, as old
drivers didn’t had the proper Xrandr support). I contributed a few patches
for this issue a while back because it was really broken, and at least as
far as I can see it’s working fine (I can position my window full screen on
both monitors, regular windows across both screens, etc).
On a system with two monitors, you should get two video displays, one for
each monitor, and you select which display you want to be fullscreen at by
using the x,y position of the window and the SDL_WINDOWPOS_UNDEFINED_MASK
This is my window setup code (it’s Cython, but you may be able to get an
idea of what I’m doing anyway).

ndisplays = SDL_GetNumVideoDisplays()
if display > ndisplays-1:
display = 0
x = SDL_WINDOWPOS_UNDEFINED_MASK | display
y = SDL_WINDOWPOS_UNDEFINED_MASK | display
SDL_GetDesktopDisplayMode(display, &dm)
width = dm.w
height = dm.h
self.window = SDL_CreateWindow(“Ignifuga”,x, y,width, height,
SDL_WINDOW_FULLSCREEN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL)

Ahh, so that’s what those macros are for… Wouldn’t you just use the
helper SDL_WINDOWPOS_UNDEFINED_DISPLAY(display) :). Oh way… Cython…

I am running the latest stable nvidia driver (304.37). Which one
difference between what I’m doing and you, is that I have not been setting
the resizable flag. Which that right there has been the cause of MUCH
frustration among ubuntu users of Torchlight. I have actually put
together a patch for this bug
[Linux] Fullscreen window not going fullscreen · Issue #380 · libsdl-org/SDL · GitHub which works around
Compiz’s “odd behavior” of not allowing a window to go fullscreen unless it
is resizable.

However the issue I still have with enabling xinerama is that the desktop
resolution does not restore. I have similar issues with SDL 1.2 and have
xinerama disabled there as well. From further debugging into things… When
SDL tries to restore the desktop resolution with Xinerama enabled it only
tries to restore one monitor to it’s original resolution, not both. And for
some reason that fails. The other difference between my code and your’s is
you are changing to the Desktop resolution, where Torchlight isn’t always
going to do that (if I go w/ the desktop resolution on my box everything
works fine as well)

Thanks for the input and sample code.

I always thought games that change your desktop resolution are rude :slight_smile:
That’s why I adapt the game to the user desktop resolution instead of
forcing it to something else, but I understand in some cases (specially
when you are not the original author of the game and it’s not even the
original platform it was meant to work on), this is inevitable.

I use KDE and don’t have Compiz enabled, and I can confirm that when you
set a different resolution from the current desktop, on exit I get only one
monitor back, and I have to restart X to get it as it was (or maybe use
some Nvidia command I don’t know about), so that’s a real bug that needs to
be fixed.> On Sep 27, 2012, at 9:24 , Gabriel Jacobo wrote:


Gabriel.

Ryan and I have been digging into this some lately. It’s not perfect yet,
but I think a bunch of issues have been fixed, including restoring the
desktop mode when Xinerama is enabled.

http://www.libsdl.org/tmp/SDL-2.0.zip

Please let us know if you see any problems, and if you have suggested
fixes, even better! :)On Thu, Sep 27, 2012 at 7:18 AM, Gabriel Jacobo wrote:

2012/9/27 Edward Rudd

On Sep 27, 2012, at 9:24 , Gabriel Jacobo wrote:

2012/9/23 urkle

**
I’m trying to use SDL2 in my future game ports (Improved keyboard
support, window control, and separation of GL context creation are BIG wins
for me on this), however fullscreen support seems to be utterly broken in
SDL2.

I have the issue described here
Desktop resolution not restored when destroying window · Issue #639 · libsdl-org/SDL · GitHub where the users desktop
resolution does not restore. A workaround seems to be disabling Xinerama
support and making sure I position the window @ 0,0 when creating it. Other
issues that have been reported are issues with Ubuntu’s Unity desktop where
the resolution will change but the window will not go properly into
full-screen mode.

In an ideal world (and ideal API) I would like to query both monitors
independently (i.e. Xinerama give me this) and allow the user to choose
which monitor goes full-screen (kinda like we did back in SDL1.2 via the
SDL_VIDEO_FULLSCREEN_DISPLAY env var). There seems to be no API to choose
which “display” I make the window go fullscreen on? (unless I am missing
something)…

The game that is having all of these lovely issues is Torchlight in the
current humble bundle. I’m going to try my “disabling” xinerama and set
position hacks to see if that resolves many of the issues. but it seems
there are some more serious deep rooted issues in the fullscreen code in
SDL2 that need some major cleanup… Any insight into the code there would
be grateful as I will most likely be digging into this mess as I plan on
using SDL2 still for 6 more game ports over the next few months.

I’m using SDL2 under Ubuntu with Nvidia Twinview and it works very well
on fullscreen for me (you need fairly recent binary Nvidia drivers, as old
drivers didn’t had the proper Xrandr support). I contributed a few patches
for this issue a while back because it was really broken, and at least as
far as I can see it’s working fine (I can position my window full screen on
both monitors, regular windows across both screens, etc).
On a system with two monitors, you should get two video displays, one for
each monitor, and you select which display you want to be fullscreen at by
using the x,y position of the window and the SDL_WINDOWPOS_UNDEFINED_MASK
This is my window setup code (it’s Cython, but you may be able to get an
idea of what I’m doing anyway).

ndisplays = SDL_GetNumVideoDisplays()
if display > ndisplays-1:
display = 0
x = SDL_WINDOWPOS_UNDEFINED_MASK | display
y = SDL_WINDOWPOS_UNDEFINED_MASK | display
SDL_GetDesktopDisplayMode(display, &dm)
width = dm.w
height = dm.h
self.window = SDL_CreateWindow(“Ignifuga”,x, y,width, height,
SDL_WINDOW_FULLSCREEN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL)

Ahh, so that’s what those macros are for… Wouldn’t you just use the
helper SDL_WINDOWPOS_UNDEFINED_DISPLAY(display) :). Oh way… Cython…

I am running the latest stable nvidia driver (304.37). Which one
difference between what I’m doing and you, is that I have not been setting
the resizable flag. Which that right there has been the cause of MUCH
frustration among ubuntu users of Torchlight. I have actually put
together a patch for this bug
[Linux] Fullscreen window not going fullscreen · Issue #380 · libsdl-org/SDL · GitHub which works around
Compiz’s “odd behavior” of not allowing a window to go fullscreen unless it
is resizable.

However the issue I still have with enabling xinerama is that the desktop
resolution does not restore. I have similar issues with SDL 1.2 and have
xinerama disabled there as well. From further debugging into things… When
SDL tries to restore the desktop resolution with Xinerama enabled it only
tries to restore one monitor to it’s original resolution, not both. And for
some reason that fails. The other difference between my code and your’s is
you are changing to the Desktop resolution, where Torchlight isn’t always
going to do that (if I go w/ the desktop resolution on my box everything
works fine as well)

Thanks for the input and sample code.

I always thought games that change your desktop resolution are rude :slight_smile:
That’s why I adapt the game to the user desktop resolution instead of
forcing it to something else, but I understand in some cases (specially
when you are not the original author of the game and it’s not even the
original platform it was meant to work on), this is inevitable.

I use KDE and don’t have Compiz enabled, and I can confirm that when you
set a different resolution from the current desktop, on exit I get only one
monitor back, and I have to restart X to get it as it was (or maybe use
some Nvidia command I don’t know about), so that’s a real bug that needs to
be fixed.


Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

2012/9/28 Sam Lantinga

Ryan and I have been digging into this some lately. It’s not perfect yet,
but I think a bunch of issues have been fixed, including restoring the
desktop mode when Xinerama is enabled.

http://www.libsdl.org/tmp/SDL-2.0.zip

Please let us know if you see any problems, and if you have suggested
fixes, even better! :slight_smile:

I made a comment on the ticket, if I change the resolution on one monitor I
still see the same thing as before (I get only one monitor enabled when I
go back).–
Gabriel.