The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL_GetNumVideoDisplays, Xrandr, and a lot of tears
psychogears


Joined: 18 May 2016
Posts: 1
Problem: I have a dual monitor setup and am running the following code:

Code:
#include <iostream>
#include <memory>
#include <SDL2/SDL.h>

int main()
{
        if(SDL_Init(SDL_INIT_VIDEO) != 0)
        {
                SDL_Quit();
                std::cerr << SDL_GetError() << std::endl;
                return 1;
        }

        SDL_DisplayMode dm{};

        for(int i=0; i<SDL_GetNumVideoDisplays(); ++i)
        {
                SDL_GetCurrentDisplayMode(i, &dm);
                std::cout << "Display " << i << std::endl
                        << "----------" << std::endl
                        << "Width: " << dm.w << std::endl
                        << "Height: " << dm.h << std::endl
                        << "Refresh: " << dm.refresh_rate << std::endl
                        << std::endl;
        }


        SDL_Quit();

        return 0;
}


I compile with

Code:
g++ -std=c++11 test.cpp -lSDL2


and running my program returns:

Code:
Display 0
----------
Width: 3840
Height: 1080
Refresh: 0


So, I've been trying to figure this out for the last two days. Google, looking into SDL source code (video/SDL_video.c, specifically), as well as libXrandr source code. I'm expecting two displays returning 1920 x 1080 each, so that my window which I create with SDL_WINDOW_FULLSCREEN_DESKTOP won't span the entire desktop, but just the one screen. I've got a main development machine with two monitors where this works as expected, but this machine with two monitors somehow regards both monitors as being part of one display.

I was wondering if anyone had any idea on how I could get SDL_WINDOW_FULLSCREEN_DESKTOP to just work on one window instead of blowing up to both windows. Thanks.