don't check the result of composite_name_window_pixmap(). it ends up hanging sometim...
authorDana Jansens <danakj@orodu.net>
Wed, 5 Mar 2008 18:49:36 +0000 (13:49 -0500)
committerDana Jansens <danakj@orodu.net>
Wed, 5 Mar 2008 18:49:36 +0000 (13:49 -0500)
render.c
window.c

index 7950419..f9b1465 100644 (file)
--- a/render.c
+++ b/render.c
@@ -322,13 +322,15 @@ paint_window(d_window_t *w, data_t *d)
     pict = render_get_picture(w, wd);
 
     //printf("-- paint window 0x%x picture 0x%x --\n", w->id, wd->picture);
-    window_get_area(w, &x, &y, &width, &height, &bwidth);
-    xcb_render_composite(w->sc->dpy->conn,
-                         //XCB_RENDER_PICT_OP_SRC,  /* - for solid */
-                         XCB_RENDER_PICT_OP_OVER, /* - for argb */
-                         wd->picture,
-                         XCB_NONE,
-                         d->overlay_buffer,
-                         0, 0, 0, 0,
-                         x, y, width + bwidth*2, height + bwidth *2);
+    if (pict) {
+        window_get_area(w, &x, &y, &width, &height, &bwidth);
+        xcb_render_composite(w->sc->dpy->conn,
+                             //XCB_RENDER_PICT_OP_SRC,  /* - for solid */
+                             XCB_RENDER_PICT_OP_OVER, /* - for argb */
+                             pict,
+                             XCB_NONE,
+                             d->overlay_buffer,
+                             0, 0, 0, 0,
+                             x, y, width + bwidth*2, height + bwidth *2);
+    }
 }
index a56899a..3aa9a95 100644 (file)
--- a/window.c
+++ b/window.c
@@ -39,8 +39,6 @@ typedef struct {
     xcb_get_window_attributes_cookie_t ck_get_attr;
     gboolean waiting_geom;
     xcb_get_geometry_cookie_t          ck_get_geom;
-    gboolean waiting_pixmap;
-    xcb_void_cookie_t                  ck_get_pixmap;
 } d_window_priv_t;
 
 static void window_get_attributes_reply(d_window_priv_t *w);
@@ -68,8 +66,6 @@ window_new(xcb_window_t id, struct d_screen *sc)
     w->ck_get_geom = xcb_get_geometry(sc->dpy->conn, id);
     w->waiting_geom = TRUE;
 
-    w->waiting_pixmap = FALSE;
-
     w->plugin_data = list_new();
 
     //printf("new window 0x%x\n", w->id);
@@ -91,12 +87,12 @@ window_unref(d_window_t *pubw)
     d_window_priv_t *w = (d_window_priv_t*)pubw;
 
     if (w && --w->ref == 0) {
-        xcb_pixmap_t p;
-
         screen_stacking_remove(w->sc, (d_window_t*)w);
 
-        if ((p = window_get_pixmap(pubw))) {
-            xcb_free_pixmap(w->sc->dpy->conn, p);
+        if (w->pixmap) {
+            /* this may cause an error if the pixmap was never valid, but
+               that's fine */
+            xcb_free_pixmap(w->sc->dpy->conn, w->pixmap);
             w->pixmap = XCB_NONE;
         }
 
@@ -105,6 +101,15 @@ window_unref(d_window_t *pubw)
     }
 }
 
+xcb_pixmap_t
+window_get_pixmap(d_window_t *pubw)
+{
+    d_window_priv_t *w = (d_window_priv_t*)pubw;
+
+    return w->pixmap;
+}
+
+
 static void
 window_update_pixmap(d_window_priv_t *w)
 {
@@ -120,11 +125,13 @@ window_update_pixmap(d_window_priv_t *w)
 
     //printf("updating pixmap for 0x%x\n", w->id);
 
+    /* we don't check the result of this call, because it seems that sometimes
+       the X server just doesn't reply.  if we check it, we end up hanging
+       sometimes waiting for the reply */
     w->pixmap = xcb_generate_id(w->sc->dpy->conn);
-    w->ck_get_pixmap = 
-        xcb_composite_name_window_pixmap_checked(w->sc->dpy->conn,
-                                                 w->id, w->pixmap);
-    w->waiting_pixmap = TRUE;
+    xcb_composite_name_window_pixmap(w->sc->dpy->conn, w->id, w->pixmap);
+    //printf("requested pixmap sequence %u\n", w->ck_get_pixmap.sequence);
+    //fflush(stdout);
     xcb_flush(w->sc->dpy->conn);
 }
 
@@ -276,26 +283,6 @@ window_is_attr_mapped(d_window_t *pubw)
     return w->attr_mapped;
 }
 
-xcb_pixmap_t
-window_get_pixmap(d_window_t *pubw)
-{
-    d_window_priv_t *w = (d_window_priv_t*)pubw;
-
-    if (w->waiting_pixmap) {
-        xcb_generic_error_t *err;
-        //printf("** checking get pixmap 0x%x\n", w->id);
-        err = xcb_request_check(w->sc->dpy->conn, w->ck_get_pixmap);
-        if (err) {
-            w->pixmap = XCB_NONE;
-            printf("error getting named pixmap for window 0x%x\n", w->id);
-            free(err);
-        }
-        w->waiting_pixmap = FALSE;
-    }
-    //printf("returning pixmap 0x%x for window 0x%x\n", w->pixmap, w->id);
-    return w->pixmap;
-}
-
 xcb_visualid_t
 window_get_visual(d_window_t *pubw)
 {