home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / XfeWidgets / Xfe / WmUtil.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.8 KB  |  88 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /*-----------------------------------------*/
  19. /*                                                                        */
  20. /* Name:        <Xfe/WmUtil.c>                                            */
  21. /* Description:    Window manager utilities source.                        */
  22. /* Author:        Ramiro Estrugo <ramiro@netscape.com>                    */
  23. /*                                                                        */
  24. /*----------------------------------------------------------------------*/
  25.  
  26.  
  27. #include <Xfe/XfeP.h>
  28.  
  29. /*----------------------------------------------------------------------*/
  30. /*                                                                        */
  31. /* OpenLook                                                                */
  32. /*                                                                        */
  33. /*----------------------------------------------------------------------*/
  34. /* extern */ Boolean
  35. XfeIsOpenLookRunning(Widget w)
  36. {
  37.     Widget            app_shell = XfeAncestorFindApplicationShell(w);
  38.     Display *        dpy = XtDisplay(app_shell);
  39.     int                result;
  40.     Atom            actual_type = 0;
  41.     int                actual_format = 0;
  42.     unsigned long    nitems = 0;
  43.     unsigned long    bytes_after = 0;
  44.     unsigned char *    data = 0;
  45.     
  46.     Atom proto_atom = XInternAtom(dpy, "_SUN_WM_PROTOCOLS", True);
  47.  
  48.     /* If the atom isn't interned, OLWM can't be running. */
  49.     if (proto_atom == None)
  50.     {
  51.         return False;
  52.     }
  53.  
  54.     result=XGetWindowProperty(dpy,
  55.                               RootWindowOfScreen(DefaultScreenOfDisplay(dpy)),
  56.                               proto_atom,
  57.                               0, 0,            /* read 0 bytes */
  58.                               False,           /* don't delete */
  59.                               AnyPropertyType, /* type expected */
  60.                               &actual_type,    /* returned values */
  61.                               &actual_format,
  62.                               &nitems,
  63.                               &bytes_after,
  64.                               &data);
  65.     
  66.     /* At most, this will be 1 allocated byte. */
  67.     if (data)
  68.     {
  69.         XtFree(data);
  70.     }
  71.         
  72.     /* If any of these are true, then OLWM isn't running. */
  73.     if (result != Success ||            /* no such property */
  74.         actual_type != XA_ATOM ||       /* didn't contain type Atom */
  75.         bytes_after <= 0)               /* zero length */
  76.     {
  77.         return False;
  78.     }
  79.     
  80.     /*
  81.      * Otherwise, it sure looks like OLWM is running.  If it's not, 
  82.      * then it's some other program that is imitating it well. 
  83.      */
  84.     
  85.     return True;
  86. }
  87. /*----------------------------------------------------------------------*/
  88.