Sun May 28 14:45:03 PDT 2000 Michael Jennings <mej@eterm.org>

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
This commit is contained in:
Michael Jennings 2000-05-28 21:28:31 +00:00
parent e64307644d
commit 47d87f02b0
11 changed files with 111 additions and 70 deletions

View File

@ -3602,3 +3602,18 @@ Fri May 26 20:43:03 PDT 2000 Michael Jennings <mej@eterm.org>
top-left, the second to top-right, and so on as listed above. top-left, the second to top-right, and so on as listed above.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Sun May 28 14:45:03 PDT 2000 Michael Jennings <mej@eterm.org>
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.
-------------------------------------------------------------------------------

View File

@ -62,7 +62,7 @@ make DESTDIR=$RPM_BUILD_ROOT install
chmod +x .%{prefix}/lib/lib*so* ||: 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/* 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_up_[123].png
%{prefix}/share/%{name}/pix/button_arrow_down_[123].png %{prefix}/share/%{name}/pix/button_arrow_down_[123].png
%{prefix}/share/%{name}/pix/menu[123].png %{prefix}/share/%{name}/pix/menu[123].png
%{prefix}/share/%{name}/pix/thumb_[12].png
%dir %{prefix}/share/%{name} %dir %{prefix}/share/%{name}
%dir %{prefix}/share/%{name}/pix %dir %{prefix}/share/%{name}/pix

View File

@ -102,7 +102,7 @@ bbar_create(void)
XSelectInput(Xdisplay, bbar->win, mask); XSelectInput(Xdisplay, bbar->win, mask);
XStoreName(Xdisplay, bbar->win, "Eterm Button Bar"); 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_docked(bbar, BBAR_DOCKED_TOP);
bbar_set_visible(bbar, 1); bbar_set_visible(bbar, 1);

View File

@ -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; static GC gc_top = (GC) 0, gc_bottom = (GC) 0;
if (gc_top == 0) { if (gc_top == 0) {
gc_top = XCreateGC(Xdisplay, TermWin.parent, 0, NULL); gc_top = X_CREATE_GC(0, NULL);
gc_bottom = XCreateGC(Xdisplay, TermWin.parent, 0, NULL); gc_bottom = X_CREATE_GC(0, NULL);
} }
XSetForeground(Xdisplay, gc_top, top); 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; static GC gc_top = (GC) 0, gc_bottom = (GC) 0;
if (gc_top == 0) { if (gc_top == 0) {
gc_top = XCreateGC(Xdisplay, TermWin.parent, 0, NULL); gc_top = X_CREATE_GC(0, NULL);
gc_bottom = XCreateGC(Xdisplay, TermWin.parent, 0, NULL); gc_bottom = X_CREATE_GC(0, NULL);
} }
XSetForeground(Xdisplay, gc_top, top); 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); 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); XPutImage(Xdisplay, p, gc, ximg, 0, 0, 0, 0, w, h);
XFreeGC(Xdisplay, gc); X_FREE_GC(gc);
XDestroyImage(ximg); XDestroyImage(ximg);
} }

View File

@ -127,9 +127,9 @@ menu_init(void)
return; return;
} }
gcvalue.foreground = PixColors[menuTopShadowColor]; gcvalue.foreground = PixColors[menuTopShadowColor];
topShadowGC = XCreateGC(Xdisplay, menu_list->menus[0]->win, GCForeground, &gcvalue); topShadowGC = X_CREATE_GC(GCForeground, &gcvalue);
gcvalue.foreground = PixColors[menuBottomShadowColor]; 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); 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, menu->swin = XCreateWindow(Xdisplay, menu->win, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent,
CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWBorderPixel | CWColormap, &xattr); 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); menuitem_clear_current(menu);
return menu; return menu;

View File

@ -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()); print_error("Parse error in file %s, line %lu: Missing filename", file_peek_path(), file_peek_line());
return NULL; 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 ")) { } else if (!BEG_STRCASECMP(buff, "geom ")) {
char *geom = PWord(2, buff); char *geom = PWord(2, buff);

View File

@ -358,7 +358,7 @@ reset_simage(simage_t * simg, unsigned long mask)
D_PIXMAP(("reset_simage(%8p, 0x%08x)\n", simg, mask)); D_PIXMAP(("reset_simage(%8p, 0x%08x)\n", simg, mask));
if ((mask & RESET_PMAP_PIXMAP) && simg->pmap->pixmap != None) { 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->pixmap = None;
simg->pmap->mask = 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; return None;
} }
XTranslateCoordinates(Xdisplay, d, desktop_window, x, y, &x, &y, &dummy); XTranslateCoordinates(Xdisplay, d, desktop_window, x, y, &x, &y, &dummy);
p = XCreatePixmap(Xdisplay, d, width, height, Xdepth); p = X_CREATE_PIXMAP(width, height);
gc = XCreateGC(Xdisplay, d, 0, NULL); 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)); 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 (p != None) {
if (pw < scr->width || ph < scr->height) { 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); bevel_pixmap(p, width, height, simg->iml->bevel->edges, simg->iml->bevel->up);
} }
} }
XFreeGC(Xdisplay, gc); X_FREE_GC(gc);
return p; 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) { if (simg->pmap->pixmap != None) {
XGetGeometry(Xdisplay, simg->pmap->pixmap, &dummy, &px, &py, &pw, &ph, &pb, &pd); XGetGeometry(Xdisplay, simg->pmap->pixmap, &dummy, &px, &py, &pw, &ph, &pb, &pd);
if (pw != width || ph != height) { if (pw != width || ph != height) {
imlib_free_pixmap_and_mask(simg->pmap->pixmap); IMLIB_FREE_PIXMAP(simg->pmap->pixmap);
simg->pmap->pixmap = None; simg->pmap->pixmap = None;
} else { } else {
p = simg->pmap->pixmap; p = simg->pmap->pixmap;
} }
} }
if (p == None) { if (p == None) {
p = XCreatePixmap(Xdisplay, d, width, height, Xdepth); p = X_CREATE_PIXMAP(width, height);
D_PIXMAP(("Created p == 0x%08x\n", p)); 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); XTranslateCoordinates(Xdisplay, d, desktop_window, x, y, &x, &y, &dummy);
D_PIXMAP(("Translated coords are %d, %d\n", x, y)); 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)) { 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); XSetFillStyle(Xdisplay, gc, FillTiled);
XFillRectangle(Xdisplay, p, gc, 0, 0, width, height); XFillRectangle(Xdisplay, p, gc, 0, 0, width, height);
} }
XFreeGC(Xdisplay, gc); X_FREE_GC(gc);
return p; return p;
} }
@ -661,13 +661,13 @@ paste_simage(simage_t *simg, unsigned char which, Drawable d, unsigned short x,
FREE(reply); FREE(reply);
enl_ipc_sync(); enl_ipc_sync();
if (pmap) { if (pmap) {
gc = XCreateGC(Xdisplay, d, 0, NULL); gc = X_CREATE_GC(0, NULL);
XSetClipMask(Xdisplay, gc, mask); XSetClipMask(Xdisplay, gc, mask);
XSetClipOrigin(Xdisplay, gc, x, y); XSetClipOrigin(Xdisplay, gc, x, y);
XCopyArea(Xdisplay, pmap, d, gc, 0, 0, w, h, 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); snprintf(buff, sizeof(buff), "imageclass %s free_pixmap 0x%08x", iclass, (int) pmap);
enl_ipc_send(buff); enl_ipc_send(buff);
XFreeGC(Xdisplay, gc); X_FREE_GC(gc);
return; return;
} else { } else {
print_error("Enlightenment returned a null pixmap, which I can't use. Disallowing \"auto\" mode for this image.\n"); 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)) { } else if (image_mode_is(which, MODE_TRANS) && image_mode_is(which, ALLOW_TRANS)) {
Pixmap p; 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? :-) */ /* 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); 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); XCopyArea(Xdisplay, p, d, gc, 0, 0, w, h, x, y);
XFreePixmap(Xdisplay, p); X_FREE_PIXMAP(p);
XFreeGC(Xdisplay, gc); X_FREE_GC(gc);
} else if (image_mode_is(which, MODE_VIEWPORT) && image_mode_is(which, ALLOW_VIEWPORT)) { } else if (image_mode_is(which, MODE_VIEWPORT) && image_mode_is(which, ALLOW_VIEWPORT)) {
Pixmap p; Pixmap p;
gc = XCreateGC(Xdisplay, d, 0, NULL); gc = X_CREATE_GC(0, NULL);
p = create_viewport_pixmap(simg, d, x, y, w, h); p = create_viewport_pixmap(simg, d, x, y, w, h);
if (simg->iml->bevel != NULL) { if (simg->iml->bevel != NULL) {
bevel_pixmap(p, w, h, simg->iml->bevel->edges, simg->iml->bevel->up); bevel_pixmap(p, w, h, simg->iml->bevel->edges, simg->iml->bevel->up);
} }
XCopyArea(Xdisplay, p, d, gc, 0, 0, w, h, x, y); XCopyArea(Xdisplay, p, d, gc, 0, 0, w, h, x, y);
XFreePixmap(Xdisplay, p); X_FREE_PIXMAP(p);
XFreeGC(Xdisplay, gc); 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); imlib_render_pixmaps_for_whole_image_at_size(&pmap, &mask, w, h);
} }
if (pmap == None) { 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); reset_simage(simg, RESET_ALL_SIMG);
return; return;
} }
gc = XCreateGC(Xdisplay, d, 0, NULL); gc = X_CREATE_GC(0, NULL);
if (mask) { if (mask) {
XSetClipMask(Xdisplay, gc, mask); XSetClipMask(Xdisplay, gc, mask);
XSetClipOrigin(Xdisplay, gc, x, y); XSetClipOrigin(Xdisplay, gc, x, y);
} }
XCopyArea(Xdisplay, pmap, d, gc, 0, 0, w, h, x, y); XCopyArea(Xdisplay, pmap, d, gc, 0, 0, w, h, x, y);
imlib_free_pixmap_and_mask(pmap); IMLIB_FREE_PIXMAP(pmap);
XFreeGC(Xdisplay, gc); X_FREE_GC(gc);
} }
} }
@ -808,9 +808,9 @@ copy_buffer_pixmap(unsigned char mode, unsigned long fill, unsigned short width,
XGCValues gcvalue; XGCValues gcvalue;
ASSERT(buffer_pixmap == None); ASSERT(buffer_pixmap == None);
buffer_pixmap = XCreatePixmap(Xdisplay, TermWin.vt, width, height, Xdepth); buffer_pixmap = X_CREATE_PIXMAP(width, height);
gcvalue.foreground = (Pixel) fill; gcvalue.foreground = (Pixel) fill;
gc = XCreateGC(Xdisplay, TermWin.vt, GCForeground, &gcvalue); gc = X_CREATE_GC(GCForeground, &gcvalue);
XSetGraphicsExposures(Xdisplay, gc, False); XSetGraphicsExposures(Xdisplay, gc, False);
if (mode == MODE_SOLID) { 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; simg = images[image_bg].current;
if (simg->pmap->pixmap) { 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); XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height);
XCopyArea(Xdisplay, simg->pmap->pixmap, buffer_pixmap, gc, 0, 0, width, height, 0, 0); XCopyArea(Xdisplay, simg->pmap->pixmap, buffer_pixmap, gc, 0, 0, width, height, 0, 0);
} else { } else {
XCopyArea(Xdisplay, (Pixmap) fill, buffer_pixmap, gc, 0, 0, width, height, 0, 0); XCopyArea(Xdisplay, (Pixmap) fill, buffer_pixmap, gc, 0, 0, width, height, 0, 0);
} }
XFreeGC(Xdisplay, gc); X_FREE_GC(gc);
} }
void void
@ -861,11 +861,11 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short
return; return;
gcvalue.foreground = gcvalue.background = PixColors[bgColor]; 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 */ pixmap = simg->pmap->pixmap; /* Save this for later */
if ((which == image_bg) && (buffer_pixmap != None)) { if ((which == image_bg) && (buffer_pixmap != None)) {
XFreePixmap(Xdisplay, buffer_pixmap); X_FREE_PIXMAP(buffer_pixmap);
buffer_pixmap = None; buffer_pixmap = None;
} }
@ -906,9 +906,9 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short
XSetClipOrigin(Xdisplay, gc, 0, 0); XSetClipOrigin(Xdisplay, gc, 0, 0);
} }
if (simg->pmap->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);
XCopyArea(Xdisplay, pmap, simg->pmap->pixmap, gc, 0, 0, width, height, 0, 0); XCopyArea(Xdisplay, pmap, simg->pmap->pixmap, gc, 0, 0, width, height, 0, 0);
XSetWindowBackgroundPixmap(Xdisplay, win, simg->pmap->pixmap); XSetWindowBackgroundPixmap(Xdisplay, win, simg->pmap->pixmap);
snprintf(buff, sizeof(buff), "imageclass %s free_pixmap 0x%08x", iclass, (int) pmap); 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 { } else {
snprintf(buff, sizeof(buff), "imageclass %s apply 0x%x %s", iclass, (int) win, state); snprintf(buff, sizeof(buff), "imageclass %s apply 0x%x %s", iclass, (int) win, state);
enl_ipc_send(buff); enl_ipc_send(buff);
XFreeGC(Xdisplay, gc); X_FREE_GC(gc);
return; return;
} }
} }
@ -932,7 +932,7 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short
# ifdef PIXMAP_OFFSET # ifdef PIXMAP_OFFSET
if (image_mode_is(which, MODE_TRANS) && image_mode_is(which, ALLOW_TRANS)) { if (image_mode_is(which, MODE_TRANS) && image_mode_is(which, ALLOW_TRANS)) {
if (simg->pmap->pixmap != None) { 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); simg->pmap->pixmap = create_trans_pixmap(simg, which, win, 0, 0, width, height);
if (simg->pmap->pixmap != None) { 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); p = create_viewport_pixmap(simg, win, 0, 0, width, height);
if (p && (p != simg->pmap->pixmap)) { if (p && (p != simg->pmap->pixmap)) {
if (simg->pmap->pixmap != None) { if (simg->pmap->pixmap != None) {
XFreePixmap(Xdisplay, simg->pmap->pixmap); X_FREE_PIXMAP(simg->pmap->pixmap);
} }
simg->pmap->pixmap = p; 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); shaped_window_apply_mask(win, simg->pmap->mask);
} }
if (simg->pmap->pixmap != None) { if (simg->pmap->pixmap != None) {
if (pixmap != None) { if (pixmap != None && pixmap != simg->pmap->pixmap) {
imlib_free_pixmap_and_mask(pixmap); IMLIB_FREE_PIXMAP(pixmap);
} }
if (xscaled != width || yscaled != height || xpos != 0 || ypos != 0) { if (xscaled != width || yscaled != height || xpos != 0 || ypos != 0) {
unsigned char single; 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; single = ((xscaled < width || yscaled < height) && !(simg->pmap->op & OP_TILE)) ? 1 : 0;
pixmap = simg->pmap->pixmap; pixmap = simg->pmap->pixmap;
simg->pmap->pixmap = XCreatePixmap(Xdisplay, win, width, height, Xdepth); simg->pmap->pixmap = X_CREATE_PIXMAP(width, height);
if (single) { if (single) {
XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height); 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 { } else {
XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height); 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) { if (simg->iml->bevel != NULL) {
bevel_pixmap(simg->pmap->pixmap, width, height, simg->iml->bevel->edges, simg->iml->bevel->up); 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 { } else {
if (renderop & RENDER_FORCE_PIXMAP) { if (renderop & RENDER_FORCE_PIXMAP) {
if (simg->pmap->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))); XSetForeground(Xdisplay, gc, ((which == image_bg) ? (PixColors[bgColor]) : (simg->bg)));
XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height); XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height);
if (simg->iml->bevel != NULL) { if (simg->iml->bevel != NULL) {
@ -1136,7 +1141,7 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short
} }
} }
XClearWindow(Xdisplay, win); XClearWindow(Xdisplay, win);
XFreeGC(Xdisplay, gc); X_FREE_GC(gc);
return; return;
} }
@ -1807,7 +1812,7 @@ get_desktop_pixmap(void)
} }
if (color_pixmap != None) { if (color_pixmap != None) {
D_PIXMAP(("Removing old solid color pixmap 0x%08x.\n", color_pixmap)); D_PIXMAP(("Removing old solid color pixmap 0x%08x.\n", color_pixmap));
XFreePixmap(Xdisplay, color_pixmap); X_FREE_PIXMAP(color_pixmap);
color_pixmap = None; color_pixmap = None;
} }
if (prop != None) { if (prop != None) {
@ -1832,19 +1837,19 @@ get_desktop_pixmap(void)
Screen *scr = ScreenOfDisplay(Xdisplay, Xscreen); Screen *scr = ScreenOfDisplay(Xdisplay, Xscreen);
gcvalue.foreground = gcvalue.background = PixColors[bgColor]; 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); 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)); 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) { 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); XCopyArea(Xdisplay, p, desktop_pixmap, gc, 0, 0, pw, ph, 0, 0);
colormod_trans(desktop_pixmap, images[image_bg].current->iml, gc, pw, ph); colormod_trans(desktop_pixmap, images[image_bg].current->iml, gc, pw, ph);
} else { } 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); 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); 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; desktop_pixmap_is_mine = 1;
D_PIXMAP(("Returning 0x%08x\n", (unsigned int) desktop_pixmap)); D_PIXMAP(("Returning 0x%08x\n", (unsigned int) desktop_pixmap));
return (desktop_pixmap); return (desktop_pixmap);
@ -1870,12 +1875,12 @@ get_desktop_pixmap(void)
D_PIXMAP((" Found solid color 0x%08x\n", pix)); D_PIXMAP((" Found solid color 0x%08x\n", pix));
gcvalue.foreground = pix; gcvalue.foreground = pix;
gcvalue.background = 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); XFillRectangle(Xdisplay, color_pixmap, gc, 0, 0, 16, 16);
D_PIXMAP(("Created solid color pixmap 0x%08x for desktop_pixmap.\n", color_pixmap)); 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); return (desktop_pixmap = color_pixmap);
} }
} }
@ -1890,7 +1895,7 @@ free_desktop_pixmap(void)
{ {
if (desktop_pixmap_is_mine && desktop_pixmap != None) { if (desktop_pixmap_is_mine && desktop_pixmap != None) {
XFreePixmap(Xdisplay, desktop_pixmap); X_FREE_PIXMAP(desktop_pixmap);
desktop_pixmap_is_mine = 0; desktop_pixmap_is_mine = 0;
} }
desktop_pixmap = None; desktop_pixmap = None;

View File

@ -48,6 +48,7 @@
# define CONVERT_TINT_RED(t) (((t) & 0xff0000) >> 16) # define CONVERT_TINT_RED(t) (((t) & 0xff0000) >> 16)
# define CONVERT_TINT_GREEN(t) (((t) & 0x00ff00) >> 8) # define CONVERT_TINT_GREEN(t) (((t) & 0x00ff00) >> 8)
# define CONVERT_TINT_BLUE(t) ((t) & 0x0000ff) # 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 #else
# define background_is_image() (0) # define background_is_image() (0)
# define background_is_trans() (0) # define background_is_trans() (0)
@ -56,7 +57,20 @@
# define background_is_pixmap() (0) # define background_is_pixmap() (0)
# define get_image_type_string(t) ((char *) "") # define get_image_type_string(t) ((char *) "")
# define delete_simage(simg) NOP # define delete_simage(simg) NOP
# define IMLIB_FREE_PIXMAP(p) NOP
#endif #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 PIXMAP_EXT NULL
#define GEOM_LEN 19 #define GEOM_LEN 19

View File

@ -875,19 +875,19 @@ scrollbar_drawing_init(void) {
gcvalue.fill_style = FillOpaqueStippled; gcvalue.fill_style = FillOpaqueStippled;
gcvalue.foreground = PixColors[fgColor]; gcvalue.foreground = PixColors[fgColor];
gcvalue.background = PixColors[bgColor]; 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]; gcvalue.foreground = PixColors[borderColor];
gc_border = XCreateGC(Xdisplay, scrollbar.win, GCForeground, &gcvalue); gc_border = X_CREATE_GC(GCForeground, &gcvalue);
} }
#endif /* XTERM_SCROLLBAR */ #endif /* XTERM_SCROLLBAR */
#if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR) #if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR)
gcvalue.foreground = images[image_sb].norm->bg; 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]; gcvalue.foreground = PixColors[topShadowColor];
gc_top = XCreateGC(Xdisplay, scrollbar.win, GCForeground, &gcvalue); gc_top = X_CREATE_GC(GCForeground, &gcvalue);
gcvalue.foreground = PixColors[bottomShadowColor]; gcvalue.foreground = PixColors[bottomShadowColor];
gc_bottom = XCreateGC(Xdisplay, scrollbar.win, GCForeground, &gcvalue); gc_bottom = X_CREATE_GC(GCForeground, &gcvalue);
#endif /* MOTIF_SCROLLBAR || NEXT_SCROLLBAR */ #endif /* MOTIF_SCROLLBAR || NEXT_SCROLLBAR */
} }

View File

@ -1819,7 +1819,7 @@ xterm_seq(int op, const char *str)
if (image_mode_is(which, MODE_TRANS) && (desktop_pixmap != None)) { if (image_mode_is(which, MODE_TRANS) && (desktop_pixmap != None)) {
free_desktop_pixmap(); free_desktop_pixmap();
} else if (image_mode_is(which, MODE_VIEWPORT) && (viewport_pixmap != None)) { } 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 */ viewport_pixmap = None; /* Force the re-read */
} }
# endif # endif
@ -1835,7 +1835,7 @@ xterm_seq(int op, const char *str)
if (image_mode_is(which, MODE_TRANS) && (desktop_pixmap != None)) { if (image_mode_is(which, MODE_TRANS) && (desktop_pixmap != None)) {
free_desktop_pixmap(); free_desktop_pixmap();
} else if (image_mode_is(which, MODE_VIEWPORT) && (viewport_pixmap != None)) { } 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 */ viewport_pixmap = None; /* Force the re-read */
} }
# endif # endif

View File

@ -378,7 +378,9 @@ Create_Windows(int argc, char *argv[])
Attributes.background_pixel = PixColors[bgColor]; Attributes.background_pixel = PixColors[bgColor];
Attributes.border_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, TermWin.parent = XCreateWindow(Xdisplay, Xroot, szHint.x, szHint.y, szHint.width, szHint.height, 0, Xdepth, InputOutput,
#ifdef PREFER_24BIT #ifdef PREFER_24BIT
Xvisual, Xvisual,
@ -468,7 +470,7 @@ Create_Windows(int argc, char *argv[])
gcvalue.foreground = PixColors[fgColor]; gcvalue.foreground = PixColors[fgColor];
gcvalue.background = PixColors[bgColor]; gcvalue.background = PixColors[bgColor];
gcvalue.graphics_exposures = 0; 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) { if (Options & Opt_noCursor) {