rroux@betelgeuse.sdd.trw.com (Ray Roux) (03/24/91)
Is there a way that I can get the resolution of the display? I need to modify a program such that it can run correctly on either a Sun Workstation or an NCD-16 X terminal. The NCD has a higher resolution than the Sun and so the widget placement and winow sizes are all off. Unfortunately, there's no money or time to re-write it to be resolution independent. I hope there's some way for me to know which display I'm using and then do some conversion. I know it's a kludge but.... Ray Roux rroux@rigel.sdd.trw.com
mouse@lightning.mcrcim.mcgill.EDU (der Mouse) (03/25/91)
> Is there a way that I can get the resolution of the display?
The Xlib document says, among other things,
WidthOfScreen(screen)
int XWidthOfScreen(screen)
Screen *screen;
Both return the width of the specified screen in pixels.
HeightOfScreen(screen)
int XHeightOfScreen(screen)
Screen *screen;
Both return the height of the specified screen in pixels.
WidthMMOfScreen(screen)
int XWidthMMOfScreen(screen)
Screen *screen;
Both return the width of the specified screen in millimeters.
HeightMMOfScreen(screen)
int XHeightMMOfScreen(screen)
Screen *screen;
Both return the height of the specified screen in millimeters.
der Mouse
old: mcgill-vision!mouse
new: mouse@larry.mcrcim.mcgill.edu
frans@origin.nl (03/25/91)
The solution you propose is a bit of turning the problem around. The HeightMMOfScreen(screen) call references the screen resolution as defined within the X server. At least in the Sun Server implementation, this is is a hard-coded constant ( I believe somewhere in server/ddx/mfb/??? ), defined to be 90 (pixels per inch). If you want to have the HeightMMOfScreen(screen) call to return the right value, you have to start the X process with the right argument ( -dpi 83 e.g.) so that the default value gets overruled. (You can check this behaviour very easily: if you run xdpyinfo in a high or low resolution display, the resolution reported remains the same, but the size of the screen reported changes ! Best greetings, Francois Staes Origin/Middleware Eindhoven, The Netherlands.
mouse@lightning.mcrcim.mcgill.EDU (der Mouse) (03/26/91)
> The solution you propose is a bit of turning the problem around. The > HeightMMOfScreen(screen) call references the screen resolution as > defined within the X server. That's as close as you can come with X operations. > At least in the Sun Server implementation, this is is a hard-coded > constant (I believe somewhere in server/ddx/mfb/???), defined to be > 90 (pixels per inch). True. That is a misfeature in the Sun server, forced upon them by Sun failing to provide any way for programs to sense what sort of monitor the machine is connected to. The server simply does not have any way of determining whether it's connected to a 16", 19", or some other size monitor...except for the user telling it, for which a flag is provided. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu