Relative positions of screens

Mark Dwyer m2.dwyer at qut.edu.au
Sun Oct 3 19:28:08 PDT 2010


Hi there,

  I'm trying to draw large scenes on multi monitor setups.  I can get all screens and the resolutions of the screens via:

numberOfScreens = XScreenCount(dpy);
/* Work out the sizes of the screens */               
for (int j = 0; j<numberOfScreens; j++)
{
	Screen *screen = XScreenOfDisplay(dpy, j);
	SIZE_X = DisplayWidth(dpy,j);
	SIZE_Y = DisplayHeight(dpy, j);
	printf("Width::%d\tHeight::%d\n", DisplayWidth(dpy,j), DisplayHeight(dpy,j));
}

But how can I get where one screen is in relation to another?  
eg.  If there are four(4) 2560x1600 monitors arranged in a column, the top screen has its first pixel at [0,0], the second monitor is [0, 1600], third is [0,3200], etc

This is ok to dodgy hack, but when I move to a machine where the monitors are arranged horizontally
eg [0,0], [2560,0], [5120, 0] and [7680,0]

All breaks.  I would prefer not to have a configuration file and would also prefer not to parse the xorg.conf file.

PS. I have have temporarily confused the [0,0] pixel with opengl (bottom left - as opposed to top left for a screen.  Hopefully you still get the idea).

Any pointers?  It appears as though xdotool appears to know this information when moving a mouse.

Cheers

Mark


More information about the xorg mailing list