From 47d87f02b0f492719caf07cab013434d164f18c8 Mon Sep 17 00:00:00 2001 From: Michael Jennings Date: Sun, 28 May 2000 21:28:31 +0000 Subject: [PATCH] Sun May 28 14:45:03 PDT 2000 Michael Jennings My attempt to track down the strange X errors have revealed that a pixmap given to me by Imlib2 is getting freed somehow behind my back. Probably because this part of Imlib2 hadn't been tested before Eterm was converted. =P It doesn't seem to happen in XFree86 4.0; I'm wondering if XFree 4 is smart enough to detect double-frees of old XID's and just ignore them? Well, I'm going to have to add some debugging code to Imlib2 and see if I can track down where it's freeing my pixmaps. But I have some errands to run first, so I'm going to commit this for now. It shouldn't actually change any functionality. SVN revision: 2722 --- ChangeLog | 15 +++++++ Eterm.spec.in | 3 +- src/buttons.c | 2 +- src/draw.c | 12 +++--- src/menus.c | 6 +-- src/options.c | 6 ++- src/pixmap.c | 103 +++++++++++++++++++++++++----------------------- src/pixmap.h | 14 +++++++ src/scrollbar.c | 10 ++--- src/term.c | 4 +- src/windows.c | 6 ++- 11 files changed, 111 insertions(+), 70 deletions(-) diff --git a/ChangeLog b/ChangeLog index af0f3c6..c609ea4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3602,3 +3602,18 @@ Fri May 26 20:43:03 PDT 2000 Michael Jennings top-left, the second to top-right, and so on as listed above. ------------------------------------------------------------------------------- +Sun May 28 14:45:03 PDT 2000 Michael Jennings + + My attempt to track down the strange X errors have revealed that a + pixmap given to me by Imlib2 is getting freed somehow behind my back. + Probably because this part of Imlib2 hadn't been tested before Eterm + was converted. =P + + It doesn't seem to happen in XFree86 4.0; I'm wondering if XFree 4 is + smart enough to detect double-frees of old XID's and just ignore them? + Well, I'm going to have to add some debugging code to Imlib2 and see + if I can track down where it's freeing my pixmaps. But I have some + errands to run first, so I'm going to commit this for now. It + shouldn't actually change any functionality. + +------------------------------------------------------------------------------- diff --git a/Eterm.spec.in b/Eterm.spec.in index 9a2d192..7f47671 100644 --- a/Eterm.spec.in +++ b/Eterm.spec.in @@ -62,7 +62,7 @@ make DESTDIR=$RPM_BUILD_ROOT install chmod +x .%{prefix}/lib/lib*so* ||: ) -strip -s $RPM_BUILD_ROOT%{prefix}/bin/* || : +#strip -s $RPM_BUILD_ROOT%{prefix}/bin/* || : gzip $RPM_BUILD_ROOT%{prefix}/man/man1/* @@ -137,6 +137,7 @@ rm -rf $RPM_BUILD_ROOT %{prefix}/share/%{name}/pix/button_arrow_up_[123].png %{prefix}/share/%{name}/pix/button_arrow_down_[123].png %{prefix}/share/%{name}/pix/menu[123].png +%{prefix}/share/%{name}/pix/thumb_[12].png %dir %{prefix}/share/%{name} %dir %{prefix}/share/%{name}/pix diff --git a/src/buttons.c b/src/buttons.c index 8982d40..2c8aed7 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -102,7 +102,7 @@ bbar_create(void) XSelectInput(Xdisplay, bbar->win, mask); XStoreName(Xdisplay, bbar->win, "Eterm Button Bar"); - bbar->gc = XCreateGC(Xdisplay, bbar->win, GCForeground | GCFont, &gcvalue); + bbar->gc = X_CREATE_GC(GCForeground | GCFont, &gcvalue); bbar_set_docked(bbar, BBAR_DOCKED_TOP); bbar_set_visible(bbar, 1); diff --git a/src/draw.c b/src/draw.c index ea78c6a..db2f4be 100644 --- a/src/draw.c +++ b/src/draw.c @@ -58,8 +58,8 @@ draw_shadow_from_colors(Drawable d, Pixel top, Pixel bottom, int x, int y, int w static GC gc_top = (GC) 0, gc_bottom = (GC) 0; if (gc_top == 0) { - gc_top = XCreateGC(Xdisplay, TermWin.parent, 0, NULL); - gc_bottom = XCreateGC(Xdisplay, TermWin.parent, 0, NULL); + gc_top = X_CREATE_GC(0, NULL); + gc_bottom = X_CREATE_GC(0, NULL); } XSetForeground(Xdisplay, gc_top, top); @@ -113,8 +113,8 @@ draw_arrow_from_colors(Drawable d, Pixel top, Pixel bottom, int x, int y, int w, static GC gc_top = (GC) 0, gc_bottom = (GC) 0; if (gc_top == 0) { - gc_top = XCreateGC(Xdisplay, TermWin.parent, 0, NULL); - gc_bottom = XCreateGC(Xdisplay, TermWin.parent, 0, NULL); + gc_top = X_CREATE_GC(0, NULL); + gc_bottom = X_CREATE_GC(0, NULL); } XSetForeground(Xdisplay, gc_top, top); @@ -234,8 +234,8 @@ bevel_pixmap(Pixmap p, int w, int h, Imlib_Border *bord, unsigned char up) MOD_PIXEL_HIGH(x, y, !up); } } - gc = XCreateGC(Xdisplay, p, 0, NULL); + gc = X_CREATE_GC(0, NULL); XPutImage(Xdisplay, p, gc, ximg, 0, 0, 0, 0, w, h); - XFreeGC(Xdisplay, gc); + X_FREE_GC(gc); XDestroyImage(ximg); } diff --git a/src/menus.c b/src/menus.c index a529f2a..292eee6 100644 --- a/src/menus.c +++ b/src/menus.c @@ -127,9 +127,9 @@ menu_init(void) return; } gcvalue.foreground = PixColors[menuTopShadowColor]; - topShadowGC = XCreateGC(Xdisplay, menu_list->menus[0]->win, GCForeground, &gcvalue); + topShadowGC = X_CREATE_GC(GCForeground, &gcvalue); gcvalue.foreground = PixColors[menuBottomShadowColor]; - botShadowGC = XCreateGC(Xdisplay, menu_list->menus[0]->win, GCForeground, &gcvalue); + botShadowGC = X_CREATE_GC(GCForeground, &gcvalue); event_register_dispatcher(menu_dispatch_event, menu_event_init_dispatcher); } @@ -455,7 +455,7 @@ menu_create(char *title) menu->swin = XCreateWindow(Xdisplay, menu->win, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent, CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWBorderPixel | CWColormap, &xattr); - menu->gc = XCreateGC(Xdisplay, menu->win, GCForeground, &gcvalue); + menu->gc = X_CREATE_GC(GCForeground, &gcvalue); menuitem_clear_current(menu); return menu; diff --git a/src/options.c b/src/options.c index 824ddd3..3f864d5 100644 --- a/src/options.c +++ b/src/options.c @@ -2699,7 +2699,11 @@ parse_image(char *buff, void *state) print_error("Parse error in file %s, line %lu: Missing filename", file_peek_path(), file_peek_line()); return NULL; } - load_image(filename, images[idx].current); + if (!load_image(filename, images[idx].current)) { + print_error("Unable to locate image \"%s\" in the image path.", NONULL(filename)); + images[idx].mode &= ~(MODE_IMAGE | ALLOW_IMAGE); + D_PIXMAP(("New image mode is 0x%02x, iml->im is 0x%08x\n", images[idx].mode, images[idx].current->iml->im)); + } } else if (!BEG_STRCASECMP(buff, "geom ")) { char *geom = PWord(2, buff); diff --git a/src/pixmap.c b/src/pixmap.c index c56170d..67d8f41 100644 --- a/src/pixmap.c +++ b/src/pixmap.c @@ -358,7 +358,7 @@ reset_simage(simage_t * simg, unsigned long mask) D_PIXMAP(("reset_simage(%8p, 0x%08x)\n", simg, mask)); if ((mask & RESET_PMAP_PIXMAP) && simg->pmap->pixmap != None) { - imlib_free_pixmap_and_mask(simg->pmap->pixmap); + IMLIB_FREE_PIXMAP(simg->pmap->pixmap); simg->pmap->pixmap = None; simg->pmap->mask = None; } @@ -485,8 +485,8 @@ create_trans_pixmap(simage_t *simg, unsigned char which, Drawable d, int x, int return None; } XTranslateCoordinates(Xdisplay, d, desktop_window, x, y, &x, &y, &dummy); - p = XCreatePixmap(Xdisplay, d, width, height, Xdepth); - gc = XCreateGC(Xdisplay, d, 0, NULL); + p = X_CREATE_PIXMAP(width, height); + gc = X_CREATE_GC(0, NULL); D_PIXMAP(("Created p [0x%08x] as a %hux%hu pixmap at %d, %d relative to window 0x%08x\n", p, width, height, x, y, desktop_window)); if (p != None) { if (pw < scr->width || ph < scr->height) { @@ -508,7 +508,7 @@ create_trans_pixmap(simage_t *simg, unsigned char which, Drawable d, int x, int bevel_pixmap(p, width, height, simg->iml->bevel->edges, simg->iml->bevel->up); } } - XFreeGC(Xdisplay, gc); + X_FREE_GC(gc); return p; } @@ -595,17 +595,17 @@ create_viewport_pixmap(simage_t *simg, Drawable d, int x, int y, unsigned short if (simg->pmap->pixmap != None) { XGetGeometry(Xdisplay, simg->pmap->pixmap, &dummy, &px, &py, &pw, &ph, &pb, &pd); if (pw != width || ph != height) { - imlib_free_pixmap_and_mask(simg->pmap->pixmap); + IMLIB_FREE_PIXMAP(simg->pmap->pixmap); simg->pmap->pixmap = None; } else { p = simg->pmap->pixmap; } } if (p == None) { - p = XCreatePixmap(Xdisplay, d, width, height, Xdepth); + p = X_CREATE_PIXMAP(width, height); D_PIXMAP(("Created p == 0x%08x\n", p)); } - gc = XCreateGC(Xdisplay, d, 0, NULL); + gc = X_CREATE_GC(0, NULL); XTranslateCoordinates(Xdisplay, d, desktop_window, x, y, &x, &y, &dummy); D_PIXMAP(("Translated coords are %d, %d\n", x, y)); if ((images[image_bg].current->pmap->w > 0) || (images[image_bg].current->pmap->op & OP_SCALE)) { @@ -616,7 +616,7 @@ create_viewport_pixmap(simage_t *simg, Drawable d, int x, int y, unsigned short XSetFillStyle(Xdisplay, gc, FillTiled); XFillRectangle(Xdisplay, p, gc, 0, 0, width, height); } - XFreeGC(Xdisplay, gc); + X_FREE_GC(gc); return p; } @@ -661,13 +661,13 @@ paste_simage(simage_t *simg, unsigned char which, Drawable d, unsigned short x, FREE(reply); enl_ipc_sync(); if (pmap) { - gc = XCreateGC(Xdisplay, d, 0, NULL); + gc = X_CREATE_GC(0, NULL); XSetClipMask(Xdisplay, gc, mask); XSetClipOrigin(Xdisplay, gc, x, y); XCopyArea(Xdisplay, pmap, d, gc, 0, 0, w, h, x, y); snprintf(buff, sizeof(buff), "imageclass %s free_pixmap 0x%08x", iclass, (int) pmap); enl_ipc_send(buff); - XFreeGC(Xdisplay, gc); + X_FREE_GC(gc); return; } else { print_error("Enlightenment returned a null pixmap, which I can't use. Disallowing \"auto\" mode for this image.\n"); @@ -680,23 +680,23 @@ paste_simage(simage_t *simg, unsigned char which, Drawable d, unsigned short x, } else if (image_mode_is(which, MODE_TRANS) && image_mode_is(which, ALLOW_TRANS)) { Pixmap p; - gc = XCreateGC(Xdisplay, d, 0, NULL); + gc = X_CREATE_GC(0, NULL); /* FIXME: The conditional on the next line works, but it's a hack. Worth fixing? :-) */ p = create_trans_pixmap(simg, which, ((which == image_st) ? scrollbar.sa_win : d), x, y, w, h); XCopyArea(Xdisplay, p, d, gc, 0, 0, w, h, x, y); - XFreePixmap(Xdisplay, p); - XFreeGC(Xdisplay, gc); + X_FREE_PIXMAP(p); + X_FREE_GC(gc); } else if (image_mode_is(which, MODE_VIEWPORT) && image_mode_is(which, ALLOW_VIEWPORT)) { Pixmap p; - gc = XCreateGC(Xdisplay, d, 0, NULL); + gc = X_CREATE_GC(0, NULL); p = create_viewport_pixmap(simg, d, x, y, w, h); if (simg->iml->bevel != NULL) { bevel_pixmap(p, w, h, simg->iml->bevel->edges, simg->iml->bevel->up); } XCopyArea(Xdisplay, p, d, gc, 0, 0, w, h, x, y); - XFreePixmap(Xdisplay, p); - XFreeGC(Xdisplay, gc); + X_FREE_PIXMAP(p); + X_FREE_GC(gc); } } @@ -739,18 +739,18 @@ paste_simage(simage_t *simg, unsigned char which, Drawable d, unsigned short x, imlib_render_pixmaps_for_whole_image_at_size(&pmap, &mask, w, h); } if (pmap == None) { - print_error("Delayed image load failure for \"%s\".", imlib_image_get_filename()); + print_error("Delayed image load failure for \"%s\".", NONULL(imlib_image_get_filename())); reset_simage(simg, RESET_ALL_SIMG); return; } - gc = XCreateGC(Xdisplay, d, 0, NULL); + gc = X_CREATE_GC(0, NULL); if (mask) { XSetClipMask(Xdisplay, gc, mask); XSetClipOrigin(Xdisplay, gc, x, y); } XCopyArea(Xdisplay, pmap, d, gc, 0, 0, w, h, x, y); - imlib_free_pixmap_and_mask(pmap); - XFreeGC(Xdisplay, gc); + IMLIB_FREE_PIXMAP(pmap); + X_FREE_GC(gc); } } @@ -808,9 +808,9 @@ copy_buffer_pixmap(unsigned char mode, unsigned long fill, unsigned short width, XGCValues gcvalue; ASSERT(buffer_pixmap == None); - buffer_pixmap = XCreatePixmap(Xdisplay, TermWin.vt, width, height, Xdepth); + buffer_pixmap = X_CREATE_PIXMAP(width, height); gcvalue.foreground = (Pixel) fill; - gc = XCreateGC(Xdisplay, TermWin.vt, GCForeground, &gcvalue); + gc = X_CREATE_GC(GCForeground, &gcvalue); XSetGraphicsExposures(Xdisplay, gc, False); if (mode == MODE_SOLID) { @@ -818,15 +818,15 @@ copy_buffer_pixmap(unsigned char mode, unsigned long fill, unsigned short width, simg = images[image_bg].current; if (simg->pmap->pixmap) { - XFreePixmap(Xdisplay, simg->pmap->pixmap); + X_FREE_PIXMAP(simg->pmap->pixmap); } - simg->pmap->pixmap = XCreatePixmap(Xdisplay, TermWin.vt, width, height, Xdepth); + simg->pmap->pixmap = X_CREATE_PIXMAP(width, height); XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height); XCopyArea(Xdisplay, simg->pmap->pixmap, buffer_pixmap, gc, 0, 0, width, height, 0, 0); } else { XCopyArea(Xdisplay, (Pixmap) fill, buffer_pixmap, gc, 0, 0, width, height, 0, 0); } - XFreeGC(Xdisplay, gc); + X_FREE_GC(gc); } void @@ -861,11 +861,11 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short return; gcvalue.foreground = gcvalue.background = PixColors[bgColor]; - gc = XCreateGC(Xdisplay, win, GCForeground | GCBackground, &gcvalue); + gc = X_CREATE_GC(GCForeground | GCBackground, &gcvalue); pixmap = simg->pmap->pixmap; /* Save this for later */ if ((which == image_bg) && (buffer_pixmap != None)) { - XFreePixmap(Xdisplay, buffer_pixmap); + X_FREE_PIXMAP(buffer_pixmap); buffer_pixmap = None; } @@ -906,9 +906,9 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short XSetClipOrigin(Xdisplay, gc, 0, 0); } if (simg->pmap->pixmap) { - XFreePixmap(Xdisplay, simg->pmap->pixmap); + X_FREE_PIXMAP(simg->pmap->pixmap); } - simg->pmap->pixmap = XCreatePixmap(Xdisplay, win, width, height, Xdepth); + simg->pmap->pixmap = X_CREATE_PIXMAP(width, height); XCopyArea(Xdisplay, pmap, simg->pmap->pixmap, gc, 0, 0, width, height, 0, 0); XSetWindowBackgroundPixmap(Xdisplay, win, simg->pmap->pixmap); snprintf(buff, sizeof(buff), "imageclass %s free_pixmap 0x%08x", iclass, (int) pmap); @@ -922,7 +922,7 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short } else { snprintf(buff, sizeof(buff), "imageclass %s apply 0x%x %s", iclass, (int) win, state); enl_ipc_send(buff); - XFreeGC(Xdisplay, gc); + X_FREE_GC(gc); return; } } @@ -932,7 +932,7 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short # ifdef PIXMAP_OFFSET if (image_mode_is(which, MODE_TRANS) && image_mode_is(which, ALLOW_TRANS)) { if (simg->pmap->pixmap != None) { - XFreePixmap(Xdisplay, simg->pmap->pixmap); + X_FREE_PIXMAP(simg->pmap->pixmap); } simg->pmap->pixmap = create_trans_pixmap(simg, which, win, 0, 0, width, height); if (simg->pmap->pixmap != None) { @@ -952,7 +952,7 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short p = create_viewport_pixmap(simg, win, 0, 0, width, height); if (p && (p != simg->pmap->pixmap)) { if (simg->pmap->pixmap != None) { - XFreePixmap(Xdisplay, simg->pmap->pixmap); + X_FREE_PIXMAP(simg->pmap->pixmap); } simg->pmap->pixmap = p; } @@ -1064,8 +1064,8 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short shaped_window_apply_mask(win, simg->pmap->mask); } if (simg->pmap->pixmap != None) { - if (pixmap != None) { - imlib_free_pixmap_and_mask(pixmap); + if (pixmap != None && pixmap != simg->pmap->pixmap) { + IMLIB_FREE_PIXMAP(pixmap); } if (xscaled != width || yscaled != height || xpos != 0 || ypos != 0) { unsigned char single; @@ -1074,7 +1074,7 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short single = ((xscaled < width || yscaled < height) && !(simg->pmap->op & OP_TILE)) ? 1 : 0; pixmap = simg->pmap->pixmap; - simg->pmap->pixmap = XCreatePixmap(Xdisplay, win, width, height, Xdepth); + simg->pmap->pixmap = X_CREATE_PIXMAP(width, height); if (single) { XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height); } @@ -1086,8 +1086,13 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short } else { XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height); } - imlib_free_pixmap_and_mask(pixmap); - } + IMLIB_FREE_PIXMAP(pixmap); + } else if (renderop & RENDER_FORCE_PIXMAP) { + pixmap = simg->pmap->pixmap; + simg->pmap->pixmap = X_CREATE_PIXMAP(width, height); + XCopyArea(Xdisplay, pixmap, simg->pmap->pixmap, gc, 0, 0, width, height, 0, 0); + IMLIB_FREE_PIXMAP(pixmap); + } if (simg->iml->bevel != NULL) { bevel_pixmap(simg->pmap->pixmap, width, height, simg->iml->bevel->edges, simg->iml->bevel->up); } @@ -1119,9 +1124,9 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short } else { if (renderop & RENDER_FORCE_PIXMAP) { if (simg->pmap->pixmap) { - XFreePixmap(Xdisplay, simg->pmap->pixmap); + X_FREE_PIXMAP(simg->pmap->pixmap); } - simg->pmap->pixmap = XCreatePixmap(Xdisplay, win, width, height, Xdepth); + simg->pmap->pixmap = X_CREATE_PIXMAP(width, height); XSetForeground(Xdisplay, gc, ((which == image_bg) ? (PixColors[bgColor]) : (simg->bg))); XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height); if (simg->iml->bevel != NULL) { @@ -1136,7 +1141,7 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short } } XClearWindow(Xdisplay, win); - XFreeGC(Xdisplay, gc); + X_FREE_GC(gc); return; } @@ -1807,7 +1812,7 @@ get_desktop_pixmap(void) } if (color_pixmap != None) { D_PIXMAP(("Removing old solid color pixmap 0x%08x.\n", color_pixmap)); - XFreePixmap(Xdisplay, color_pixmap); + X_FREE_PIXMAP(color_pixmap); color_pixmap = None; } if (prop != None) { @@ -1832,19 +1837,19 @@ get_desktop_pixmap(void) Screen *scr = ScreenOfDisplay(Xdisplay, Xscreen); gcvalue.foreground = gcvalue.background = PixColors[bgColor]; - gc = XCreateGC(Xdisplay, TermWin.vt, GCForeground | GCBackground, &gcvalue); + gc = X_CREATE_GC(GCForeground | GCBackground, &gcvalue); XGetGeometry(Xdisplay, p, &w, &px, &py, &pw, &ph, &pb, &pd); D_PIXMAP(("XGetGeometry() returned w = 0x%08x, pw == %u, ph == %u\n", w, pw, ph)); if (pw < (unsigned int) scr->width || ph < (unsigned int) scr->height) { - desktop_pixmap = XCreatePixmap(Xdisplay, TermWin.parent, pw, ph, Xdepth); + desktop_pixmap = X_CREATE_PIXMAP(pw, ph); XCopyArea(Xdisplay, p, desktop_pixmap, gc, 0, 0, pw, ph, 0, 0); colormod_trans(desktop_pixmap, images[image_bg].current->iml, gc, pw, ph); } else { - desktop_pixmap = XCreatePixmap(Xdisplay, TermWin.vt, scr->width, scr->height, Xdepth); + desktop_pixmap = X_CREATE_PIXMAP(scr->width, scr->height); XCopyArea(Xdisplay, p, desktop_pixmap, gc, 0, 0, scr->width, scr->height, 0, 0); colormod_trans(desktop_pixmap, images[image_bg].current->iml, gc, scr->width, scr->height); } - XFreeGC(Xdisplay, gc); + X_FREE_GC(gc); desktop_pixmap_is_mine = 1; D_PIXMAP(("Returning 0x%08x\n", (unsigned int) desktop_pixmap)); return (desktop_pixmap); @@ -1870,12 +1875,12 @@ get_desktop_pixmap(void) D_PIXMAP((" Found solid color 0x%08x\n", pix)); gcvalue.foreground = pix; gcvalue.background = pix; - gc = XCreateGC(Xdisplay, TermWin.vt, GCForeground | GCBackground, &gcvalue); + gc = X_CREATE_GC(GCForeground | GCBackground, &gcvalue); - color_pixmap = XCreatePixmap(Xdisplay, TermWin.vt, 16, 16, Xdepth); + color_pixmap = X_CREATE_PIXMAP(16, 16); XFillRectangle(Xdisplay, color_pixmap, gc, 0, 0, 16, 16); D_PIXMAP(("Created solid color pixmap 0x%08x for desktop_pixmap.\n", color_pixmap)); - XFreeGC(Xdisplay, gc); + X_FREE_GC(gc); return (desktop_pixmap = color_pixmap); } } @@ -1890,7 +1895,7 @@ free_desktop_pixmap(void) { if (desktop_pixmap_is_mine && desktop_pixmap != None) { - XFreePixmap(Xdisplay, desktop_pixmap); + X_FREE_PIXMAP(desktop_pixmap); desktop_pixmap_is_mine = 0; } desktop_pixmap = None; diff --git a/src/pixmap.h b/src/pixmap.h index 8096935..07117ff 100644 --- a/src/pixmap.h +++ b/src/pixmap.h @@ -48,6 +48,7 @@ # define CONVERT_TINT_RED(t) (((t) & 0xff0000) >> 16) # define CONVERT_TINT_GREEN(t) (((t) & 0x00ff00) >> 8) # define CONVERT_TINT_BLUE(t) ((t) & 0x0000ff) +# define IMLIB_FREE_PIXMAP(p) do {D_PIXMAP(("Freeing pixmap: imlib_free_pixmap_and_mask(0x%08x)\n", (p))); imlib_free_pixmap_and_mask(p);} while (0) #else # define background_is_image() (0) # define background_is_trans() (0) @@ -56,7 +57,20 @@ # define background_is_pixmap() (0) # define get_image_type_string(t) ((char *) "") # define delete_simage(simg) NOP +# define IMLIB_FREE_PIXMAP(p) NOP #endif +#ifdef __GNUC__ +# define X_CREATE_PIXMAP(w, h) __extension__ ({Pixmap __my_tmp_pmap = XCreatePixmap(Xdisplay, (TermWin.parent ? TermWin.parent : Xroot), (w), (h), Xdepth); \ + D_PIXMAP(("Created pixmap 0x%08x (width %d, height %d)\n", (__my_tmp_pmap), (w), (h))); \ + (__my_tmp_pmap);}) +# define X_CREATE_GC(flags, gcv) __extension__ ({GC __my_tmp_gc = XCreateGC(Xdisplay, (TermWin.parent ? TermWin.parent : Xroot), (flags), (gcv)); \ + D_PIXMAP(("Created GC 0x%08x\n", (__my_tmp_gc))); (__my_tmp_gc);}) +#else +# define X_CREATE_PIXMAP(w, h) (XCreatePixmap(Xdisplay, TermWin.parent, (w), (h), Xdepth)) +# define X_CREATE_GC(flags, gcv) (XCreateGC(Xdisplay, TermWin.parent, (flags), (gcv))) +#endif +#define X_FREE_PIXMAP(p) do {D_PIXMAP(("Freeing pixmap: XFreePixmap(Xdisplay, 0x%08x)\n", (p))); XFreePixmap(Xdisplay, (p));} while (0) +#define X_FREE_GC(gc) do {D_PIXMAP(("Freeing GC: XFreeGC(Xdisplay, 0x%08x)\n", (gc))); XFreeGC(Xdisplay, (gc));} while (0) #define PIXMAP_EXT NULL #define GEOM_LEN 19 diff --git a/src/scrollbar.c b/src/scrollbar.c index add2e1a..7035f6f 100644 --- a/src/scrollbar.c +++ b/src/scrollbar.c @@ -875,19 +875,19 @@ scrollbar_drawing_init(void) { gcvalue.fill_style = FillOpaqueStippled; gcvalue.foreground = PixColors[fgColor]; gcvalue.background = PixColors[bgColor]; - gc_stipple = XCreateGC(Xdisplay, scrollbar.win, GCForeground | GCBackground | GCFillStyle | GCStipple, &gcvalue); + gc_stipple = X_CREATE_GC(GCForeground | GCBackground | GCFillStyle | GCStipple, &gcvalue); gcvalue.foreground = PixColors[borderColor]; - gc_border = XCreateGC(Xdisplay, scrollbar.win, GCForeground, &gcvalue); + gc_border = X_CREATE_GC(GCForeground, &gcvalue); } #endif /* XTERM_SCROLLBAR */ #if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR) gcvalue.foreground = images[image_sb].norm->bg; - gc_scrollbar = XCreateGC(Xdisplay, scrollbar.win, GCForeground, &gcvalue); + gc_scrollbar = X_CREATE_GC(GCForeground, &gcvalue); gcvalue.foreground = PixColors[topShadowColor]; - gc_top = XCreateGC(Xdisplay, scrollbar.win, GCForeground, &gcvalue); + gc_top = X_CREATE_GC(GCForeground, &gcvalue); gcvalue.foreground = PixColors[bottomShadowColor]; - gc_bottom = XCreateGC(Xdisplay, scrollbar.win, GCForeground, &gcvalue); + gc_bottom = X_CREATE_GC(GCForeground, &gcvalue); #endif /* MOTIF_SCROLLBAR || NEXT_SCROLLBAR */ } diff --git a/src/term.c b/src/term.c index 19960f9..6bf7512 100644 --- a/src/term.c +++ b/src/term.c @@ -1819,7 +1819,7 @@ xterm_seq(int op, const char *str) if (image_mode_is(which, MODE_TRANS) && (desktop_pixmap != None)) { free_desktop_pixmap(); } else if (image_mode_is(which, MODE_VIEWPORT) && (viewport_pixmap != None)) { - XFreePixmap(Xdisplay, viewport_pixmap); + X_FREE_PIXMAP(viewport_pixmap); viewport_pixmap = None; /* Force the re-read */ } # endif @@ -1835,7 +1835,7 @@ xterm_seq(int op, const char *str) if (image_mode_is(which, MODE_TRANS) && (desktop_pixmap != None)) { free_desktop_pixmap(); } else if (image_mode_is(which, MODE_VIEWPORT) && (viewport_pixmap != None)) { - XFreePixmap(Xdisplay, viewport_pixmap); + X_FREE_PIXMAP(viewport_pixmap); viewport_pixmap = None; /* Force the re-read */ } # endif diff --git a/src/windows.c b/src/windows.c index da44e88..f32603f 100644 --- a/src/windows.c +++ b/src/windows.c @@ -378,7 +378,9 @@ Create_Windows(int argc, char *argv[]) Attributes.background_pixel = PixColors[bgColor]; Attributes.border_pixel = PixColors[bgColor]; - D_X11(("szHint == { %d, %d, %d, %d }\n", szHint.x, szHint.y, szHint.width, szHint.height)); + D_X11(("Size Hints: x %d, y %d. Width/Height: Base %dx%d, Minimum %dx%d, Current %dx%d, Increment %dx%d\n", + szHint.x, szHint.y, szHint.base_width, szHint.base_height, szHint.min_width, szHint.min_height, + szHint.width, szHint.height, szHint.width_inc, szHint.height_inc)); TermWin.parent = XCreateWindow(Xdisplay, Xroot, szHint.x, szHint.y, szHint.width, szHint.height, 0, Xdepth, InputOutput, #ifdef PREFER_24BIT Xvisual, @@ -468,7 +470,7 @@ Create_Windows(int argc, char *argv[]) gcvalue.foreground = PixColors[fgColor]; gcvalue.background = PixColors[bgColor]; gcvalue.graphics_exposures = 0; - TermWin.gc = XCreateGC(Xdisplay, TermWin.vt, GCForeground | GCBackground | GCFont | GCGraphicsExposures, &gcvalue); + TermWin.gc = X_CREATE_GC(GCForeground | GCBackground | GCFont | GCGraphicsExposures, &gcvalue); } if (Options & Opt_noCursor) {