make sure the window's region is correct, and if we fail to update the region cuz...
authorDana Jansens <danakj@orodu.net>
Sun, 16 Mar 2008 16:52:05 +0000 (12:52 -0400)
committerDana Jansens <danakj@orodu.net>
Sun, 16 Mar 2008 16:52:05 +0000 (12:52 -0400)
glxrender.c
render.c
window.c

index 62b5465..9186ca8 100644 (file)
@@ -604,7 +604,7 @@ glxrender_window_reshape(d_window_t *w)
     d->window_reshape(w);
 
     assert(wd != NULL);
-    glxrender_free_window_pixmap(w, d, wd);
+    //glxrender_free_window_pixmap(w, d, wd);
     glxrender_fetch_window_region(w, wd);
 }
 
index bc55044..103f1d4 100644 (file)
--- a/render.c
+++ b/render.c
@@ -65,6 +65,8 @@ static void paint_shadow(d_window_t *w, data_t *d, window_data_t *wd,
 static void render_update_picture(d_window_t *w, data_t *d, window_data_t *wd);
 static void render_update_root_picture(d_screen_t *sc, data_t *d);
 static void render_free_picture(d_window_t *w, window_data_t *wd);
+static void render_redraw_window(d_window_t *w, data_t *d,
+                                 gboolean shadow, window_data_t *wd);
 static xcb_render_pictformat_t find_visual_format(data_t *d,
                                                   xcb_visualid_t visual);
 static xcb_render_pictformat_t find_argb32_format(data_t *d);
@@ -276,14 +278,8 @@ render_window_zombie_dead(d_window_t *w)
     d = screen_find_plugin_data(w->sc, plugin_id);
     wd = window_find_plugin_data(w, plugin_id);
     if (wd) {
-        /* make sure the shadow region is right */
-        render_update_shadow(w, d, wd);
-
-        /* redraw the window's area, and its shadow's as well */
-        xcb_xfixes_union_region(w->sc->dpy->conn, d->damaged_region,
-                                window_get_region(w), d->damaged_region);
-        xcb_xfixes_union_region(w->sc->dpy->conn, d->damaged_region,
-                                wd->shadow_region, d->damaged_region);
+        /* redraw the window and its shadow */
+        render_redraw_window(w, d, TRUE, wd);
 
         render_window_free(w, wd);
         window_remove_plugin_data(w, plugin_id);
@@ -472,7 +468,7 @@ render_window_reshape(d_window_t *w)
     d->window_reshape(w);
 
     assert(wd != NULL);
-    render_free_picture(w, wd);
+    //render_free_picture(w, wd);
 
     /* redraw the screen */
     xcb_xfixes_copy_region(w->sc->dpy->conn, d->all_region, d->damaged_region);
@@ -495,14 +491,34 @@ render_window_restack(d_window_t *w, d_window_t *above)
     /* the window might not be visible */
     if (wd == NULL) return;
 
-    /* make sure the shadow region is right */
-    render_update_shadow(w, d, wd);
+    /* redraw the window and its shadow */
+    render_redraw_window(w, d, TRUE, wd);
+}
+
+/* wd is only needed if redrawing the shadow */
+static void
+render_redraw_window(d_window_t *w, data_t *d,
+                     gboolean shadow, window_data_t *wd)
+{
+    xcb_xfixes_region_t region = window_get_region(w);
 
-    /* redraw the window's contents, and its shadow as well */
-    xcb_xfixes_union_region(w->sc->dpy->conn, d->damaged_region,
-                            window_get_region(w), d->damaged_region);
-    xcb_xfixes_union_region(w->sc->dpy->conn, d->damaged_region,
-                            wd->shadow_region, d->damaged_region);
+    if (region) {
+        /* redraw the window's contents, and its shadow as well */
+        xcb_xfixes_union_region(w->sc->dpy->conn, d->damaged_region,
+                                region, d->damaged_region);
+
+        if (shadow) {
+            /* make sure the shadow region is right */
+            render_update_shadow(w, d, wd);
+            xcb_xfixes_union_region(w->sc->dpy->conn, d->damaged_region,
+                                    wd->shadow_region, d->damaged_region);
+        }
+    }
+    else {
+        /* redraw the screen */
+        xcb_xfixes_copy_region(w->sc->dpy->conn, d->all_region,
+                               d->damaged_region);
+    }
 }
 
 static void
@@ -535,14 +551,8 @@ render_window_opacity_change(d_window_t *w)
     /* update the window and its shadows opacities */
     render_update_opacity(w, d, wd);
 
-    /* make sure the shadow region is right */
-    render_update_shadow(w, d, wd);
-
-    /* redraw the window's contents, and its shadow as well */
-    xcb_xfixes_union_region(w->sc->dpy->conn, d->damaged_region,
-                            window_get_region(w), d->damaged_region);
-    xcb_xfixes_union_region(w->sc->dpy->conn, d->damaged_region,
-                            wd->shadow_region, d->damaged_region);
+    /* redraw the window and its shadow */
+    render_redraw_window(w, d, TRUE, wd);
 
     //printf("opacity change 0x%x\n", w->id);
 }
@@ -557,9 +567,8 @@ render_window_damage(d_window_t *w)
     /* pass it on */
     d->window_damage(w);
 
-    /* redraw the window's contents */
-    xcb_xfixes_union_region(w->sc->dpy->conn, d->damaged_region,
-                            window_get_region(w), d->damaged_region);
+    /* redraw the window not not its shadow */
+    render_redraw_window(w, d, FALSE, NULL);
 }
 
 static void
index 7b5230b..30686fc 100644 (file)
--- a/window.c
+++ b/window.c
@@ -55,6 +55,8 @@ typedef struct {
     xcb_get_property_cookie_t          ck_get_opac;
     gboolean waiting_pixmap;
     xcb_void_cookie_t                  ck_pixmap;
+    gboolean waiting_region;
+    xcb_void_cookie_t                  ck_region;
 } d_window_priv_t;
 
 static void window_get_attributes_reply(d_window_priv_t *w);
@@ -169,11 +171,15 @@ window_update_region(d_window_priv_t *w)
     }
 
     w->region = xcb_generate_id(w->sc->dpy->conn);
-    xcb_xfixes_create_region_from_window(w->sc->dpy->conn, w->region,
-                                         w->id, XCB_SHAPE_SK_BOUNDING);
+    w->ck_region =
+        xcb_xfixes_create_region_from_window_checked(w->sc->dpy->conn,
+                                                     w->region,
+                                                     w->id,
+                                                     XCB_SHAPE_SK_BOUNDING);
     window_get_area((d_window_t*)w, &x, &y, &wi, &hei, &bw);
     xcb_xfixes_translate_region(w->sc->dpy->conn, w->region, x+bw, y+bw);
     xcb_flush(w->sc->dpy->conn);
+    w->waiting_region = TRUE;
 }
 
 static void
@@ -420,6 +426,17 @@ window_get_region(d_window_t *pubw)
 {
     d_window_priv_t *w = (d_window_priv_t*)pubw;
 
+    if (w->waiting_region) {
+        xcb_generic_error_t *err = xcb_request_check(w->sc->dpy->conn,
+                                                     w->ck_region);
+        if (err) {
+            display_error(w->sc->dpy, err);
+            w->region = XCB_NONE;
+            free(err);
+        }
+        w->waiting_region = FALSE;
+    }
+
     return w->region;
 }