brossard%litsun2.epfl.ch@MITVMA.MIT.EDU (03/18/89)
[Sent: Fri. 17/Mar./89 Time: 17:21] XTranslateCoordinates takes among other inputs the screen number. How does an application find the screen number? For example, I have the following line of code: XTranslateCoordinates( XtDisplay(widget), XtWindow(widget), RootWindow( XtDisplay(widget), SCREEN_NUMBER), 0, 0, &shellx, &shelly, &w ); I could hardcode SCREEN_NUMBER to be 0, but that doesn't seem right. I could use XtScreen to get at the screen pointer, but that structure doesn't seem to have any field holding the screen number. So, what am I missing? Alain Brossard brossard@litsun2.epfl.ch PS I know about XtTranslateCoords(), but it doesn't work (see next posting).
swick@ATHENA.MIT.EDU (Ralph R Swick) (03/18/89)
> XTranslateCoordinates takes among other inputs the screen > number. How does an application find the screen number? For example, > I have the following line of code: > > XTranslateCoordinates( XtDisplay(widget), XtWindow(widget), > RootWindow( XtDisplay(widget), SCREEN_NUMBER), > 0, 0, &shellx, &shelly, &w ); If you really want the screen number, you'll have to code your own loop that compares XtScreen(widget) with ScreenOfDisplay(XtDisplay(widget), loop_index). In the example you give, a much simpler solution is to use RootWindowOfScreen(XtScreen(widget)) instead of RootWindow(). > I know about XtTranslateCoords(), but it doesn't work (see next > posting). This is a known bug (under some window managers, e.g. uwm).
steveg@tove.umd.edu (Steve Green) (03/18/89)
Yes indeed, XtTrans... does not work correctly and XTrans... is what I used. I got the screen number from the DefaultScreen(dpy) macro. XtScreen returns a pointer to a Screen structure not the integer. I assume that the screen number is in the Screen structure but DefaultScreen works for me and why mess with success. Is there any reason not to use DefaultScreen? -steve green steveg@tove.umd.edu
kit@ATHENA.MIT.EDU (Chris D. Peterson) (03/21/89)
> Is there any reason not to use DefaultScreen?
Yep, what if someone has a 2 headed display, and starts his program up
with:
% foo -display foo:0.1
You will be calculating against foo:0.0 and your translation will be
garbage. It is best to use the RootWindowOfScreen() macro on the screen
returned by XtScreen().
Chris D. Peterson
MIT X Consortium /
Project Athena
Net: kit@athena.mit.edu
Phone: (617) 253 - 1326
USMail: MIT - Room E40-321
77 Massachusetts Ave.
Cambridge, MA 02139
kit@ATHENA.MIT.EDU (Chris D. Peterson) (03/22/89)
I just recieved this message from Jim Fulton: > If you start a client with a display variable of host:dpy.1, > DefaultScreen() will be 1, not 0. Oops. It looks like my example was flawed, perhaps there is no problem with using DefaultScreen(). I still have this feeling that DefaultScreen() will fail when I least expect it. I will continue to use RootWindowOfScreen() as this will clearly do the right thing. Sorry for any inconvience. Chris D. Peterson MIT X Consortium / Project Athena Net: kit@athena.mit.edu Phone: (617) 253 - 1326 USMail: MIT - Room E40-321 77 Massachusetts Ave. Cambridge, MA 02139