Skip to content

X11: Setting window to fullscreen fails with RRScreenSize reporting BadMatch #4561

@bdach

Description

@bdach

Hi,

On recent versions on SDL I am seeing failures to display a fullscreen window. Before I proceed, a few notes on my hardware setup (as it's possibly relevant):

  • I am on a Ubuntu 16.04 system (uname -a says 4.15.0-151-generic #157-Ubuntu SMP Fri Jul 9 23:07:57 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux), with x11, running i3 as the window manager
  • I have two physical monitors, one of which has a 2560x1080 resolution, and the other has a 1920x1080 resolution

Below is a minimal reproducer example that fails for me with current main (please forgive the haphazard error handling, I do not program C often if at all these days):

#include <stdio.h>
#include <stdlib.h>
#include "../SDL/include/SDL.h"

int main(int argc, char **argv)
{
    if (SDL_Init(SDL_INIT_VIDEO) < 0)
    {
        printf("SDL failed to initialise with error %s\n", SDL_GetError());
        return EXIT_FAILURE;
    }

    SDL_Window *window = NULL;

    window = SDL_CreateWindow("test", 0, 0, 2560, 1080, SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN);

    if (window == NULL)
    {
        printf("Window was not created: %s\n", SDL_GetError());
        return EXIT_FAILURE;
    }

    SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, 0);

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

    int quit = 0;

    SDL_Event e;

    while (!quit) {
        while (SDL_PollEvent(&e) != 0) {
            if (e.type == SDL_QUIT) {
                quit = 1;
            }
        }
    }

    return EXIT_SUCCESS;
}

This on my system fails with

X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  140 (RANDR)
  Minor opcode of failed request:  7 (RRSetScreenSize)
  Serial number of failed request:  256
  Current serial number in output stream:  257

I have managed to trace this back to 16e3bfe; commenting out the call to X11_XRRSetScreenSize prevents the crash to desktop.

The reason why I stated that this is possibly related to my monitor configuration is that upon some digging and instrumenting the call above with some log statements I have managed to fish out the following:

INFO: DisplayWidth = 4480, DisplayWidthMM = 1518
INFO: DisplayHeight = 1080, DisplayHeightMM = 366
INFO: about to XRRSetScreenSize (display = 55c9cd09e0f0, window = 254, w = 2560, h = 1080, mmWidth = 867, mmHeight = 366)

Note that DisplayWidth and DisplayHeight say 4480x1080, so it's the total resolution of both my screens. xrandr reports: (somewhat truncated)

Screen 0: minimum 8 x 8, current 4480 x 1080, maximum 16384 x 16384
eDP-1-1 connected 1920x1080+2560+0 (normal left inverted right x axis y axis) 344mm x 194mm
HDMI-1-1 connected 2560x1080+0+0 (normal left inverted right x axis y axis) 673mm x 284mm

I am not sure where xlib got the 1518x366 measurements from, and since I do not routinely develop anything for x11 I have no idea what the proper API would be for fetching the single screen's size.

If I can provide any further information or test possible patches/PRs to resolve this please let me know.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions