"Fossies" - the Fresh Open Source Software Archive

Member "xlockmore-5.59/xlock/vroot.h" (28 Oct 2007, 5239 Bytes) of package /linux/misc/xlockmore-5.59.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "vroot.h" see the Fossies "Dox" file reference documentation.

    1 #ifndef _VROOT_H_
    2 #define _VROOT_H_
    3 
    4 #if !defined( lint ) && !defined( SABER )
    5 /* #ident   "@(#)vroot.h    4.14 99/06/17 xlockmore" */
    6 
    7 #endif
    8 
    9 /*****************************************************************************/
   10 /**                   Copyright 1991 by Andreas Stolcke                     **/
   11 /**               Copyright 1990 by Solbourne Computer Inc.                 **/
   12 /**                          Longmont, Colorado                             **/
   13 /**                                                                         **/
   14 /**                           All Rights Reserved                           **/
   15 /**                                                                         **/
   16 /**    Permission to use, copy, modify, and distribute this software and    **/
   17 /**    its documentation  for  any  purpose  and  without  fee is hereby    **/
   18 /**    granted, provided that the above copyright notice appear  in  all    **/
   19 /**    copies and that both  that  copyright  notice  and  this  permis-    **/
   20 /**    sion  notice appear in supporting  documentation,  and  that  the    **/
   21 /**    name of Solbourne not be used in advertising                         **/
   22 /**    in publicity pertaining to distribution of the  software  without    **/
   23 /**    specific, written prior permission.                                  **/
   24 /**                                                                         **/
   25 /**    ANDREAS STOLCKE AND SOLBOURNE COMPUTER INC. DISCLAIMS ALL WARRANTIES **/
   26 /**    WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF    **/
   27 /**    MERCHANTABILITY  AND  FITNESS,  IN  NO  EVENT SHALL ANDREAS STOLCKE  **/
   28 /**    OR SOLBOURNE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL    **/
   29 /**    DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA   **/
   30 /**    OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER    **/
   31 /**    TORTIOUS ACTION, ARISING OUT OF OR IN  CONNECTION  WITH  THE  USE    **/
   32 /**    OR PERFORMANCE OF THIS SOFTWARE.                                     **/
   33 /*****************************************************************************/
   34 /*-
   35  * vroot.h -- Virtual Root Window handling header file
   36  *
   37  * This header file redefines the X11 macros RootWindow and DefaultRootWindow,
   38  * making them look for a virtual root window as provided by certain `virtual'
   39  * window managers like swm and tvtwm. If none is found, the ordinary root
   40  * window is returned, thus retaining backward compatibility with standard
   41  * window managers.
   42  * The function implementing the virtual root lookup remembers the result of
   43  * its last invocation to avoid overhead in the case of repeated calls
   44  * on the same display and screen arguments.
   45  * The lookup code itself is taken from Tom LaStrange's ssetroot program.
   46  *
   47  * Most simple root window changing X programs can be converted to using
   48  * virtual roots by just including
   49  *
   50  * #include <X11/vroot.h>
   51  *
   52  * after all the X11 header files.  It has been tested on such popular
   53  * X clients as xphoon, xfroot, xloadimage, and xaqua.
   54  * It also works with the core clients xprop, xwininfo, xwd, and editres
   55  * (and is necessary to get those clients working under tvtwm).
   56  * It does NOT work with xsetroot; get the xsetroot replacement included in
   57  * the tvtwm distribution instead.
   58  *
   59  * Andreas Stolcke <stolcke@ICSI.Berkeley.EDU>, 9/7/90
   60  * - replaced all NULL's with properly cast 0's, 5/6/91
   61  * - free children list (suggested by Mark Martin <mmm@cetia.fr>), 5/16/91
   62  * - include X11/Xlib.h and support RootWindowOfScreen, too 9/17/91
   63  */
   64 
   65 #ifdef VMS
   66 #include "vms_x_fix.h"
   67 #endif
   68 
   69 #include <X11/X.h>
   70 #include <X11/Xatom.h>
   71 #include <X11/Xlib.h>
   72 
   73 static      Window
   74 VirtualRootWindowOfScreen(Screen * s)
   75 {
   76     static Screen *save_screen = (Screen *) 0;
   77     static Window root = (Window) 0;
   78 
   79     if (s != save_screen) {
   80 
   81         root = RootWindowOfScreen(s);
   82 
   83         /* go look for a virtual root */
   84 #if 0
   85 /*-
   86  * I forget why I put this here....
   87  * With this it screws up the mouse focus with xscreensaver.
   88  */
   89         if (inroot)
   90 #endif
   91         {
   92             Display    *dpy = DisplayOfScreen(s);
   93             Atom        __SWM_VROOT;
   94             int         i;
   95             Window      rootReturn, parentReturn, *children;
   96             unsigned int numChildren;
   97 
   98             __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
   99             if (XQueryTree(dpy, root, &rootReturn, &parentReturn,
  100                        &children, &numChildren)) {
  101                 for (i = 0; i < (int) numChildren; i++) {
  102                     Atom        actual_type;
  103                     int         actual_format;
  104                     unsigned long nitems, bytesafter;
  105                     Window     *newRoot = (Window *) 0;
  106 
  107                     if (XGetWindowProperty(dpy, children[i],
  108                      __SWM_VROOT, 0, 1, False, XA_WINDOW,
  109                         &actual_type, &actual_format,
  110                             &nitems, &bytesafter,
  111                             (unsigned char **) &newRoot) == Success && newRoot) {
  112                         root = *newRoot;
  113                         break;
  114                     }
  115                 }
  116                 if (children)
  117                     XFree((caddr_t) children);
  118             }
  119         }
  120         save_screen = s;
  121     }
  122     return root;
  123 }
  124 
  125 #undef RootWindowOfScreen
  126 #define RootWindowOfScreen(s) VirtualRootWindowOfScreen(s)
  127 
  128 #undef RootWindow
  129 #define RootWindow(dpy,s) VirtualRootWindowOfScreen(ScreenOfDisplay(dpy,s))
  130 
  131 #undef DefaultRootWindow
  132 #define DefaultRootWindow(dpy) VirtualRootWindowOfScreen(DefaultScreenOfDisplay(dpy))
  133 
  134 #endif /* _VROOT_H_ */