xdbe replaced with more generic pixmap based buffering but there are 3 major bugs:
authorLance Colton <lance.colton@gmail.com>
Fri, 13 Jan 2012 06:00:39 +0000 (23:00 -0700)
committerLance Colton <lance.colton@gmail.com>
Fri, 13 Jan 2012 06:00:39 +0000 (23:00 -0700)
1) main_loop delay is broken or it is getting too many events to process or something because it just runs full speed, so it's using 100% cpu and doing like 20 frames per second instead of going to sleep
2) put code in xdbe_swap_buffers() to clear the back buffer I guess (XFillRectangle) but it's using a solid color so I had to disable that. Now it just makes a blurry mess
3) loading my usual cario / lua script crashes it with BadDrawable passed to X_GetGeometry

src/conky.c
src/x11.c
src/x11.h

index c766820..f55ca4e 100644 (file)
@@ -3633,6 +3633,20 @@ static void main_loop(void)
                                                draw_stuff(); /* redraw everything in our newly sized window */
                                                XResizeWindow(display, window.window, window.width,
                                                                window.height); /* resize window */
+                                               fprintf(stderr, PACKAGE_NAME": resizing window to %d x %d\n",window.width,window.height);
+#ifdef HAVE_XDBE
+                                               if (use_xdbe) {
+                                                       XFreePixmap(display, window.back_buffer);
+                                                       window.back_buffer = XCreatePixmap(display, window.window,
+                                                                                                                          window.width, window.height, window.depth);
+                                                       if (window.back_buffer != None)
+                                                               window.drawable = window.back_buffer;
+                                                       else {
+                                                               window.drawable = window.window;
+                                                               use_xdbe = 0;
+                                                       }
+                                               }
+#endif
                                                set_transparent_background(window.window, own_window_argb_value);
 #ifdef HAVE_XDBE
                                                /* swap buffers */
@@ -3758,7 +3772,21 @@ static void main_loop(void)
                                                                                        window.window, &attrs)) {
                                                                                window.width = attrs.width;
                                                                                window.height = attrs.height;
+                                                                               fprintf(stderr, PACKAGE_NAME": x11? resized our window to %d x %d\n",window.width,window.height);
                                                                        }
+#ifdef HAVE_XDBE
+                                                                       if (use_xdbe) {
+                                                                               XFreePixmap(display, window.back_buffer);
+                                                                               window.back_buffer = XCreatePixmap(display, window.window,
+                                                                                                                                                  window.width, window.height, window.depth);
+                                                                               if (window.back_buffer != None)
+                                                                                       window.drawable = window.back_buffer;
+                                                                               else {
+                                                                                       window.drawable = window.window;
+                                                                                       use_xdbe = 0;
+                                                                               }
+                                                                       }
+#endif
                                                                }
 
                                                                text_width = window.width - window.border_inner_margin * 2 - window.border_outer_margin * 2 - window.border_width * 2;
@@ -3888,6 +3916,7 @@ static void main_loop(void)
                } else {
 #endif /* X11 */
                        t = (next_update_time - get_time()) * 1000000;
+                       fprintf(stderr, PACKAGE_NAME": trying to sleep %d microseconds\n",t);
                        if(t > 0) usleep((useconds_t)t);
                        update_text();
                        draw_stuff();
index ba65fcb..e933a64 100644 (file)
--- a/src/x11.c
+++ b/src/x11.c
@@ -259,6 +259,12 @@ void destroy_window(void)
        if(window.gc) {
                XFreeGC(display, window.gc);
        }
+       if(window.gc_back) {
+               XFreeGC(display, window.gc_back);
+       }
+       if(window.back_buffer != None) {
+               XFreePixmap(display, window.back_buffer);
+       }
        memset(&window, 0, sizeof(struct conky_window));
        colour_set = -1;
 }
@@ -352,6 +358,8 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
                                window.x = window.y = 0;
                        }
                        /* Parent is root window so WM can take control */
+
+                       fprintf(stderr, PACKAGE_NAME": creating window of %d x %d x %d\n",w,h,depth);
                        window.window = XCreateWindow(display, window.root, window.x,
                                        window.y, w, h, 0, depth, InputOutput, visual,
                                        flags, &attrs);
@@ -504,8 +512,8 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
 
                        /* Skip pager */
                        if (TEST_HINT(window.hints, HINT_FULLSCREEN)) {
-                               /* fprintf(stderr, PACKAGE_NAME": hint - skip_pager\n");
-                                  fflush(stderr); */
+                               fprintf(stderr, PACKAGE_NAME": hint - fullscreen\n");
+                               fflush(stderr);
 
                                xa = ATOM(_NET_WM_STATE);
                                if (xa != None) {
@@ -526,20 +534,23 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
        } else
 #endif /* OWN_WINDOW */
        {
-               XWindowAttributes attrs;
-
                if (!window.window) {
                        window.window = find_desktop_window(&window.root, &window.desktop);
                }
                window.visual = DefaultVisual(display, screen);
                window.colourmap = DefaultColormap(display, screen);
 
+               fprintf(stderr, PACKAGE_NAME": drawing to desktop window\n");
+       }
+
+       {
+               fprintf(stderr, PACKAGE_NAME": getting window attrs\n");
+               XWindowAttributes attrs;
                if (XGetWindowAttributes(display, window.window, &attrs)) {
                        window.width = attrs.width;
                        window.height = attrs.height;
+                       window.depth = attrs.depth;
                }
-
-               fprintf(stderr, PACKAGE_NAME": drawing to desktop window\n");
        }
 
        /* Drawable is same as window. This may be changed by double buffering. */
@@ -547,16 +558,12 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
 
 #ifdef HAVE_XDBE
        if (use_xdbe) {
-               int major, minor;
-
-               if (!XdbeQueryExtension(display, &major, &minor)) {
-                       use_xdbe = 0;
-               } else {
-                       window.back_buffer = XdbeAllocateBackBufferName(display,
-                                       window.window, XdbeBackground);
+               {
+                       window.back_buffer = XCreatePixmap(display, window.window,
+                                                                                          window.width, window.height, window.depth);
                        if (window.back_buffer != None) {
                                window.drawable = window.back_buffer;
-                               fprintf(stderr, PACKAGE_NAME": drawing to double buffer\n");
+                               fprintf(stderr, PACKAGE_NAME": created %d x %d x %d back buffer\n",window.width, window.height, window.depth);
                        } else {
                                use_xdbe = 0;
                        }
@@ -627,6 +634,8 @@ void create_gc(void)
        values.function = GXcopy;
        window.gc = XCreateGC(display, window.drawable,
                        GCFunction | GCGraphicsExposures, &values);
+       window.gc_back = XCreateGC(display, window.drawable,
+                       GCFunction | GCGraphicsExposures, &values);
 }
 
 //Get current desktop number
@@ -856,11 +865,16 @@ void set_struts(int sidenum)
 void xdbe_swap_buffers(void)
 {
        if (use_xdbe) {
-               XdbeSwapInfo swap;
-
-               swap.swap_window = window.window;
-               swap.swap_action = XdbeBackground;
-               XdbeSwapBuffers(display, &swap, 1);
+               //XWindowAttributes dest;//leaks
+               //XGetWindowAttributes(display, window.window, &dest);
+               //unsigned int src_height, src_width, src_depth = 0;
+               //XGetGeometry(display, window.back_buffer, NULL, NULL, NULL,src_width,src_height, NULL, src_depth);
+//             fprintf(stderr, PACKAGE_NAME": copy from %d x %d x %d to %d x %d x %d\n",src_width, src_height, src_depth, dest.width, dest.height, dest.depth);
+               XCopyArea(display, window.drawable, window.window,
+                                 window.gc_back, 0, 0, window.width, window.height, 0, 0);
+               /* FIXME should fill w/ window background */
+//             XFillRectangle(display, window.back_buffer, window.gc,
+//                                        0, 0, window.width, window.height);
        }
 }
 #endif /* HAVE_XDBE */
index 7c2d018..d30a775 100644 (file)
--- a/src/x11.h
+++ b/src/x11.h
 #include <X11/Xft/Xft.h>
 #endif
 
-#ifdef HAVE_XDBE
-#include <X11/extensions/Xdbe.h>
-#endif
-
 #define ATOM(a) XInternAtom(display, #a, False)
 
 #ifdef OWN_WINDOW
@@ -49,7 +45,7 @@ struct conky_window {
        long border_inner_margin, border_outer_margin, border_width;
 
 #ifdef HAVE_XDBE
-       XdbeBackBuffer back_buffer;
+        Pixmap back_buffer;
 #endif
 #ifdef XFT
        XftDraw *xftdraw;
@@ -65,6 +61,8 @@ struct conky_window {
        unsigned int type;
        unsigned long hints;
 #endif
+    int depth;
+       GC gc_back;
 };
 
 #ifdef HAVE_XDBE