aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2000-06-12 19:09:11 +0000
committerGerd Moellmann2000-06-12 19:09:11 +0000
commit3e71d8f2eb24cf7c7cea796f65963be10e9795c3 (patch)
treeb9714908290e392d5afa2cd68533175b3d185e77
parent08dc08dc4d678b8585a4c95fa6396fb64fb40211 (diff)
downloademacs-3e71d8f2eb24cf7c7cea796f65963be10e9795c3.tar.gz
emacs-3e71d8f2eb24cf7c7cea796f65963be10e9795c3.zip
(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.
-rw-r--r--src/xterm.c99
1 files changed, 76 insertions, 23 deletions
diff --git a/src/xterm.c b/src/xterm.c
index c2cc57a319d..11e0e900f15 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -412,7 +412,6 @@ static void set_output_cursor P_ ((struct cursor_pos *));
412static struct glyph *x_y_to_hpos_vpos P_ ((struct window *, int, int, 412static struct glyph *x_y_to_hpos_vpos P_ ((struct window *, int, int,
413 int *, int *, int *)); 413 int *, int *, int *));
414static void note_mode_line_highlight P_ ((struct window *, int, int)); 414static void note_mode_line_highlight P_ ((struct window *, int, int));
415static void x_check_font P_ ((struct frame *, XFontStruct *));
416static void note_mouse_highlight P_ ((struct frame *, int, int)); 415static void note_mouse_highlight P_ ((struct frame *, int, int));
417static void note_tool_bar_highlight P_ ((struct frame *f, int, int)); 416static void note_tool_bar_highlight P_ ((struct frame *f, int, int));
418static void x_handle_tool_bar_click P_ ((struct frame *, XButtonEvent *)); 417static void x_handle_tool_bar_click P_ ((struct frame *, XButtonEvent *));
@@ -1187,7 +1186,7 @@ x_per_char_metric (font, char2b)
1187 } 1186 }
1188 1187
1189 return ((pcm == NULL 1188 return ((pcm == NULL
1190 || pcm->width == 0 && (pcm->rbearing - pcm->lbearing) == 0) 1189 || (pcm->width == 0 && (pcm->rbearing - pcm->lbearing) == 0))
1191 ? NULL : pcm); 1190 ? NULL : pcm);
1192} 1191}
1193 1192
@@ -1613,7 +1612,10 @@ x_produce_stretch_glyph (it)
1613 struct it *it; 1612 struct it *it;
1614{ 1613{
1615 /* (space :width WIDTH :height HEIGHT. */ 1614 /* (space :width WIDTH :height HEIGHT. */
1616 extern Lisp_Object QCwidth, QCheight, QCascent, Qspace; 1615#if GLYPH_DEBUG
1616 extern Lisp_Object Qspace;
1617#endif
1618 extern Lisp_Object QCwidth, QCheight, QCascent;
1617 extern Lisp_Object QCrelative_width, QCrelative_height; 1619 extern Lisp_Object QCrelative_width, QCrelative_height;
1618 extern Lisp_Object QCalign_to; 1620 extern Lisp_Object QCalign_to;
1619 Lisp_Object prop, plist; 1621 Lisp_Object prop, plist;
@@ -2850,8 +2852,6 @@ x_get_glyph_overhangs (glyph, f, left, right)
2850 struct frame *f; 2852 struct frame *f;
2851 int *left, *right; 2853 int *left, *right;
2852{ 2854{
2853 int c;
2854
2855 *left = *right = 0; 2855 *left = *right = 0;
2856 2856
2857 if (glyph->type == CHAR_GLYPH) 2857 if (glyph->type == CHAR_GLYPH)
@@ -3154,21 +3154,20 @@ x_draw_composite_glyph_string_foreground (s)
3154 3154
3155#ifdef USE_X_TOOLKIT 3155#ifdef USE_X_TOOLKIT
3156 3156
3157/* Allocate the color COLOR->pixel on the screen and display of 3157static struct frame *x_frame_of_widget P_ ((Widget));
3158 widget WIDGET in colormap CMAP. If an exact match cannot be
3159 allocated, try the nearest color available. Value is non-zero
3160 if successful. This is called from lwlib. */
3161 3158
3162int 3159
3163x_alloc_nearest_color_for_widget (widget, cmap, color) 3160/* Return the frame on which widget WIDGET is used.. Abort if frame
3161 cannot be determined. */
3162
3163struct frame *
3164x_frame_of_widget (widget)
3164 Widget widget; 3165 Widget widget;
3165 Colormap cmap;
3166 XColor *color;
3167{ 3166{
3168 struct frame *f;
3169 struct x_display_info *dpyinfo; 3167 struct x_display_info *dpyinfo;
3170 Lisp_Object tail; 3168 Lisp_Object tail;
3171 3169 struct frame *f;
3170
3172 dpyinfo = x_display_info_for_display (XtDisplay (widget)); 3171 dpyinfo = x_display_info_for_display (XtDisplay (widget));
3173 3172
3174 /* Find the top-level shell of the widget. Note that this function 3173 /* Find the top-level shell of the widget. Note that this function
@@ -3186,11 +3185,28 @@ x_alloc_nearest_color_for_widget (widget, cmap, color)
3186 (f->output_data.nothing != 1 3185 (f->output_data.nothing != 1
3187 && FRAME_X_DISPLAY_INFO (f) == dpyinfo)) 3186 && FRAME_X_DISPLAY_INFO (f) == dpyinfo))
3188 && f->output_data.x->widget == widget) 3187 && f->output_data.x->widget == widget)
3189 return x_alloc_nearest_color (f, cmap, color); 3188 return f;
3190 3189
3191 abort (); 3190 abort ();
3192} 3191}
3193 3192
3193
3194/* Allocate the color COLOR->pixel on the screen and display of
3195 widget WIDGET in colormap CMAP. If an exact match cannot be
3196 allocated, try the nearest color available. Value is non-zero
3197 if successful. This is called from lwlib. */
3198
3199int
3200x_alloc_nearest_color_for_widget (widget, cmap, color)
3201 Widget widget;
3202 Colormap cmap;
3203 XColor *color;
3204{
3205 struct frame *f = x_frame_of_widget (widget);
3206 return x_alloc_nearest_color (f, cmap, color);
3207}
3208
3209
3194#endif /* USE_X_TOOLKIT */ 3210#endif /* USE_X_TOOLKIT */
3195 3211
3196 3212
@@ -3278,6 +3294,30 @@ x_copy_color (f, pixel)
3278} 3294}
3279 3295
3280 3296
3297/* Allocate color PIXEL on display DPY. PIXEL must already be allocated.
3298 It's necessary to do this instead of just using PIXEL directly to
3299 get color reference counts right. */
3300
3301unsigned long
3302x_copy_dpy_color (dpy, cmap, pixel)
3303 Display *dpy;
3304 Colormap cmap;
3305 unsigned long pixel;
3306{
3307 XColor color;
3308
3309 color.pixel = pixel;
3310 BLOCK_INPUT;
3311 XQueryColor (dpy, cmap, &color);
3312 XAllocColor (dpy, cmap, &color);
3313 UNBLOCK_INPUT;
3314#ifdef DEBUG_X_COLORS
3315 register_color (pixel);
3316#endif
3317 return color.pixel;
3318}
3319
3320
3281/* Allocate a color which is lighter or darker than *PIXEL by FACTOR 3321/* Allocate a color which is lighter or darker than *PIXEL by FACTOR
3282 or DELTA. Try a color with RGB values multiplied by FACTOR first. 3322 or DELTA. Try a color with RGB values multiplied by FACTOR first.
3283 If this produces the same color as PIXEL, try a color where all RGB 3323 If this produces the same color as PIXEL, try a color where all RGB
@@ -3364,8 +3404,6 @@ x_setup_relief_color (f, relief, factor, delta, default_pixel)
3364 if (relief->gc 3404 if (relief->gc
3365 && relief->allocated_p) 3405 && relief->allocated_p)
3366 { 3406 {
3367 /* If display has an immutable color map, freeing colors is not
3368 necessary and some servers don't allow it. So don't do it. */
3369 x_free_colors (f, &relief->pixel, 1); 3407 x_free_colors (f, &relief->pixel, 1);
3370 relief->allocated_p = 0; 3408 relief->allocated_p = 0;
3371 } 3409 }
@@ -4383,7 +4421,7 @@ x_set_glyph_string_background_width (s, start, last_x)
4383#define BUILD_CHAR_GLYPH_STRINGS(W, ROW, AREA, START, END, HEAD, TAIL, HL, X, LAST_X, OVERLAPS_P) \ 4421#define BUILD_CHAR_GLYPH_STRINGS(W, ROW, AREA, START, END, HEAD, TAIL, HL, X, LAST_X, OVERLAPS_P) \
4384 do \ 4422 do \
4385 { \ 4423 { \
4386 int c, charset, face_id; \ 4424 int c, face_id; \
4387 XChar2b *char2b; \ 4425 XChar2b *char2b; \
4388 \ 4426 \
4389 c = (ROW)->glyphs[AREA][START].u.ch; \ 4427 c = (ROW)->glyphs[AREA][START].u.ch; \
@@ -6131,7 +6169,7 @@ x_y_to_hpos_vpos (w, x, y, hpos, vpos, area)
6131 int *hpos, *vpos, *area; 6169 int *hpos, *vpos, *area;
6132{ 6170{
6133 struct glyph *glyph, *end; 6171 struct glyph *glyph, *end;
6134 struct glyph_row *row; 6172 struct glyph_row *row = NULL;
6135 int x0, i, left_area_width; 6173 int x0, i, left_area_width;
6136 6174
6137 /* Find row containing Y. Give up if some row is not enabled. */ 6175 /* Find row containing Y. Give up if some row is not enabled. */
@@ -7885,7 +7923,7 @@ x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole)
7885 { 7923 {
7886#ifdef HAVE_XAW3D 7924#ifdef HAVE_XAW3D
7887 ScrollbarWidget sb = (ScrollbarWidget) widget; 7925 ScrollbarWidget sb = (ScrollbarWidget) widget;
7888 int scroll_mode; 7926 int scroll_mode = 0;
7889 7927
7890 /* `scroll_mode' only exists with Xaw3d + ARROW_SCROLLBAR. */ 7928 /* `scroll_mode' only exists with Xaw3d + ARROW_SCROLLBAR. */
7891 if (xaw3d_arrow_scroll) 7929 if (xaw3d_arrow_scroll)
@@ -10967,7 +11005,6 @@ x_new_fontset (f, fontsetname)
10967{ 11005{
10968 int fontset = fs_query_fontset (build_string (fontsetname), 0); 11006 int fontset = fs_query_fontset (build_string (fontsetname), 0);
10969 Lisp_Object result; 11007 Lisp_Object result;
10970 char *fontname;
10971 11008
10972 if (fontset < 0) 11009 if (fontset < 0)
10973 return Qnil; 11010 return Qnil;
@@ -11678,6 +11715,7 @@ x_make_frame_visible (f)
11678 /* It could be confusing if a real alarm arrives while 11715 /* It could be confusing if a real alarm arrives while
11679 processing the fake one. Turn it off and let the 11716 processing the fake one. Turn it off and let the
11680 handler reset it. */ 11717 handler reset it. */
11718 extern void poll_for_input_1 P_ ((void));
11681 int old_poll_suppress_count = poll_suppress_count; 11719 int old_poll_suppress_count = poll_suppress_count;
11682 poll_suppress_count = 1; 11720 poll_suppress_count = 1;
11683 poll_for_input_1 (); 11721 poll_for_input_1 ();
@@ -11909,6 +11947,21 @@ x_destroy_window (f)
11909 free_frame_menubar (f); 11947 free_frame_menubar (f);
11910#endif /* USE_X_TOOLKIT */ 11948#endif /* USE_X_TOOLKIT */
11911 11949
11950 unload_color (f, f->output_data.x->foreground_pixel);
11951 unload_color (f, f->output_data.x->background_pixel);
11952 unload_color (f, f->output_data.x->cursor_pixel);
11953 unload_color (f, f->output_data.x->cursor_foreground_pixel);
11954 unload_color (f, f->output_data.x->border_pixel);
11955 unload_color (f, f->output_data.x->mouse_pixel);
11956 if (f->output_data.x->scroll_bar_background_pixel != -1)
11957 unload_color (f, f->output_data.x->scroll_bar_background_pixel);
11958 if (f->output_data.x->scroll_bar_foreground_pixel != -1)
11959 unload_color (f, f->output_data.x->scroll_bar_foreground_pixel);
11960 if (f->output_data.x->white_relief.allocated_p)
11961 unload_color (f, f->output_data.x->white_relief.pixel);
11962 if (f->output_data.x->black_relief.allocated_p)
11963 unload_color (f, f->output_data.x->black_relief.pixel);
11964
11912 free_frame_faces (f); 11965 free_frame_faces (f);
11913 XFlush (FRAME_X_DISPLAY (f)); 11966 XFlush (FRAME_X_DISPLAY (f));
11914 } 11967 }
@@ -12226,7 +12279,7 @@ x_list_fonts (f, pattern, size, maxnames)
12226 for (; CONSP (patterns); patterns = XCDR (patterns)) 12279 for (; CONSP (patterns); patterns = XCDR (patterns))
12227 { 12280 {
12228 int num_fonts; 12281 int num_fonts;
12229 char **names; 12282 char **names = NULL;
12230 12283
12231 pattern = XCAR (patterns); 12284 pattern = XCAR (patterns);
12232 /* See if we cached the result for this particular query. 12285 /* See if we cached the result for this particular query.