I would like to display images in the second monitor. I have two displays of 1920x1080px connected and detected properly in Ubuntu.
I am listing the screens with the following code. The problem is that I am listing always just one screen0: 1920x1080 for a single display configuration and a 3840x1080 for a multiple display (exended or duplicated).
How can I get the list of two displays in order to select just screen1 (second display 1920x1080)?
Display *myDisplay = XOpenDisplay(NULL);
unsigned int numScreens = ScreenCount(myDisplay);
for(unsigned int i=0; i<numScreens; i++){
Screen *myScreen = ScreenOfDisplay(myDisplay, i);
ScreenInfo screen;
screen.resX = myScreen->width;
screen.resY = myScreen->height;
char screenName[50];
sprintf(screenName, "Screen number %d", i);
screen.name = screenName;
}
update: here is my xrandr output, that shows the two displays properly connected, and I can use it accordingly. However, if I access to the available displays, I can get only :0 with one screen with 3840x1080. How to get two displays (:0 and :1)?
vo@vo-ubuntu:~$ xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 8192 x 8192
HDMI-1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 527mm x 296mm
1920x1080 60.00*+ 60.00 50.00 50.00 59.94
1920x1080i 60.00 60.00 50.00 59.94
1600x1200 60.00
1680x1050 59.88
1400x1050 59.95
1600x900 60.00
1280x1024 75.02 60.02
1440x900 59.90
1280x960 60.00
1152x864 75.00
1280x720 60.00 60.00 50.00 59.94
1024x768 75.03 70.07 60.00
832x624 74.55
800x600 72.19 75.00 60.32 56.25
720x576 50.00 50.00
720x576i 50.00 50.00
720x480 60.00 60.00 59.94 59.94 59.94
720x480i 60.00 60.00 59.94 59.94
640x480 75.00 72.81 66.67 60.00 59.94 59.94
720x400 70.08
HDMI-2 disconnected (normal left inverted right x axis y axis)
DP-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 527mm x 296mm
1920x1080 60.00*+
1600x1200 60.00
1680x1050 59.95
1400x1050 59.98
1600x900 60.00
1280x1024 75.02 60.02
1440x900 59.89
1280x960 60.00
1152x864 75.00
1280x720 60.00
1024x768 75.03 70.07 60.00
832x624 74.55
800x600 72.19 75.00 60.32 56.25
640x480 75.00 72.81 66.67 59.94
720x400 70.08
DVI-D-1-1 disconnected (normal left inverted right x axis y axis)
HDMI-1-3 disconnected (normal left inverted right x axis y axis)
DP-1-2 disconnected (normal left inverted right x axis y axis)
Check available X displays doesn't return the two connected displays,
vo@vo-ubuntu:~$ cd /tmp/.X11-unix && for x in X*; do echo ":${x#X}"; done
:0
:1024
vo@vo-ubuntu:/tmp/.X11-unix$