Newsgroups: comp.windows.x
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.intercon.com!psinntp!intell!mcgary
From: mcgary@intellection.com (Mike McGary)
Subject: Re: Keyboard mapping and window placement questions
In-Reply-To: darcym@fpddet4.mentorg.com's message of Tue, 27 Apr 1993 18:29:12 GMT
Message-ID: <MCGARY.93Apr30142340@norm.intellection.com>
Organization: Intellection, Inc.
References: <1993Apr27.182912.3388@news.mentorg.com>
Date: Fri, 30 Apr 1993 20:23:40 GMT
Lines: 51

In article <1993Apr27.182912.3388@news.mentorg.com> darcym@fpddet4.mentorg.com (Darcy McCallum) writes:

>   These are two common subjects so I hope someone has had to deal with these
>   specific questions.
>
>   1.  [....question 1 deleted.....]
>
>   2.  I would like to place a popup so that it will be to the immediate right
>   of my main window.  I want it at the same y coord, and their right/left
>   sides touching.  What I need to ask for is the x,y coord of the window 
>   manager's border for the main window.  This should ring a bell with anyone
>   who has called XtMoveWidget(), immediately checking the x,y after the move
>   and seeing that it is right, and in their next callback asking for the x,y
>   and seeing that it is now offset by the WM border.
>
>   Any help would be most appreciated.
>
>   Darcy
>   darcy_mccallum@mentorg.com

I have done this before, but I'm not sure I used the best approach (although
I tried several methods...).

You have to run up the window heirarchy (using XQueryTree()) until you get
to the root window.  Now, this is not so simple because some window managers
slap a window over the root window that is the same size as the root window,
so be sure to take that into account for further calculations.

Calculate the position and width/height offsets for each window using
XGetGeometry().  BE SURE TO TAKE THE BORDER_WIDTH INTO CONSIDERATION.
Remember a windows border_width IS ON THE OUTSIDE of a window, so the
windows x,y,width,height must be adjusted accordingly.

All of this should give you pretty good numbers for how much space the
window-manager is using.

Now, to place the new window, you have to use the same numbers to calculate 
where you want to place it, because the window-manager will re-parent it on
the OUTSIDE of where you place your window (if I remember correctly).

DISCLAIMER: All of this is from memory, and I no longer have the code.  But
I did get it working under several window managers correctly.  Feel free to
call or e-mail for further info.

              -McGary

-- 
Mike D. McGary                VOICE: (214) 620-2100
Intellection                  FAX:   (214) 484-8110
1603 LBJ Freeway, Suite 780   ARPA:  mcgary@intellection.com
Dallas, Texas 75234           UUCP:  intellection.com!mcgary@cs.utexas.edu
