From 0085b9be229be7369300f4f4ab27a9699db641b4 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Tue, 29 Oct 2013 09:55:25 +0400 Subject: [PATCH] * xterm.h (struct x_output): For 'black_relief' and 'white_relief' fields, drop 'allocated_p' member and use -1 for uninitialized value. * w32term.h (struct w32_output): Similarly but do not use -1 because... * xfaces.c (unload_color) [HAVE_X_WINDOWS]: ...this function is a no-op on MS-Windows anyway. (free_face_colors): Define only if HAVE_X_WINDOWS and... (free_realized_face): ...adjust user. * xfns.c (Fx_create_frame, x_create_tip_frame): Initialize black and white relief pixels to -1. * xterm.c (x_setup_relief_color, x_free_frame_resources): Adjust users. * w32term.c (w32_setup_relief_color, x_free_frame_resources): Likewise. * dispextern.h (unload_color): Move prototype under HAVE_X_WINDOWS. --- src/ChangeLog | 15 +++++++++++++++ src/dispextern.h | 2 +- src/w32term.c | 16 +--------------- src/w32term.h | 1 - src/xfaces.c | 14 +++++++------- src/xfns.c | 5 +++++ src/xterm.c | 14 +++++--------- src/xterm.h | 1 - 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 6458b739a5..55ff9390ce 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2013-10-29 Dmitry Antipov + + * xterm.h (struct x_output): For 'black_relief' and 'white_relief' + fields, drop 'allocated_p' member and use -1 for uninitialized value. + * w32term.h (struct w32_output): Similarly but do not use -1 because... + * xfaces.c (unload_color) [HAVE_X_WINDOWS]: ...this function is a no-op + on MS-Windows anyway. + (free_face_colors): Define only if HAVE_X_WINDOWS and... + (free_realized_face): ...adjust user. + * xfns.c (Fx_create_frame, x_create_tip_frame): Initialize black and + white relief pixels to -1. + * xterm.c (x_setup_relief_color, x_free_frame_resources): Adjust users. + * w32term.c (w32_setup_relief_color, x_free_frame_resources): Likewise. + * dispextern.h (unload_color): Move prototype under HAVE_X_WINDOWS. + 2013-10-28 Paul Eggert * dispextern.h, image.c (x_bitmap_height, x_bitmap_width): Now static. diff --git a/src/dispextern.h b/src/dispextern.h index e61347ebf9..0d225e9616 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3328,6 +3328,7 @@ void ignore_sigio (void); /* Defined in xfaces.c */ #ifdef HAVE_X_WINDOWS +void unload_color (struct frame *, unsigned long); void x_free_colors (struct frame *, unsigned long *, int); #endif @@ -3339,7 +3340,6 @@ void clear_face_cache (int); unsigned long load_color (struct frame *, struct face *, Lisp_Object, enum lface_attribute_index); #endif -void unload_color (struct frame *, unsigned long); char *choose_face_font (struct frame *, Lisp_Object *, Lisp_Object, int *); void prepare_face_for_display (struct frame *, struct face *); diff --git a/src/w32term.c b/src/w32term.c index 8bc46734b7..275df92731 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -1596,10 +1596,7 @@ w32_setup_relief_color (struct frame *f, struct relief *relief, double factor, xgcv.foreground = default_pixel; pixel = background; if (w32_alloc_lighter_color (f, &pixel, factor, delta)) - { - relief->allocated_p = 1; - xgcv.foreground = relief->pixel = pixel; - } + xgcv.foreground = relief->pixel = pixel; if (relief->gc == 0) { @@ -6001,17 +5998,6 @@ x_free_frame_resources (struct frame *f) free_frame_menubar (f); - unload_color (f, FRAME_FOREGROUND_PIXEL (f)); - unload_color (f, FRAME_BACKGROUND_PIXEL (f)); - unload_color (f, f->output_data.w32->cursor_pixel); - unload_color (f, f->output_data.w32->cursor_foreground_pixel); - unload_color (f, f->output_data.w32->border_pixel); - unload_color (f, f->output_data.w32->mouse_pixel); - if (f->output_data.w32->white_relief.allocated_p) - unload_color (f, f->output_data.w32->white_relief.pixel); - if (f->output_data.w32->black_relief.allocated_p) - unload_color (f, f->output_data.w32->black_relief.pixel); - if (FRAME_FACE_CACHE (f)) free_frame_faces (f); diff --git a/src/w32term.h b/src/w32term.h index 956e03d336..b3c0cf56c7 100644 --- a/src/w32term.h +++ b/src/w32term.h @@ -376,7 +376,6 @@ struct w32_output { XGCValues *gc; unsigned long pixel; - int allocated_p; } black_relief, white_relief; diff --git a/src/xfaces.c b/src/xfaces.c index 313e863411..21a66d390d 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -1293,30 +1293,28 @@ load_face_colors (struct frame *f, struct face *face, face->foreground = load_color (f, face, fg, LFACE_FOREGROUND_INDEX); } +#ifdef HAVE_X_WINDOWS /* Free color PIXEL on frame F. */ void unload_color (struct frame *f, long unsigned int pixel) { -#ifdef HAVE_X_WINDOWS if (pixel != -1) { block_input (); x_free_colors (f, &pixel, 1); unblock_input (); } -#endif } - /* Free colors allocated for FACE. */ static void free_face_colors (struct frame *f, struct face *face) { -/* PENDING(NS): need to do something here? */ -#ifdef HAVE_X_WINDOWS + /* PENDING(NS): need to do something here? */ + if (face->colors_copied_bitwise_p) return; @@ -1363,9 +1361,10 @@ free_face_colors (struct frame *f, struct face *face) } unblock_input (); -#endif /* HAVE_X_WINDOWS */ } +#endif /* HAVE_X_WINDOWS */ + #endif /* HAVE_WINDOW_SYSTEM */ @@ -4039,8 +4038,9 @@ free_realized_face (struct frame *f, struct face *face) face->gc = 0; unblock_input (); } - +#ifdef HAVE_X_WINDOWS free_face_colors (f, face); +#endif /* HAVE_X_WINDOWS */ x_destroy_bitmap (f, face->stipple); } #endif /* HAVE_WINDOW_SYSTEM */ diff --git a/src/xfns.c b/src/xfns.c index 9cd7d3e662..695a72a702 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -2880,6 +2880,8 @@ This function is an internal primitive--use `make-frame' instead. */) f->output_data.x->scroll_bar_top_shadow_pixel = -1; f->output_data.x->scroll_bar_bottom_shadow_pixel = -1; #endif /* USE_TOOLKIT_SCROLL_BARS */ + f->output_data.x->white_relief.pixel = -1; + f->output_data.x->black_relief.pixel = -1; fset_icon_name (f, x_get_arg (dpyinfo, parms, Qicon_name, "iconName", "Title", @@ -4824,6 +4826,9 @@ x_create_tip_frame (struct x_display_info *dpyinfo, f->output_data.x->scroll_bar_top_shadow_pixel = -1; f->output_data.x->scroll_bar_bottom_shadow_pixel = -1; #endif /* USE_TOOLKIT_SCROLL_BARS */ + f->output_data.x->white_relief.pixel = -1; + f->output_data.x->black_relief.pixel = -1; + fset_icon_name (f, Qnil); FRAME_DISPLAY_INFO (f) = dpyinfo; f->output_data.x->parent_desc = FRAME_DISPLAY_INFO (f)->root_window; diff --git a/src/xterm.c b/src/xterm.c index 26ad526762..c7fe9ec6ac 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -1774,11 +1774,10 @@ x_setup_relief_color (struct frame *f, struct relief *relief, double factor, int /* Free previously allocated color. The color cell will be reused when it has been freed as many times as it was allocated, so this doesn't affect faces using the same colors. */ - if (relief->gc - && relief->allocated_p) + if (relief->gc && relief->pixel != -1) { x_free_colors (f, &relief->pixel, 1); - relief->allocated_p = 0; + relief->pixel = -1; } /* Allocate new color. */ @@ -1786,10 +1785,7 @@ x_setup_relief_color (struct frame *f, struct relief *relief, double factor, int pixel = background; if (dpyinfo->n_planes != 1 && x_alloc_lighter_color (f, dpy, cmap, &pixel, factor, delta)) - { - relief->allocated_p = 1; - xgcv.foreground = relief->pixel = pixel; - } + xgcv.foreground = relief->pixel = pixel; if (relief->gc == 0) { @@ -9338,9 +9334,9 @@ x_free_frame_resources (struct frame *f) if (f->output_data.x->scroll_bar_bottom_shadow_pixel != -1) unload_color (f, f->output_data.x->scroll_bar_bottom_shadow_pixel); #endif /* USE_TOOLKIT_SCROLL_BARS */ - if (f->output_data.x->white_relief.allocated_p) + if (f->output_data.x->white_relief.pixel != -1) unload_color (f, f->output_data.x->white_relief.pixel); - if (f->output_data.x->black_relief.allocated_p) + if (f->output_data.x->black_relief.pixel != -1) unload_color (f, f->output_data.x->black_relief.pixel); x_free_gcs (f); diff --git a/src/xterm.h b/src/xterm.h index 06c0d4882b..753debff1b 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -605,7 +605,6 @@ struct x_output { GC gc; unsigned long pixel; - int allocated_p; } black_relief, white_relief; -- 2.20.1