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 3520 - SDL_GetNumDisplayModes fails to enumerate supported resolutions under Wayland backend
Summary: SDL_GetNumDisplayModes fails to enumerate supported resolutions under Wayland...
Status: ASSIGNED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.1
Hardware: x86_64 Linux
: P2 normal
Assignee: Gabriel Jacobo
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-14 14:48 UTC by sebby2k
Modified: 2017-08-11 18:02 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sebby2k 2016-12-14 14:48:26 UTC
= Description

When enumerating supported display modes using SDL_GetNumDisplayModes/SDL_GetDisplayMode under Wayland backend, only the current desktop display resolution is listed. X11 backend properly lists all supported resolutions.

= Environment

Fedora 25 running Gnome Wayland session.

Name        : gnome-shell
Arch        : x86_64
Epoch       : 0
Version     : 3.22.2
Release     : 2.fc25

Name        : SDL2
Arch        : x86_64
Epoch       : 0
Version     : 2.0.5
Release     : 2.fc25

= Output 

X11 Backend Output:

Mode 2560 1440 0x16161804 60
Mode 1920 1200 0x16161804 60
Mode 1920 1080 0x16161804 60
Mode 1920 1080 0x16161804 50
Can't connect to display
Mode 1920 1080 0x16161804 30
Mode 1920 1080 0x16161804 25
Mode 1680 1050 0x16161804 60
Mode 1440 900 0x16161804 60
Mode 1280 1024 0x16161804 75
Mode 1280 1024 0x16161804 60
Mode 1280 720 0x16161804 60
Mode 1280 720 0x16161804 50
Mode 1152 864 0x16161804 75
Mode 1024 768 0x16161804 75
Mode 1024 768 0x16161804 60
Mode 800 600 0x16161804 75
Mode 800 600 0x16161804 60
Mode 720 576 0x16161804 50
Mode 720 480 0x16161804 60
Mode 720 400 0x16161804 70
Mode 640 480 0x16161804 75
Mode 640 480 0x16161804 60

Wayland Backend Output:

Mode 2560 1440 0000000000 59

= Test Driver

#include <stdio.h>
#include <SDL2/SDL.h>

void dump_disp_mode(SDL_DisplayMode &mode) {
  printf("Mode %d %d %#010x %d\n",
         mode.w,
         mode.h,
         mode.format,
         mode.refresh_rate);
}

int test_sdl() {
  int ret;

  ret = SDL_InitSubSystem(SDL_INIT_VIDEO);
  if (ret < 0) {
    fprintf(stderr, "Failed to init SDL video: %s\n", SDL_GetError());
    return 1;
  }

  SDL_DisplayMode mode;
  ret = SDL_GetDesktopDisplayMode(0, &mode);
  if (ret < 0) {
    fprintf(stderr, "Failed to get desktop display mode: %s\n", SDL_GetError());
    return 1;
  }
  dump_disp_mode(mode);

  int modes_num = SDL_GetNumDisplayModes(0);
  for (int i = 0; i < modes_num; i++) {
    ret = SDL_GetDisplayMode(0, i, &mode);
    if (ret < 0) {
      fprintf(stderr, "Failed to get display mode: %s\n", SDL_GetError());
      return 1;
    }
    dump_disp_mode(mode);
  }

  SDL_QuitSubSystem(SDL_INIT_VIDEO);
}

int main(int argc, char **argv) {
  test_sdl();
  return 0;
}