kscreensaver_vroot.h00001
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef _VROOT_H_
00058 #define _VROOT_H_
00059
00060 #if !defined(lint) && !defined(SABER)
00061 static const char vroot_rcsid[] = "#Id: vroot.h,v 1.4 1991/09/30 19:23:16 stolcke Exp stolcke #";
00062 #endif
00063
00064 #include <qwidget.h>
00065 #ifdef Q_WS_X11
00066 #include <X11/X.h>
00067 #include <X11/Xatom.h>
00068 #include <X11/Xlib.h>
00069
00070 static Window
00071 #if defined(__STDC__) || defined(__cplusplus)
00072 VirtualRootWindowOfScreen(Screen *screen)
00073 #else
00074 VirtualRootWindowOfScreen(screen) Screen *screen;
00075 #endif
00076 {
00077 static Screen *save_screen = (Screen *)0;
00078 static Window root = (Window)0;
00079
00080 if (screen != save_screen) {
00081 Display *dpy = DisplayOfScreen(screen);
00082 Atom __SWM_VROOT = None;
00083 uint i;
00084 Window rootReturn, parentReturn, *children;
00085 unsigned int numChildren;
00086
00087 root = RootWindowOfScreen(screen);
00088
00089
00090 __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
00091 if (XQueryTree(dpy, root, &rootReturn, &parentReturn,
00092 &children, &numChildren)) {
00093 for (i = 0; i < numChildren; i++) {
00094 Atom actual_type;
00095 int actual_format;
00096 unsigned long nitems, bytesafter;
00097 unsigned char *newRoot = 0;
00098
00099 if (XGetWindowProperty(dpy, children[i],
00100 __SWM_VROOT, 0, 1, False, XA_WINDOW,
00101 &actual_type, &actual_format,
00102 &nitems, &bytesafter,
00103 &newRoot) == Success
00104 && newRoot)
00105 {
00106 void *tmpRoot = (void *) newRoot;
00107 root = *(Window*) tmpRoot;
00108 XFree( (char*) newRoot );
00109 break;
00110 }
00111 }
00112 if (children)
00113 XFree((char *)children);
00114 }
00115
00116 save_screen = screen;
00117 }
00118
00119 return root;
00120 }
00121
00122 #undef RootWindowOfScreen
00123 #define RootWindowOfScreen(s) VirtualRootWindowOfScreen(s)
00124
00125 #undef RootWindow
00126 #define RootWindow(dpy,screen) VirtualRootWindowOfScreen(ScreenOfDisplay(dpy,screen))
00127
00128 #undef DefaultRootWindow
00129 #define DefaultRootWindow(dpy) VirtualRootWindowOfScreen(DefaultScreenOfDisplay(dpy))
00130 #endif
00131
00132 #endif
|