Re: XForms: Walking Forms

Steve Lamont (spl@szechuan.ucsd.edu)
Mon, 14 Jul 97 17:23:25 PDT

To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> I guess I really didn't phrase my question very well... What I need
> to know is: How can I specify the window (form) origins so that they
> will appear where I want them?

Check the function XTranslateCoordinates(). It will allow you to
translate between coordinates in one window to the coordinates in
another -- in your case, probably the root window. You can get the
root window using the RootWindow() X macro.

If there's "decoration" on your window, you can figure out how much by
using XQueryTree() to find the parent (which will be the Window to
which your window manager reparented your form) and XGetGeometry() on
the parent to find out the border and other slop that's been added
behind your back.

The following bit of code is used to calculate geometry in a resizing
operation -- I know, not exactly what you're doing but similar and it
may give you an idea of how to got about things:

FD_main *main = get_context_main( context_ptr );
Window root;
Window parent;
Window *children;
unsigned int n_children;
int x;
int y;
unsigned int parent_width;
unsigned int parent_height;
unsigned int border_width;
unsigned int depth;
int x_slop;
int y_slop;

XQueryTree( fl_get_display(), main->main->window,
&root, &parent, &children, &n_children );
XGetGeometry( fl_get_display(), parent,
&root, &x, &y, &parent_width, &parent_height,
&border_width, &depth );
x_slop = ( border_width * 2 ) +
( parent_width - main->main->w );
y_slop = ( border_width * 2 ) +
( parent_height - main->main->h );
XFree( children );
fl_set_form_geometry( main->main, 0, 0,
fl_scrw - x_slop, fl_scrh - y_slop );

(context_ptr is a pointer to an opaque data structure I use to keep
all of the form's pertaining info)

Another thing you may need to do is to use fl_prepare_form_window() to
create the window but not display it. I believe that the window
manager will reparent the window to whatever decoration you might have
for a FL_TRANSIENT for and then you can adjust the geometry more or
less as shown above.

Sorry for being a bit non-linear on this -- I'm sort of in the middle
of something else but I thought I'd toss out a few ideas anyway.

spl

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/