[comp.windows.x] Suggestions for for extended geometry specifications

paul@cs.edinburgh.ac.uk (Paul Anderson) (11/28/90)

We have several different types of X server here and people who habitually use the different displays need X startup files with several levels of conditionals to place their favorite windows in a sensible place on each of the diferently sized screens. I haven't been following this group closely enough to to know whether any better solution has been proposed for this, but I have implemented the following routines which seem to be working quite well here:

I wrote a new XParseGeometry which accepts the following items anywhere that a conventional geometry specification will accept a number:

	<n>		Where <n> is an integer
	 h		screen height in pixels
	 w		screen width in pixels
	 H		screen height in mm
	 W		screen width in mm
	 h[<f>] 	height of the character cell for font <f>
	 w[<f>] 	width of the character cell for font <f>

	( <expr> )	where <expr> is any of there items combined
			with the operators + - * / %

This allows geometry specifications like:

	(w/2)x(h-20)+(w/2)+20

Which puts a window in the right hand half of the screen with a 20 pixel gap at the top, on any size of screen.

It is possible to simply compile existing applications with the new XParseGeometry, although it is not ideal, because XParseGeometry now needs to know the display so it can obtain the dimensions. Without an extra argument to XParseGeometry, or a call to another routine, my version simply uses the DISPLAY variable to determine the display to use.

I also embedded this in a utility "xgeom" which takes an extended geometry specification on the command like and writes out a conventional geometry, so you can write things like:

	xdvi -geometry `xgeom '(w/2)x(h-20)+(w/2)+20'` foo.dvi

without recompiling the basic utilities.

Is this a good idea, or have I missed some better way of doing it?

-- 
Paul Anderson                      JANET: paul@uk.ac.ed.lfcs
LFCS, Dept. of Computer Science    UUCP:  ..!mcvax!ukc!lfcs!paul	
University of Edinburgh            ARPA:  paul%lfcs.ed.ac.uk@nsfnet-relay.ac.uk
Edinburgh EH9 3JZ, UK.             Tel:   031-650-5193