# HG changeset patch # User Gerd Moellmann # Date 960836951 0 # Node ID a377acd06ea8c836b959d5c23ae06afdfabb4413 # Parent 8a2e32f7717ed1034bcc5e0732eb1ebe252cb56f (x_frame_of_widget): New function. (x_alloc_nearest_color_for_widget): Use it. (x_copy_dpy_color): New function. (x_destroy_window): Free various colors. diff -r 8a2e32f7717e -r a377acd06ea8 src/xterm.c --- a/src/xterm.c Mon Jun 12 19:08:37 2000 +0000 +++ b/src/xterm.c Mon Jun 12 19:09:11 2000 +0000 @@ -412,7 +412,6 @@ static struct glyph *x_y_to_hpos_vpos P_ ((struct window *, int, int, int *, int *, int *)); static void note_mode_line_highlight P_ ((struct window *, int, int)); -static void x_check_font P_ ((struct frame *, XFontStruct *)); static void note_mouse_highlight P_ ((struct frame *, int, int)); static void note_tool_bar_highlight P_ ((struct frame *f, int, int)); static void x_handle_tool_bar_click P_ ((struct frame *, XButtonEvent *)); @@ -1187,7 +1186,7 @@ } return ((pcm == NULL - || pcm->width == 0 && (pcm->rbearing - pcm->lbearing) == 0) + || (pcm->width == 0 && (pcm->rbearing - pcm->lbearing) == 0)) ? NULL : pcm); } @@ -1613,7 +1612,10 @@ struct it *it; { /* (space :width WIDTH :height HEIGHT. */ - extern Lisp_Object QCwidth, QCheight, QCascent, Qspace; +#if GLYPH_DEBUG + extern Lisp_Object Qspace; +#endif + extern Lisp_Object QCwidth, QCheight, QCascent; extern Lisp_Object QCrelative_width, QCrelative_height; extern Lisp_Object QCalign_to; Lisp_Object prop, plist; @@ -2850,8 +2852,6 @@ struct frame *f; int *left, *right; { - int c; - *left = *right = 0; if (glyph->type == CHAR_GLYPH) @@ -3154,21 +3154,20 @@ #ifdef USE_X_TOOLKIT -/* Allocate the color COLOR->pixel on the screen and display of - widget WIDGET in colormap CMAP. If an exact match cannot be - allocated, try the nearest color available. Value is non-zero - if successful. This is called from lwlib. */ - -int -x_alloc_nearest_color_for_widget (widget, cmap, color) +static struct frame *x_frame_of_widget P_ ((Widget)); + + +/* Return the frame on which widget WIDGET is used.. Abort if frame + cannot be determined. */ + +struct frame * +x_frame_of_widget (widget) Widget widget; - Colormap cmap; - XColor *color; -{ - struct frame *f; +{ struct x_display_info *dpyinfo; Lisp_Object tail; - + struct frame *f; + dpyinfo = x_display_info_for_display (XtDisplay (widget)); /* Find the top-level shell of the widget. Note that this function @@ -3186,11 +3185,28 @@ (f->output_data.nothing != 1 && FRAME_X_DISPLAY_INFO (f) == dpyinfo)) && f->output_data.x->widget == widget) - return x_alloc_nearest_color (f, cmap, color); + return f; abort (); } + +/* Allocate the color COLOR->pixel on the screen and display of + widget WIDGET in colormap CMAP. If an exact match cannot be + allocated, try the nearest color available. Value is non-zero + if successful. This is called from lwlib. */ + +int +x_alloc_nearest_color_for_widget (widget, cmap, color) + Widget widget; + Colormap cmap; + XColor *color; +{ + struct frame *f = x_frame_of_widget (widget); + return x_alloc_nearest_color (f, cmap, color); +} + + #endif /* USE_X_TOOLKIT */ @@ -3278,6 +3294,30 @@ } +/* Allocate color PIXEL on display DPY. PIXEL must already be allocated. + It's necessary to do this instead of just using PIXEL directly to + get color reference counts right. */ + +unsigned long +x_copy_dpy_color (dpy, cmap, pixel) + Display *dpy; + Colormap cmap; + unsigned long pixel; +{ + XColor color; + + color.pixel = pixel; + BLOCK_INPUT; + XQueryColor (dpy, cmap, &color); + XAllocColor (dpy, cmap, &color); + UNBLOCK_INPUT; +#ifdef DEBUG_X_COLORS + register_color (pixel); +#endif + return color.pixel; +} + + /* Allocate a color which is lighter or darker than *PIXEL by FACTOR or DELTA. Try a color with RGB values multiplied by FACTOR first. If this produces the same color as PIXEL, try a color where all RGB @@ -3364,8 +3404,6 @@ if (relief->gc && relief->allocated_p) { - /* If display has an immutable color map, freeing colors is not - necessary and some servers don't allow it. So don't do it. */ x_free_colors (f, &relief->pixel, 1); relief->allocated_p = 0; } @@ -4383,7 +4421,7 @@ #define BUILD_CHAR_GLYPH_STRINGS(W, ROW, AREA, START, END, HEAD, TAIL, HL, X, LAST_X, OVERLAPS_P) \ do \ { \ - int c, charset, face_id; \ + int c, face_id; \ XChar2b *char2b; \ \ c = (ROW)->glyphs[AREA][START].u.ch; \ @@ -6131,7 +6169,7 @@ int *hpos, *vpos, *area; { struct glyph *glyph, *end; - struct glyph_row *row; + struct glyph_row *row = NULL; int x0, i, left_area_width; /* Find row containing Y. Give up if some row is not enabled. */ @@ -7885,7 +7923,7 @@ { #ifdef HAVE_XAW3D ScrollbarWidget sb = (ScrollbarWidget) widget; - int scroll_mode; + int scroll_mode = 0; /* `scroll_mode' only exists with Xaw3d + ARROW_SCROLLBAR. */ if (xaw3d_arrow_scroll) @@ -10967,7 +11005,6 @@ { int fontset = fs_query_fontset (build_string (fontsetname), 0); Lisp_Object result; - char *fontname; if (fontset < 0) return Qnil; @@ -11678,6 +11715,7 @@ /* It could be confusing if a real alarm arrives while processing the fake one. Turn it off and let the handler reset it. */ + extern void poll_for_input_1 P_ ((void)); int old_poll_suppress_count = poll_suppress_count; poll_suppress_count = 1; poll_for_input_1 (); @@ -11909,6 +11947,21 @@ free_frame_menubar (f); #endif /* USE_X_TOOLKIT */ + unload_color (f, f->output_data.x->foreground_pixel); + unload_color (f, f->output_data.x->background_pixel); + unload_color (f, f->output_data.x->cursor_pixel); + unload_color (f, f->output_data.x->cursor_foreground_pixel); + unload_color (f, f->output_data.x->border_pixel); + unload_color (f, f->output_data.x->mouse_pixel); + if (f->output_data.x->scroll_bar_background_pixel != -1) + unload_color (f, f->output_data.x->scroll_bar_background_pixel); + if (f->output_data.x->scroll_bar_foreground_pixel != -1) + unload_color (f, f->output_data.x->scroll_bar_foreground_pixel); + if (f->output_data.x->white_relief.allocated_p) + unload_color (f, f->output_data.x->white_relief.pixel); + if (f->output_data.x->black_relief.allocated_p) + unload_color (f, f->output_data.x->black_relief.pixel); + free_frame_faces (f); XFlush (FRAME_X_DISPLAY (f)); } @@ -12226,7 +12279,7 @@ for (; CONSP (patterns); patterns = XCDR (patterns)) { int num_fonts; - char **names; + char **names = NULL; pattern = XCAR (patterns); /* See if we cached the result for this particular query.