It looks like there's a libXinerama
API that can retrieve that information. I haven't found any detailed information on it yet though.
General X.org programming information can be found here (PDF file). Information on the functions provided by libXinerama
can be found here (online copy of a manpage, not a lot of information in it).
Here's a small C++ program that I whipped up from those references to retrieve the dimensions and offsets of each of the monitors hooked into Xinerama. It also works for nVidia TwinView; I don't presently have an ATI card to test it on their BigDesktop system, but I suspect it would work on it as well.
#include <cstdlib>
#include <iostream>
#include <X11/extensions/Xinerama.h>
using std::cout;
using std::endl;
int main(int argc, char *argv[]) {
bool success=false;
Display *d=XOpenDisplay(NULL);
if (d) {
int dummy1, dummy2;
if (XineramaQueryExtension(d, &dummy1, &dummy2)) {
if (XineramaIsActive(d)) {
int heads=0;
XineramaScreenInfo *p=XineramaQueryScreens(d, &heads);
if (heads>0) {
for (int x=0; x<heads; ++x)
cout << "Head " << x+1 << " of " << heads << ": " <<
p[x].width << "x" << p[x].height << " at " <<
p[x].x_org << "," << p[x].y_org << endl;
success=true;
} else cout << "XineramaQueryScreens says there aren't any" << endl;
XFree(p);
} else cout << "Xinerama not active" << endl;
} else cout << "No Xinerama extension" << endl;
XCloseDisplay(d);
} else cout << "Can't open display" << endl;
return (success ? EXIT_SUCCESS : EXIT_FAILURE);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…