From: Dana Jansens Date: Sun, 16 Mar 2008 04:42:28 +0000 (-0400) Subject: save the window's geometry when fetching the window's region so that if it changes... X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=a551fb347e22d4f4c09213da9a3194520e27f81f;p=dana%2Fdcompmgr.git save the window's geometry when fetching the window's region so that if it changes (like it moves), we will use the right x/y and stuff to apply to the returned region --- diff --git a/glxrender.c b/glxrender.c index 6077ccf..7a38442 100644 --- a/glxrender.c +++ b/glxrender.c @@ -60,6 +60,11 @@ typedef struct { xcb_xfixes_fetch_region_cookie_t ck_region; int waiting_region; + int x_region; + int y_region; + int w_region; + int h_region; + int bw_region; } window_data_t; static gboolean glxrender_find_fb_config(d_screen_t *sc, data_t *d); @@ -403,7 +408,6 @@ glxrender_update_window_pixmap(d_window_t *w, data_t *d, window_data_t *wd) d->fbconfig[depth], px, attrs); - glBindTexture(GL_TEXTURE_2D, wd->texname); d->bind_func(w->sc->dpy->xlib_dpy, wd->glpixmap, GLX_FRONT_LEFT_EXT, NULL); @@ -415,14 +419,13 @@ glxrender_update_window_pixmap(d_window_t *w, data_t *d, window_data_t *wd) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glBindTexture(GL_TEXTURE_2D, 0); - - glxrender_update_window_region(w, wd); } static void glxrender_fetch_window_region(d_window_t *w, window_data_t *wd) { - if (wd->waiting_region) return; + window_get_area(w, &wd->x_region, &wd->y_region, + &wd->w_region, &wd->h_region, &wd->bw_region); wd->ck_region = xcb_xfixes_fetch_region_unchecked(w->sc->dpy->conn, @@ -436,15 +439,14 @@ glxrender_update_window_region(d_window_t *w, window_data_t *wd) { xcb_xfixes_fetch_region_reply_t *rep; xcb_rectangle_t area, *rects; - int nrects, i, j, x, y, wid, hei, bwid; + int nrects, i, j; if (!wd->waiting_region) return; - window_get_area(w, &x, &y, &wid, &hei, &bwid); - area.x = x; - area.y = y; - area.width = wid + bwid * 2; - area.height = hei + bwid * 2; + area.x = wd->x_region; + area.y = wd->y_region; + area.width = wd->w_region + wd->bw_region * 2; + area.height = wd->h_region + wd->bw_region * 2; rep = xcb_xfixes_fetch_region_reply(w->sc->dpy->conn, wd->ck_region, NULL); if (!rep) { @@ -463,20 +465,20 @@ glxrender_update_window_region(d_window_t *w, window_data_t *wd) for (i = j = 0; i < nrects * 4; ++j, i += 4) { wd->texcoords[i+LEFT] = - (GLfloat)(rects[j].x - x) / (GLfloat)area.width; + (GLfloat)(rects[j].x - area.x) / (GLfloat)area.width; wd->texcoords[i+TOP] = - (GLfloat)(rects[j].y - y) / (GLfloat)area.height; + (GLfloat)(rects[j].y - area.y) / (GLfloat)area.height; wd->texcoords[i+RIGHT] = - (GLfloat)(rects[j].x - x + rects[j].width) / + (GLfloat)(rects[j].x - area.x + rects[j].width) / (GLfloat)area.width; wd->texcoords[i+BOTTOM] = - (GLfloat)(rects[j].y - y + rects[j].height) / + (GLfloat)(rects[j].y - area.y + rects[j].height) / (GLfloat)area.height; - wd->vertices[i+LEFT] = rects[j].x - x; - wd->vertices[i+TOP] = rects[j].y - y; - wd->vertices[i+RIGHT] = rects[j].x - x + rects[j].width; - wd->vertices[i+BOTTOM] = rects[j].y - y + rects[j].height; + wd->vertices[i+LEFT] = rects[j].x - area.x; + wd->vertices[i+TOP] = rects[j].y - area.y; + wd->vertices[i+RIGHT] = rects[j].x - area.x + rects[j].width; + wd->vertices[i+BOTTOM] = rects[j].y - area.y + rects[j].height; } if (rep) @@ -535,8 +537,6 @@ glxrender_window_resize(d_window_t *w) assert(wd != NULL); glxrender_free_window_pixmap(w, d, wd); - - glxrender_free_window_region(wd); glxrender_fetch_window_region(w, wd); } @@ -554,8 +554,6 @@ glxrender_window_reshape(d_window_t *w) assert(wd != NULL); glxrender_free_window_pixmap(w, d, wd); - - glxrender_free_window_region(wd); glxrender_fetch_window_region(w, wd); } @@ -714,6 +712,8 @@ paint_window(d_window_t *w, data_t *d, window_data_t *wd, int x, int y, if (!wd->glpixmap) glxrender_update_window_pixmap(w, d, wd); + if (wd->waiting_region) + glxrender_update_window_region(w, wd); if (wd->nrects < 1) return;