home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.windows.x
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!cs.utexas.edu!qt.cs.utexas.edu!news.Brown.EDU!noc.near.net!gateway!miki!oj
- From: oj@miki.pictel.com (Oliver Jones)
- Subject: Re: HELP: Finding the complete display name for an app
- Message-ID: <1992Dec15.150051.2328@miki.pictel.com>
- Organization: PictureTel Corporation
- References: <1992Dec8.155553.900@csqx.cs.rhbnc.ac.uk> <1992Dec11.100529.28050@thunder.mcrcim.mcgill.edu> <1992Dec12.135834.15905@csqx.cs.rhbnc.ac.uk>
- Date: Tue, 15 Dec 1992 15:00:51 GMT
- Lines: 85
-
- In article <1992Dec12.135834.15905@csqx.cs.rhbnc.ac.uk> jamesd@lt5.cs.rhbnc.ac.uk (James Driscoll) writes:
- >
- >|>> How can I find out the complete name of the Display that an
- >|>> application is displayed on?
-
- Der Mouse was right (if a bit pedantic). ":0.0" is, of course, a
- well-formed display name.
-
- >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.
-
- OK, let's nail down some terminology. I'm putting *stars* around
- the words about which I urge you to be precise in your thinking and usage.
-
- Your *application* is distributed, and implemented with several
- different *X clients* running on several different *machines* around
- the network. Each *X client* displays information to a local
- *display*. (The term *display* means *X display server.*)
-
- >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) ...
-
- Let's rewrite this sentence.
-
- The *application* starts up when the first *X client* starts up.
- The first *X client* connects to its default *display* (the one named
- in its DISPLAY environment variable or on its command line.)
-
- This *X client* establishes data sharing for the *application* by
- storing some properties on the default root window of the display
- connection. The first *X client's* *display* will do double duty
- as both a device for user i/o and as "bus" for data sharing.
-
- The first *X client* then communicates its *display* name to other *X
- clients* running on other *machines* in the network so those other
- clients can get access to the shared data. Each subsequent *X client*
- must open two different display connections, one to its default
- display (which is usually, but not necessarily, a local display ":0")
- and another to the first *display*, the one used for data sharing.
-
- [ Note well: This description of your *application* may not
- be exactly correct, but it's what I infer from what you wrote. ]
-
- >...I 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.
-
- To be precise, it's insufficient unless it's used by another
- client running on the same *machine.*
-
- >Thus I need some way of being able to get an
- >accurate identifier to the display where the properties are stored...
-
- Right. What you want is a network-unique *display* name. How can you
- get this?
-
- 1) in your user's setup scripts or in a shell script which runs your
- networked application, issue the command
-
- setenv DISPLAY `hostname`:0
-
- or the /bin/sh equivalent.
-
- 2) refrain from using "-display :0" in your command lines. Rather,
- use "-display `hostname`:0"
-
- If you do (1) and (2) you'll be happy with DisplayString's results.
- Note that (1) and (2) overload two things. a) they specify
- a network-wide display name, b) they request the use of TCP to
- connect to the server rather than Unix-domain sockets.
-
- a) is good, b) may or may not be depending on your situation.
-
- 3) in your C program, if you find that DisplayString starts
- with a colon it's good evidence that your *X client" and *display*
- are running on the same machine. Write some code in your "*X client*
- program to look up your host name and prepend it to the display
- string.
-
- Good luck. Don't forget to deal with the case where the
- user switches off the display for the first X client.
-