Search code examples
c++linuxscreenxlibxorg

get xorg.conf serverLayout with c++


I am currently working on a multi window application that spans over multiple screens. The software is written with xlib and runs on ubuntu 10.10, gnome desktop. To get the position of every window I'd like to access the /etc/X11/xorg.conf file, expecially the section SeverLayout. It looks somehow like this:

Section "ServerLayout"
     Identifier "aticonfig Layout"
     Screen     "screen0" 0 0
     Screen     "screen1" 1920 0
     Screen     "screen2" 3840 0
     Screen     "screen3" 5760 0
EndSection

I'd like to get the X values of each screen (0, 1920, ... ) Does xlib somehow provide access to this information?

thanks


Solution

  • Information about layout of multiple monitors in X, especially when they're combined into a single logical screen, is available via the libXrandr and libXinerama API's. Unfortunately, the multi-screen API's added to libXrandr in version 1.2 aren't covered in the man page, but require looking at the extension spec and Xrandr.h header file.