From: jamesd@lt5.cs.rhbnc.ac.uk (James Driscoll)
Newsgroups: fj.mail-lists.x-window
Subject: Re: HELP: Finding the complete display name for an app
Date: 12 Dec 92 16:21:35 GMT
Distribution: fj
Organization: Royal Holloway, University of London

Date: Sat, 12 Dec 1992 13:58:34 GMT
Message-Id: <1992Dec12.135834.15905@csqx.cs.rhbnc.ac.uk>
Newsgroups: comp.windows.x


|>> How can I find out the complete name of the Display that an
|>> application is displayed on?
|>
|>"the" "complete" name of "the" Display?  Those three words embody
|>possibly-invalid assumptions which are part of the reason you're
|>having
|>so much trouble.
|>
|>(1) The assumption that the application is displaying on exactly one
|>    display (the second "the").
|>
|>(2) The assumption that some names are "incomplete" and some are
|>    "complete".  See below for more on this.
|>
|>(3) The assumption that every display has exactly one "complete"
|>name.
|>
|>> I've tried :
|>
|>> 	o	DisplayString(display); which tends to return :0.0
|>
|>> 	o	getenv("DISPLAY");	which returns NULL for applications
|>> 					started with -display.
|>
|>I assume the former is an example of a display name which you would
|>consider not "complete".  What's incomplete about it?  It specifies
|>everything the client needs to know in order to contact the display
|>in
|>question.  It has a well-defined meaning: display 0 on the machine
|>the
|>client is running on, with screen 0 as the default screen.
|>
|>> Is there any function that returns the form I want (eg
|>> cad1a.cs.rhbnc.ac.uk:0.0)
|>
|>So, a "complete" display name is defined as - what?  One with
|>something
|>before the colon?  One with a FQDN before the colon?  One with a
|>machine name before the colon?  A name that'll work for another X
|>client anywhere?
|>
|>If you want "something before the colon", just prepend 127.0.0.1 when
|>you see a name with nothing before the colon; that's the standard
|>loopback address.  If you want a FQDN before the colon, this is not
|>possible; not all machines have FQDN names, not even all machines
|>running X servers.  If you want a machine name before the colon, this
|>too may not be possible, since not all machines have names, and even
|>those that do don't always have names that are usable by X clients. 
|>If
|>you want a name that'll work anywhere, that's not possible either
|>since
|>the name-to-machine mapping varies depending on who's performing the
|>lookup operation.  Even if you're willing to require that an FQDN
|>exist
|>for the machine, that's not enough; there are lots of machines on the
|>Internet that are utterly incapable of figuring out FQDNs they haven't
|>been explicitly told about.
|>
|>> or is there something that contains this information or will I have
|>> to write a "fudge" to get around it, and if so how?
|>
|>If you can define precisely what semantics you want, I may be able to
|>help.  But I think it more likely that as you try to pin down exactly
|>what you want to ask, you'll discover the *real* problem.
|>
|>					der Mouse
|>
|>			    mouse@larry.mcrcim.mcgill.edu
|>

I obviously better go in to a bit more detail as to what I require.

I am writing a mutli-process application that needs to share information. Each
instance of the application needs to know about the contents of 4 or 5 data
fields and when they change. Hence I am storing the data in Xproperties on the
root window of the display upon which the first instance is started up. As
subsequent processes can occur elsewhere on the network (and hence on different
displays) the have to be able to make a connection to that display. Therefore
when getenv("DISPLAY"); returns "0.0" it is insufficient as an identifier to the
display containing the root window where the properties are stored.

Thus I need some way of being able to get an accurate identifier to the display
where the properties are stored so that all other processes can make connections
to that display and retrieve the desired information and setup a
PropertyNotify event handler to trap any changes in the data stored there.

Perhaps I'm going about this in the wrong way - if so would you be kind enough to
make a few suggestions?

Thanks very much in advance,

-James