• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libtdescreensaver
 

libtdescreensaver

  • libtdescreensaver
tdescreensaver_vroot.h
1 /*****************************************************************************/
25 /*****************************************************************************/
26 /*
27  * vroot.h -- Virtual Root Window handling header file
28  *
29  * This header file redefines the X11 macros RootWindow and DefaultRootWindow,
30  * making them look for a virtual root window as provided by certain `virtual'
31  * window managers like swm and tvtwm. If none is found, the ordinary root
32  * window is returned, thus retaining backward compatibility with standard
33  * window managers.
34  * The function implementing the virtual root lookup remembers the result of
35  * its last invocation to avoid overhead in the case of repeated calls
36  * on the same display and screen arguments.
37  * The lookup code itself is taken from Tom LaStrange's ssetroot program.
38  *
39  * Most simple root window changing X programs can be converted to using
40  * virtual roots by just including
41  *
42  * #include <X11/vroot.h>
43  *
44  * after all the X11 header files. It has been tested on such popular
45  * X clients as xphoon, xfroot, xloadimage, and xaqua.
46  * It also works with the core clients xprop, xwininfo, xwd, and editres
47  * (and is necessary to get those clients working under tvtwm).
48  * It does NOT work with xsetroot; get the xsetroot replacement included in
49  * the tvtwm distribution instead.
50  *
51  * Andreas Stolcke <stolcke@ICSI.Berkeley.EDU>, 9/7/90
52  * - replaced all NULL's with properly cast 0's, 5/6/91
53  * - free children list (suggested by Mark Martin <mmm@cetia.fr>), 5/16/91
54  * - include X11/Xlib.h and support RootWindowOfScreen, too 9/17/91
55  */
56 
57 #ifndef _VROOT_H_
58 #define _VROOT_H_
59 
60 #if !defined(lint) && !defined(SABER)
61 static const char vroot_rcsid[] = "#Id: vroot.h,v 1.4 1991/09/30 19:23:16 stolcke Exp stolcke #";
62 #endif
63 
64 #include <tqwidget.h>
65 #ifdef TQ_WS_X11
66 #include <X11/X.h>
67 #include <X11/Xatom.h>
68 #include <X11/Xlib.h>
69 
70 static Window
71 #if defined(__STDC__) || defined(__cplusplus) /* ANSIfication added by jwz, to avoid superfluous warnings. */
72 VirtualRootWindowOfScreen(Screen *screen)
73 #else /* !__STDC__ */
74 VirtualRootWindowOfScreen(screen) Screen *screen;
75 #endif /* !__STDC__ */
76 {
77  static Screen *save_screen = (Screen *)0;
78  static Window root = (Window)0;
79 
80  if (screen != save_screen) {
81  Display *dpy = DisplayOfScreen(screen);
82  Atom __SWM_VROOT = None;
83  uint i;
84  Window rootReturn, parentReturn, *children;
85  unsigned int numChildren;
86 
87  root = RootWindowOfScreen(screen);
88 
89  /* go look for a virtual root */
90  __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
91  if (XQueryTree(dpy, root, &rootReturn, &parentReturn,
92  &children, &numChildren)) {
93  for (i = 0; i < numChildren; i++) {
94  Atom actual_type;
95  int actual_format;
96  unsigned long nitems, bytesafter;
97  unsigned char *newRoot = 0;
98 
99  if (XGetWindowProperty(dpy, children[i],
100  __SWM_VROOT, 0, 1, False, XA_WINDOW,
101  &actual_type, &actual_format,
102  &nitems, &bytesafter,
103  &newRoot) == Success
104  && newRoot)
105  {
106  void *tmpRoot = (void *) newRoot;
107  root = *(Window*) tmpRoot;
108  XFree( (char*) newRoot );
109  break;
110  }
111  }
112  if (children)
113  XFree((char *)children);
114  }
115 
116  save_screen = screen;
117  }
118 
119  return root;
120 }
121 
122 #undef RootWindowOfScreen
123 #define RootWindowOfScreen(s) VirtualRootWindowOfScreen(s)
124 
125 #undef RootWindow
126 #define RootWindow(dpy,screen) VirtualRootWindowOfScreen(ScreenOfDisplay(dpy,screen))
127 
128 #undef DefaultRootWindow
129 #define DefaultRootWindow(dpy) VirtualRootWindowOfScreen(DefaultScreenOfDisplay(dpy))
130 #endif
131 
132 #endif /* _VROOT_H_ */

libtdescreensaver

Skip menu "libtdescreensaver"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members

libtdescreensaver

Skip menu "libtdescreensaver"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for libtdescreensaver by doxygen 1.9.1
This website is maintained by Timothy Pearson.