SDL: X11: Setting window to fullscreen fails with `RRScreenSize` reporting `BadMatch`
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 -asays4.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 https://github.com/libsdl-org/SDL/commit/16e3bfe807dfdd48b6833da4cd78e789a920e2ec; 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.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 8
- Comments: 15
Commits related to this issue
- x11: Don't let XRRSetScreenSize fire a BadMatch error. This is a workaround and not a proper fix, but this is possibly complicated, and possibly a corner case, so this will do for 2.0.16, if not the ... — committed to libsdl-org/SDL by icculus 3 years ago
- x11: XSync while trying to catch XRRSetScreenSize error. Reference issue #4561 — committed to libsdl-org/SDL by icculus 3 years ago
Agreed, but we’re looking to ship 2.0.16, so this is a mitigation for now and we’ll look more closely afterwards.