[comp.windows.x] Window manager hints: window group problem

epstein@trwacs.UUCP (Jeremy Epstein) (02/27/91)

We're trying to build an application which has multiple top
level windows, which we're then trying to group together using
the window manager hints.  Our goal is that when we iconify the
"master" window, the other top level window should be iconified
as well.

The first of the following programs creates a top level window and
displays the window ID.  The second program, when given the window
ID from the first as a command line parameter, will create another
top level window with the window_group field of the window manager
hints set to the first window.

We've run these programs under mwm (1.1), twm, and olwm on X11R4
on Sun 3 & Sun 4 systems.  Iconifying the first window does not
iconify the second window.

Is this a misreading of ICCCM, a bug in the programs, or a problem
with the window managers?  If it's a problem with the window managers,
are there any window managers where this works properly?  Is this
anywhere in the FAQ (I couldn't find it)?

Thanks for any help!
--Jeremy

*****START OF PROGRAM #1*****
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <Xm/Xm.h>
#include <Xm/Text.h>
#include <stdio.h>

main(argc, argv)
int argc;
char *argv[];
{
	Widget toplevel, text;
	Arg args[10];
	int n=0;
	Window win_id;
	char string[32];

	toplevel = XtInitialize(argv[0], "Main_window", NULL, 0, &argc, argv);
	text = XtCreateManagedWidget("label", xmTextWidgetClass, toplevel, NULL, 0);
	XtRealizeWidget(toplevel);
	win_id = XtWindow(toplevel);
	sprintf(string, "Window id: %d/0x%x", win_id, win_id);
	XtSetArg(args[n], XmNvalue, string); n++;
	XtSetValues(text, args, n);
	XtMainLoop();
}
*****END OF PROGRAM #1*****

*****START OF PROGRAM #2*****
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <X11/Xresource.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
#include <Xm/Xm.h>
#include <Xm/Text.h>

main(argc, argv)
int argc;
char *argv[];
{
	Widget toplevel;
	Arg args[10];
	int n=0;
	long flags;
	XID win_id;
	XWMHints *wm_hints;
	
	win_id = atoi(argv[1]);
	toplevel = XtInitialize(argv[0], "Child", NULL, 0, &argc, argv);
	XtCreateManagedWidget("child", xmTextWidgetClass, toplevel, NULL, 0);
	XtRealizeWidget(toplevel);
	wm_hints = XAllocWMHints();
	wm_hints -> flags = WindowGroupHint;
	wm_hints -> window_group = win_id;
	XSetWMHints(XtDisplay(toplevel), XtWindow(toplevel), wm_hints);
	XtMainLoop();
}
*****END OF PROGRAM #2*****
-- 
Jeremy Epstein			UUCP: uunet!trwacs!epstein
Trusted X Research Group	Internet: epstein@trwacs.fp.trw.com
TRW Systems Division		Voice: +1 703/876-8776
Fairfax Virginia

toml@marvin.Solbourne.COM (Tom LaStrange) (02/27/91)

} We're trying to build an application which has multiple top
} level windows, which we're then trying to group together using
} the window manager hints.  Our goal is that when we iconify the
} "master" window, the other top level window should be iconified
} as well.
} 
} The first of the following programs creates a top level window and
} displays the window ID.  The second program, when given the window
} ID from the first as a command line parameter, will create another
} top level window with the window_group field of the window manager
} hints set to the first window.
} 
} We've run these programs under mwm (1.1), twm, and olwm on X11R4
} on Sun 3 & Sun 4 systems.  Iconifying the first window does not
} iconify the second window.
} 
} Is this a misreading of ICCCM, a bug in the programs, or a problem
} with the window managers?  If it's a problem with the window managers,
} are there any window managers where this works properly?  Is this
} anywhere in the FAQ (I couldn't find it)?

The ICCCM doesn't really specify how window managers should use group hints.
I thought at one point twm would iconify a group if the leader was iconified,
I haven't tried it lately.

--
Tom LaStrange        toml@Solbourne.COM

dshr@eng.sun.COM (David Rosenthal) (02/27/91)

> We're trying to build an application which has multiple top
> level windows, which we're then trying to group together using
> the window manager hints.  Our goal is that when we iconify the
> "master" window, the other top level window should be iconified
> as well.
> 
You are trying to determine a window manager policy.  The general
window manager may not even have a concept of "iconifying a window".
The ICCCM (Section 4.1.11) specifically leaves it up to the
implementor of a window manager to determine the semantics it
attaches to the group:

	"It is up to the window manager to determine the policy for
	treating the windows in a group."

See also Section 4.1.2.4:

	"Window managers may provide facilities for manipulating the
	group as a whole.  Clients,  at present,  have no way to
	operate on the group as a whole."

Note the word "may",  because it implies also "may not".

> We've run these programs under mwm (1.1), twm, and olwm on X11R4
> on Sun 3 & Sun 4 systems.  Iconifying the first window does not
> iconify the second window.
> 
That is because the implementors of these window managers decided that
their user interface policy did not require that windows in a group
should be inconified/deiconified together.

> Is this a misreading of ICCCM, a bug in the programs, or a problem
> with the window managers?  If it's a problem with the window managers,
> are there any window managers where this works properly?  Is this
> anywhere in the FAQ (I couldn't find it)?
> 
It is a misreading of the ICCCM.  I don't know if there are existing
window managers which implement the policy you want.  You have two
choices:

-	If your application will only be run in a controlled environment
	where you decide which WM gets run,  you can hack on your
	favourite WM and implement the policy you like.

-	If you want your application to work right with the user's
	favourite WM,  you have to live with the fact that you don't know
	what its policy about window groups is (this shouldn't stop
	you providing it with the information about the group,  because
	it will probably do something sensible in the context of its
	overall user interface policy).

I would strongly recommend the second choice - programs that insist on
a particular window manager and a particular user interface to window
management are much to be deprecated.

	David.

yee@osf.org (Michael K. Yee) (02/28/91)

In article <269@trwacs.UUCP> epstein@trwacs.UUCP (Jeremy Epstein) writes:
:>   Is this a misreading of ICCCM, a bug in the programs, or a problem
:>   with the window managers?  If it's a problem with the window managers,
:>   are there any window managers where this works properly?  Is this
:>   anywhere in the FAQ (I couldn't find it)?
:>
:>   Thanks for any help!
:>   --Jeremy
:>
:>	   wm_hints = XAllocWMHints();
:>	   wm_hints -> flags = WindowGroupHint;
:>	   wm_hints -> window_group = win_id;
:>

	Currently Mwm 1.1 does not support window groups (may be in a future
	version).

	=Mike
--
= Michael K. Yee		-- yee@osf.org or uunet!osf.org!yee --
= OSF/Motif Development
= "I can't give you brains, but I can give you a diploma." -- The Wizard of OZ

nazgul@alphalpha.com (Kee Hinckley) (03/01/91)

In article <YEE.91Feb27154217@katana.osf.org> yee@osf.org (Michael K. Yee) writes:
>	Currently Mwm 1.1 does not support window groups (may be in a future
>	version).

A possible work around is to create all of your secondary windows as
non-modal dialogs.  Then they'll get iconized when the parent window
is iconized.
-- 
Alfalfa Software, Inc.          |       Poste:  The EMail for Unix
nazgul@alfalfa.com              |       Send Anything... Anywhere
617/646-7703 (voice/fax)        |       info@alfalfa.com

I'm not sure which upsets me more; that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

colas@lemur.inria.fr (Colas Nahaboo) (03/06/91)

> In article <269@trwacs.UUCP> epstein@trwacs.UUCP (Jeremy Epstein) writes:
> :>   Is this a misreading of ICCCM, a bug in the programs, or a problem
> :>   with the window managers?  If it's a problem with the window managers,
> :>   are there any window managers where this works properly?  Is this
> :>   anywhere in the FAQ (I couldn't find it)?

This is not a bug of WMs, just missing features.

Gwm (on expo, contrib/gwm) will allow you to customize it to design whatever WM
policy you have in mind. Just like Emacs, it has a built-in lisp interpreter.

For instance, in the default set-up, iconifying an icon will iconify the group,
unless the application is in a certain list of applications (Epoch for me).
Moreover, the menu has 3 entries for iconifying: 
	"normal" iconifying (only window, or whole group if called on leader)
	iconify whole group from any window of the group
	iconify all other windows of the group (very useful)

-- 
Colas Nahaboo, colas@sa.inria.fr, Bull Research, Koala Project, GWM X11 WM
Phone:(33) 93.65.77.70(.66 Fax), INRIA, B.P.109 - 06561 Valbonne Cedex, FRANCE.