Only one monitor detected X11

Hi everyone,
I have to use a computer (Ubuntu18.04) that is connected to 3 monitors that are configured in metamode with Nvidia X server (X0 is the main screen and X1 is a combination of the two others: 1920+1920X1080). However glfw returns only one monitor (the X0 one). Would you have an idea why? What I could do? I put below the xorg.conf file and what glfw monitors give me.
Thanks a lot in advance for your help!

Name: HDMI-0 (primary)
Current mode: 1920 x 1080 x 24 (16:9) (8 8 8) 60 Hz
Virtual position: 0, 0
Content scale: 1.000000 x 1.000000
Physical size: 1600 x 900 mm (30.48 dpi at 1920 x 1080)
Monitor work area: 1853 x 1053 starting at 67, 27
Modes:
  0: 640 x 480 x 24 (4:3) (8 8 8) 60 Hz
  1: 720 x 480 x 24 (3:2) (8 8 8) 60 Hz
  2: 720 x 576 x 24 (5:4) (8 8 8) 50 Hz
  3: 800 x 600 x 24 (4:3) (8 8 8) 60 Hz
  4: 1024 x 768 x 24 (4:3) (8 8 8) 60 Hz
  5: 1280 x 720 x 24 (16:9) (8 8 8) 50 Hz
  6: 1280 x 720 x 24 (16:9) (8 8 8) 60 Hz
  7: 1280 x 1024 x 24 (5:4) (8 8 8) 60 Hz
  8: 1920 x 1080 x 24 (16:9) (8 8 8) 50 Hz
  9: 1920 x 1080 x 24 (16:9) (8 8 8) 60 Hz (current mode)
 10: 1920 x 1200 x 24 (8:5) (8 8 8) 60 Hz
# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings:  version 460.39

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    Screen      1  "Screen1" 1920 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "Xinerama" "0"
EndSection

Section "Files"
EndSection

Section "Module"
    Load           "dbe"
    Load           "extmod"
    Load           "type1"
    Load           "freetype"
    Load           "glx"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Targa"
    HorizSync       14.0 - 68.0
    VertRefresh     48.0 - 62.0
    Option         "DPMS"
EndSection

Section "Monitor"
    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor1"
    VendorName     "Unknown"
    ModelName      "VPX PROPixx"
    HorizSync       30.0 - 255.0
    VertRefresh     55.0 - 255.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 1080 Ti"
    BusID          "PCI:1:0:0"
    Screen          0
EndSection

Section "Device"
    Identifier     "Device1"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 1080 Ti"
    BusID          "PCI:1:0:0"
    Screen          1
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "DFP-1"
    Option         "metamodes" "HDMI-0: nvidia-auto-select +0+0"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Screen"
    Identifier     "Screen1"
    Device         "Device1"
    Monitor        "Monitor1"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "DFP-0"
    Option         "metamodes" "DVI-D-0: nvidia-auto-select +1920+0, DP-4: nvidia-auto-select +0+0"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Hi @marianne,

Welcome to the GLFW forum.

From the documentation on GLFW: Standards conformance

GLFW uses the XRandR 1.3 extension to provide multi-monitor support. If the running X server does not support this version of this extension, multi-monitor support will not function and only a single, desktop-spanning monitor will be reported.

You can find out which version of XRandR is supported with:

xrandr --version

Can you check what version is supported by the NVIDIA X Server?

Thank you @dougbinks it seems that could be the problem!
xrandr version is 1.5 and the Nvidia version is 460.80. However I am not sure which version of xrandr is supported (I read through the nvidia documentation and there was no mention of xrandr), it only reports in the minimum requirements section:

X.Org xserver * 1.7, 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19, 1.20 Xorg -version

I am not sure how xorg relates to xrandr, so if you had any pointers I’d appreciate it!

If your version of XRandR is 1.5 then I’m not sure why it’s not working - perhaps the NVIDIA X server does not support this.

perhaps try to run xrandr -q which should list all monitors, if it doesn’t this might be the issue. If it does list all monitors then this could be a bug with this setup, which might be worth reporting to the GLFW Github Issues.

So indeed xrandr -q only lists the one monitor that glfw detects. So this doesn’t seem to be a glfw issue.

  • would anyone have an idea or pointers why xrandr doesn’t detect the screens in xconf? (I put the xorg.conf in both /etc/X11/ and xorg.conf.d). Maybe it would be more appropriate to ask the question somewhere else, though…

  • if I manage to get xrandr to detect the relevant monitors, should glfw work (even though xrandr version is not 1.3, as mentionned above)?

I’m afraid I don’t know enough about xrandr to help.

My main system is similar to yours
Ubuntu 21.04
Nvidia 640.80 drivers
GTX950
2 Monitors connected.

the main difference is that I have no xorg.conf file, I just let the system configure the screens as it will.

Here is the output of xrandr
Screen 0: minimum 8 x 8, current 6400 x 2160, maximum 16384 x 16384
DVI-I-0 disconnected (normal left inverted right x axis y axis)
DVI-I-1 disconnected (normal left inverted right x axis y axis)
HDMI-0 connected 2560x1440+3840+302 (normal left inverted right x axis y axis) 597mm x 336mm
2560x1440 74.60*+ 59.95
1920x1080 60.00 59.94 50.00 60.00 50.04
1680x1050 59.95
1440x900 59.89
1440x576 50.00
1440x480 59.94
1280x1024 75.02 60.02
1280x960 60.00
1280x800 59.81
1280x720 60.00 59.94 50.00
1152x864 75.00
1024x768 75.03 70.07 60.00
800x600 75.00 72.19 60.32 56.25
720x576 50.00
720x480 59.94
640x480 75.00 59.94 59.93
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)
DP-4 connected primary 3840x2160+0+0 (normal left inverted right x axis y axis) 941mm x 529mm
3840x2160 60.00*+ 60.00 59.94 30.00 30.00 29.97 25.00 23.98
1920x1080 60.00 59.94
1680x1050 59.95
1440x900 59.89
1280x1024 75.02 60.02
1280x960 60.00
1280x800 59.81
1280x720 60.00 59.94
1152x864 75.00
1024x768 75.03 70.07 60.00
800x600 75.00 72.19 60.32 56.25
720x480 59.94
640x480 75.00 72.81 59.94 59.93
DP-5 disconnected (normal left inverted right x axis y axis)

here is what the monitors app puts out for this system
Name: DP-4 (primary)
Current mode: 3840 x 2160 x 24 (16:9) (8 8 8) 60 Hz
Virtual position: 0 0
Content scale: 1.000000 1.000000
Physical size: 941 x 529 mm (103.65 dpi)
Monitor work area: pos=(0,34) size=(3840x2126)
Modes:
0: 640 x 480 x 24 (4:3) (8 8 8) 60 Hz
1: 640 x 480 x 24 (4:3) (8 8 8) 73 Hz
2: 640 x 480 x 24 (4:3) (8 8 8) 75 Hz
3: 720 x 480 x 24 (3:2) (8 8 8) 60 Hz
4: 800 x 600 x 24 (4:3) (8 8 8) 56 Hz
5: 800 x 600 x 24 (4:3) (8 8 8) 60 Hz
6: 800 x 600 x 24 (4:3) (8 8 8) 72 Hz
7: 800 x 600 x 24 (4:3) (8 8 8) 75 Hz
8: 1024 x 768 x 24 (4:3) (8 8 8) 60 Hz
9: 1024 x 768 x 24 (4:3) (8 8 8) 70 Hz
10: 1024 x 768 x 24 (4:3) (8 8 8) 75 Hz
11: 1280 x 720 x 24 (16:9) (8 8 8) 60 Hz
12: 1152 x 864 x 24 (4:3) (8 8 8) 75 Hz
13: 1280 x 800 x 24 (8:5) (8 8 8) 60 Hz
14: 1280 x 960 x 24 (4:3) (8 8 8) 60 Hz
15: 1440 x 900 x 24 (8:5) (8 8 8) 60 Hz
16: 1280 x 1024 x 24 (5:4) (8 8 8) 60 Hz
17: 1280 x 1024 x 24 (5:4) (8 8 8) 75 Hz
18: 1680 x 1050 x 24 (8:5) (8 8 8) 60 Hz
19: 1920 x 1080 x 24 (16:9) (8 8 8) 60 Hz
20: 3840 x 2160 x 24 (16:9) (8 8 8) 24 Hz
21: 3840 x 2160 x 24 (16:9) (8 8 8) 25 Hz
22: 3840 x 2160 x 24 (16:9) (8 8 8) 30 Hz
23: 3840 x 2160 x 24 (16:9) (8 8 8) 60 Hz (current mode)
Name: HDMI-0 (secondary)
Current mode: 2560 x 1440 x 24 (16:9) (8 8 8) 75 Hz
Virtual position: 3840 302
Content scale: 1.000000 1.000000
Physical size: 597 x 336 mm (108.92 dpi)
Monitor work area: pos=(3840,302) size=(2560x1440)
Modes:
0: 640 x 480 x 24 (4:3) (8 8 8) 60 Hz
1: 640 x 480 x 24 (4:3) (8 8 8) 75 Hz
2: 720 x 480 x 24 (3:2) (8 8 8) 60 Hz
3: 720 x 576 x 24 (5:4) (8 8 8) 50 Hz
4: 800 x 600 x 24 (4:3) (8 8 8) 56 Hz
5: 800 x 600 x 24 (4:3) (8 8 8) 60 Hz
6: 800 x 600 x 24 (4:3) (8 8 8) 72 Hz
7: 800 x 600 x 24 (4:3) (8 8 8) 75 Hz
8: 1440 x 480 x 24 (3:1) (8 8 8) 60 Hz
9: 1024 x 768 x 24 (4:3) (8 8 8) 60 Hz
10: 1024 x 768 x 24 (4:3) (8 8 8) 70 Hz
11: 1024 x 768 x 24 (4:3) (8 8 8) 75 Hz
12: 1440 x 576 x 24 (5:2) (8 8 8) 50 Hz
13: 1280 x 720 x 24 (16:9) (8 8 8) 50 Hz
14: 1280 x 720 x 24 (16:9) (8 8 8) 60 Hz
15: 1152 x 864 x 24 (4:3) (8 8 8) 75 Hz
16: 1280 x 800 x 24 (8:5) (8 8 8) 60 Hz
17: 1280 x 960 x 24 (4:3) (8 8 8) 60 Hz
18: 1440 x 900 x 24 (8:5) (8 8 8) 60 Hz
19: 1280 x 1024 x 24 (5:4) (8 8 8) 60 Hz
20: 1280 x 1024 x 24 (5:4) (8 8 8) 75 Hz
21: 1680 x 1050 x 24 (8:5) (8 8 8) 60 Hz
22: 1920 x 1080 x 24 (16:9) (8 8 8) 50 Hz
23: 1920 x 1080 x 24 (16:9) (8 8 8) 60 Hz
24: 2560 x 1440 x 24 (16:9) (8 8 8) 60 Hz
25: 2560 x 1440 x 24 (16:9) (8 8 8) 75 Hz (current mode)

So perhaps try it without a xorg.conf and see what you get.

Thank you! That indeed worked and helped me track down the issue (if I remove the xconf file, I see the 3 displays), and it indeed is related to GLFW.

With some additionnal help from the Nvidia forum, it turns out that like the list of monitors returned by glfwGetMonitors (_glfwPollMonitorsX11) only looks at monitors associated with the default X screen (so xrandr -q 0), X screen 0, and thus doesn’t list X screen 1 (that I need to display my experiment)…

Is this with the latest GLFW code form Github?

Looking at the code for _glfwPollMonitorsX11 this gets the full list of monitors with XRRGetScreenResourcesCurrent.

There might however be a problem when one screen spans multiple monitors, as the code to attribute a monitor to a screen seems to only do so if they are the exact same size.

If you’ve checked this with the latest GLFW code it might be worth posting an issue on Github.

It is with the latest stable I believe (3.3.4).
Following your advice, I posted an issue!

X11 nomenclature is… a mess.

GLFW only supports a single X11 screen, chosen by glfwInit. X11 screens are (nowadays) like virtual screens and can cover any number of physical monitors using XRandR or (deprecated) Xinerama. Each X11 screen has its own window hierarchy and windows cannot move between them. We pass a window to XRRGetScreenResourcesCurrent to let it know which X11 screen we are interested in.

One can run a GLFW program on any existing X11 screen by setting the DISPLAY environment variable, which is typically set to :0.0. The last number is the X11 screen number.

env DISPLAY=:0.1 ./my_game

The matching of GLFW monitors against screens by area in GLFW uses Xinerama screens, not X11 screens. Xinerama screens are viewports into a single X11 screen much like XRandR monitors and CRTCs. The window manager protocol for making windows full screen take Xinerama screen indices instead of XRandR IDs, which is why GLFW needs them.

It would be possible to support multiple X11 screens in GLFW but I believe it would be too much extra complexity and maintenance for such a rare setup. It would also break some existing assumptions like being able to place a window on any monitor.