We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1643

Summary: SDL_SetWindowFullscreen fails in legacy mode.
Product: SDL Reporter: Martín Golini <spartanj>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED ABANDONED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: solosnake
Version: HG 2.0   
Hardware: x86   
OS: Linux   

Description Martín Golini 2012-11-12 19:08:35 UTC
I'm having problems with the new implementation of the legacy fullscreen on Linux.
I'm using openbox, what happens is something like this:
I call SDL_SetWindowFullscreen ( X11_SetWindowFullscreen ), checks if must use legacy mode, since use_vidmode is != 0 goes to the legacy mode ( only if i have connected one monitor, if my secondary monitor is active, use_vidmode is 0, so it works fine, sine the new implementation works fine ), then enters to X11_BeginWindowFullscreenLegacy and then locks in this call:
XIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow);
But i'm not that sure, since i can't keep debugging because now i have a big black window and i can't alt-tab to the debugger.
One time i saw that the process entered in an endless loop in X11_SetWindowGrab, trying to grab the mouse ( in the endless for ), i think this should have a limit of tries, in case of failure.

Sadly i don't know nothing about this, so i'm trying to describe my situation, i think that the check for legacy fullscreen fallback it's not working well, since openbox is perfectly capable of managing the fullscreen ( net_wm is TRUE for openbox ), if i comment the
if ( displaydata->use_vidmode ) in X11_SetWindowFullscreen everything works fine ( i tested also in enlightenment, kwin3, icewm and windowmaker ).

Thanks!
Comment 1 Ryan C. Gordon 2015-02-19 05:22:20 UTC
Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry if you got a lot of email from this. This is to help me sort through some bugs in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4, though!
Comment 2 solosnake 2017-05-17 19:33:20 UTC
This bug is still present in 2.0.5 (running on Linux Mint 17.3 Cinnamon). 

It can easily reproduced by modifying one of the tests. I modified testdrawchessboard.c and inserted this into the loop() function:

if( e.type == SDL_TEXTINPUT ){
    auto key = e.text.text[ 0 ];

    if( key == 'f' ){
        const Uint32 flag = SDL_WINDOW_FULLSCREEN_DESKTOP;
        const int isfullscreen = 0 != ( SDL_GetWindowFlags( window ) & flag );
        SDL_SetWindowFullscreen( window, isfullscreen ? 0 : flag );
    }
}

Now pressing f key will cause the window to badly misbehave - it will minimise and will not be responsive.

As the original poster says, the issue seems to be in the legacy mode.

The problem begins here in SDL_x11window.c


void
X11_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * _display, SDL_bool fullscreen)
{
    /* !!! FIXME: SDL_Hint? */
    SDL_bool legacy = SDL_FALSE;
    const char *env = SDL_getenv("SDL_VIDEO_X11_LEGACY_FULLSCREEN");
    if (env) {
        legacy = SDL_atoi(env);
    } else {
        SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
        SDL_DisplayData *displaydata = (SDL_DisplayData *) _display->driverdata;
        if ( displaydata->use_vidmode ) {
            legacy = SDL_TRUE;  /* the new stuff only works with XRandR. */
        } else if ( !videodata->net_wm ) {
            legacy = SDL_TRUE;  /* The window manager doesn't support it */
        } else {
            /* !!! FIXME: look at the window manager name, and blacklist certain ones? */
            /* http://stackoverflow.com/questions/758648/find-the-name-of-the-x-window-manager */
            legacy = SDL_FALSE;  /* try the new way. */
        }
    }

    if (legacy) {
        if (fullscreen) {
            X11_BeginWindowFullscreenLegacy(_this, window, _display);
        } else {
            X11_EndWindowFullscreenLegacy(_this, window, _display);
        }
    } else {
        X11_SetWindowFullscreenViaWM(_this, window, _display, fullscreen);
    }
}

The X11_BeginWindowFullscreenLegacy misbehaves and sadly my x11 knowledge isn't good enough to understand why (I have stepped through it several times now).

In the above function (X11_SetWindowFullscreen) if I edit the code so that the 'legacy' variable remains false, then everything works. 

So there appears to be two issues. One is that the x11 code is broken, and second is that the legacy mode should not be used on my system (?).

Being unable to fullscreen is a major problem and I am surprised this issue has existed since 2012 without a fix?

Thanks.
Comment 3 Ryan C. Gordon 2018-08-06 21:20:22 UTC
Hello, and sorry if you're getting dozens of copies of this message by email.

We are closing out bugs that appear to be abandoned in some form. This can happen for lots of reasons: we couldn't reproduce it, conversation faded out, the bug was noted as fixed in a comment but we forgot to mark it resolved, the report is good but the fix is impractical, we fixed it a long time ago without realizing there was an associated report, etc.

Individually, any of these bugs might have a better resolution (such as WONTFIX or WORKSFORME or INVALID) but we've added a new resolution of ABANDONED to make this easily searchable and make it clear that it's not necessarily unreasonable to revive a given bug report.

So if this bug is still a going concern and you feel it should still be open: please feel free to reopen it! But unless you respond, we'd like to consider these bugs closed, as many of them are several years old and overwhelming our ability to prioritize recent issues.

(please note that hundred of bug reports were sorted through here, so we apologize for any human error. Just reopen the bug in that case!)

Thanks,
--ryan.