[comp.windows.x] IS THERE A WINDOW MGR ?

rmarks@KSP.Unisys.COM (Richard Marks) (09/20/90)

Hello all,

Could someone tell me how a client program can determine
if there is a window manager running for a given screen?

I am looking for a general mechanism.  I know I can code
up specific tests for the WM's currently available on
my clients.

Thanks,
Richard Marks
rmarks@KSP.unisys.COM

mikey@eukanuba.wpd.sgi.com (Mike Yang) (09/20/90)

In article <772@bbking.KSP.Unisys.COM>, rmarks@KSP.Unisys.COM (Richard Marks) writes:
|> Could someone tell me how a client program can determine
|> if there is a window manager running for a given screen?
|> 
|> I am looking for a general mechanism.  I know I can code
|> up specific tests for the WM's currently available on
|> my clients.

Most gindow managers these days select for SubstructureRedirect on the
root window, so that they can reparent application windows.  Since
only one client per window can select for these events, try celecting
for SubstructureRedirect on the root window of the screen.  If an
error occurs (use an error handler), you can assume that a window
manager is running.

-----------------------------------------------------------------------
                 Mike Yang        Silicon Graphics, Inc.
               mikey@sgi.com           415/335-1786

mikey@eukanuba.wpd.sgi.com (Mike Yang) (09/20/90)

In article <772@bbking.KSP.Unisys.COM>, rmarks@KSP.Unisys.COM (Richard Marks) writes:
|> Could someone tell me how a client program can determine
|> if there is a window manager running for a given screen?
|> 
|> I am looking for a general mechanism.  I know I can code
|> up specific tests for the WM's currently available on
|> my clients.

Most window managers these days select for SubstructureRedirect on the
root window, so that they can reparent application windows.  Since
only one client per window can select for these events, try selecting
for SubstructureRedirect on the root window of the screen.  If an
error occurs (use an error handler), you can assume that a window
manager is running.

-----------------------------------------------------------------------
                 Mike Yang        Silicon Graphics, Inc.
               mikey@sgi.com           415/335-1786

mouse@LARRY.MCRCIM.MCGILL.EDU (09/22/90)

>> Could someone tell me how a client program can determine if there is
>> a window manager running for a given screen?

>> I am looking for a general mechanism.  I know I can code up specific
>> tests for the WM's currently available on my clients.

> Most window managers these days select for SubstructureRedirect on
> the root window, so that they can reparent application windows.

But note that this is only "most".  A general mechanism it isn't.  (I
don't believe any such general mechanism exists; this is probably as
close as you can come.)

> Since only one client per window can select for these events, try
> selecting for SubstructureRedirect on the root window of the screen.
> If an error occurs (use an error handler), you can assume that a
> window manager is running.

But if no error occurs, you cannot necessaily assume that no window
manager is running.  Note that doing this is dangerous because there is
the potential for another client to start up during the time you have
SubstructureRedirectMask selected (in the case where the SelectInput
succeeds, in which case you will get a request event and the client
that tried to start will be left out in the cold.  It would be better
to use XGetWindowAttributes.  In the XWindowAttributes structure
returned there is a member

     long all_event_masks;    /* set of events all people have interest in*/

which is documented as

	The all_event_masks member is set to the bitwise inclusive
	OR of all event masks selected on the window by all clients.

So, if SubstructureRedirectMask is set then someone has selected for
it, and there's no danger of your causing some random other client
grief in the process.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu