debian building now does it with everything enabled in ./configure
[monky] / src / x11.c
index e0b6d9e..40aa64c 100644 (file)
--- a/src/x11.c
+++ b/src/x11.c
@@ -27,6 +27,8 @@ Display *display;
 int display_width;
 int display_height;
 int screen;
+static int set_transparent;
+static int background_colour;
 
 /* workarea from _NET_WORKAREA, this is where window / text is aligned */
 int workarea[4];
@@ -143,34 +145,42 @@ static Window find_window_to_draw()
 }
 
 /* sets background to ParentRelative for the Window and all parents */
-void set_transparent_background(Window win)
+inline void set_transparent_background(Window win)
 {
-       Window parent = win;
-       unsigned int i;
-       for (i = 0; i < 16 && parent != RootWindow(display, screen); i++) {
-               Window r, *children;
-               unsigned int n;
-
-               XSetWindowBackgroundPixmap(display, parent,
-                                          ParentRelative);
-
-               XQueryTree(display, parent, &r, &parent, &children, &n);
-               XFree(children);
+       static int colour_set = -1;
+       if (set_transparent) {
+               Window parent = win;
+               unsigned int i;
+               for (i = 0; i < 50 && parent != RootWindow(display, screen); i++) {
+                       Window r, *children;
+                       unsigned int n;
+                       
+                       XSetWindowBackgroundPixmap(display, parent, ParentRelative);
+       
+                       XQueryTree(display, parent, &r, &parent, &children, &n);
+                       XFree(children);
+                       }
+       } else if (colour_set != background_colour) {
+               XSetWindowBackground(display, win, background_colour);
+               colour_set = background_colour;
        }
-       XClearWindow(display, win);
+       //XClearWindow(display, win);
 }
 
 #if defined OWN_WINDOW
-void init_window(int own_window, int w, int h, int l, int fixed_pos)
+void init_window(int own_window, int w, int h, int l, int fixed_pos, int set_trans, int back_colour)
 #else
-void init_window(int own_window, int w, int h, int l)
+void init_window(int own_window, int w, int h, int l, int set_trans, int back_colour)
 #endif
 {
        /* There seems to be some problems with setting transparent background (on
         * fluxbox this time). It doesn't happen always and I don't know why it
         * happens but I bet the bug is somewhere here. */
+       set_transparent = set_trans;
+       background_colour = back_colour;
 #ifdef OWN_WINDOW
        if (own_window) {
+
                /* looks like root pixmap isn't needed for anything */
                {
                        XSetWindowAttributes attrs;
@@ -190,7 +200,7 @@ void init_window(int own_window, int w, int h, int l)
                        XSetClassHint(display, window.window,
                                      &class_hints);
 
-                       set_transparent_background(window.window);
+                       /*set_transparent_background(window.window);*/
 
                        XStoreName(display, window.window, "conky");
 
@@ -198,7 +208,7 @@ void init_window(int own_window, int w, int h, int l)
 
                        if (!fixed_pos)
                                XMoveWindow(display, window.window, window.x,
-                                           window.y);
+                       window.y);
                }
 
                {
@@ -280,12 +290,12 @@ void init_window(int own_window, int w, int h, int l)
 
        XFlush(display);
 
-       /* set_transparent_background() must be done after double buffer stuff? */
+       /*set_transparent_background(window.window); must be done after double buffer stuff? */
 #ifdef OWN_WINDOW
-       if (own_window) {
-               set_transparent_background(window.window);
+       /*if (own_window) {
+       set_transparent_background(window.window);
                XClearWindow(display, window.window);
-       }
+}*/
 #endif
 
        XSelectInput(display, window.window, ExposureMask