Hi marcus,
first let me say that I don’t have a reliable system setup right now so I’m not 100% sure about what I’m going to say, but I am pretty sure.
Now here’s a quote from the X manual page:
From the user's perspective, every X server has a display name of the form:
hostname:displaynumber.screennumber
This information is used by the application to determine how it should connect to the server and which screen it
should use by default (on displays with multiple monitors):
hostname
The hostname specifies the name of the machine to which the display is physically connected. If the
hostname is not given, the most efficient way of communicating to a server on the same machine will be
used.
displaynumber
The phrase "display" is usually used to refer to collection of monitors that share a common keyboard and
pointer (mouse, tablet, etc.). Most workstations tend to only have one keyboard, and therefore, only one
display. Larger, multi-user systems, however, frequently have several displays so that more than one
person can be doing graphics work at once. To avoid confusion, each display on a machine is assigned a
display number (beginning at 0) when the X server for that display is started. The display number must
always be given in a display name.
screennumber
Some displays share a single keyboard and pointer among two or more monitors. Since each monitor has its
own set of windows, each screen is assigned a screen number (beginning at 0) when the X server for that
display is started. If the screen number is not given, screen 0 will be used.
It seems that each seperate X server process you start starts a seperate display which can have different screens (which are configured in XF86Config-4). Screen numbers must be consecutive and you can get them from the display structure using a macro provided by X without doing any probing. But this is not possible with displays and probing won’t help you either. The display number is specified when the server starts and it doesn’t have to be consecutive, just positive. Try this at a command prompt with no server running:
$X :0.0 &
$X :123.0 &
This will give you two servers(two displays) but obviously you can’t find the second one unless you probe all numbers between 0 and 123. Anyway the display numbers running on a machine are specified by the user so it’s not your business to ‘autodetect’ them. I don’t know what you need this for but either let the user specify all available displays in a list in some config. file or if its for GLFW specify the display as a parameter in some API call.
I hope all this helps.
PS: I’m considering using a toolkit since I’m tired of fighting with X (and totally terrified of doing the same with win32). GLFW is on the top of my list of choices (and at the bottom, it’s the only one. I guess I could consider glut or freeglut but I don’t like them and I wouldn’t even consider SDL). I think I’m going to send you and email one of these days (if I ever get my system runnning) about some details in GLFW which cause me some trouble.
[This message has been edited by zen (edited 03-01-2004).]