[comp.soft-sys.andrew] im_CreateTransient -- I wrote it last night.

wdc@athena.mit.edu (Bill Cattey) (10/18/90)

Progress report:  I've done modifications to im.c, im.ch, xim.c, and
xim.ch.  (CMU developers will be relieved to know I used xim.c rev 1.43
so it has the latest changes in it.)

I have not compiled or tested yet, so I'm not ready to supply patches,
but I wanted to share my design with the info-andrew list:

Changes to im.ch:
I added a class procedure 
    CreateTransient(struct im *other) returns struct im *; 
and a method 
    CreateTransientWindow(struct im *other) returns boolean;

Changes to im.c:

    im__CreateTransient  is a clone of im__Create, except that it calls
im_CreateTransientWindow instead of im_CreateWindow.

Clever hack:
    im__CreateTransientWindow, rather than saying it's a missing method,
as im__CreateWindow does, calls im__CreateWindow, throwing it's argument
away.

This way if the window server specific code implements no
CreateTransientWindow, the system will behave as if im_Create, rather
than im_CreateTransient had been called.

Change to xim.ch:
added a method:
    CreateTransientWindow(struct im *other) returns boolean;

Changes to xim.c:

    xim__CreateTransientWindow is a lobotomized clone of
xim__CreateWindow.  All the code that dealt with the possiblity of the
window being on a new display is removed.  The argument other is checked
to see if it really is a valid other window, and all the once-only stuff
is pulled from it.  If other is invalid, a warning is printed, and a
call is made to im_CreateWindow.

XSetTransientForHint is called.

Geometry specification is VERY different.

cleverness:  

If no desired height is specified, the height is set as 1/4 the height
of the other window.
If no desired width is specified, the width is set as 1/2 the width of
the other window.
If no desired top and left are  specified, the new window is positioned
so as to be centered on the other window.

The lack of a desired size or position is defined as a value equal to
zero.  If you don't want a window relative to the existing window, use
im_Create!

How does this design sound?

-wdc

guy@auspex.auspex.com (Guy Harris) (10/19/90)

>How does this design sound?

Make sure you set CWSaveUnder for the window if "UseSaveUnder" is set in
the ".Xdefaults" file, as the menu package does, so that when the popup
window goes away you don't necessarily get a bunch of Expose events that
force you to painstakingly redraw the windows behind the popup.  That's
one thing that got me thinking about ways to improve the pop-up window
support in Andrew....

Also, this mechanism may make life unpleasant for people still using
WM; that's no skin off my nose, but some people might not like it. 
There might be some other way of doing popups to have them continue to
work in WM the way they always did; it might involve creating Graphics
in WM that are still inside the other window using that window, but in a
separate popup window for X and other window systems that let you create
reasonable pop-up windows.

Dunno offhand how to make input work.