comparison src/xterm.c @ 29600:a377acd06ea8

(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.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 12 Jun 2000 19:09:11 +0000
parents 4def8a9e785a
children d171b4754825
comparison
equal deleted inserted replaced
29599:8a2e32f7717e 29600:a377acd06ea8
410 int *, int *)); 410 int *, int *));
411 static void set_output_cursor P_ ((struct cursor_pos *)); 411 static void set_output_cursor P_ ((struct cursor_pos *));
412 static struct glyph *x_y_to_hpos_vpos P_ ((struct window *, int, int, 412 static struct glyph *x_y_to_hpos_vpos P_ ((struct window *, int, int,
413 int *, int *, int *)); 413 int *, int *, int *));
414 static void note_mode_line_highlight P_ ((struct window *, int, int)); 414 static void note_mode_line_highlight P_ ((struct window *, int, int));
415 static void x_check_font P_ ((struct frame *, XFontStruct *));
416 static void note_mouse_highlight P_ ((struct frame *, int, int)); 415 static void note_mouse_highlight P_ ((struct frame *, int, int));
417 static void note_tool_bar_highlight P_ ((struct frame *f, int, int)); 416 static void note_tool_bar_highlight P_ ((struct frame *f, int, int));
418 static void x_handle_tool_bar_click P_ ((struct frame *, XButtonEvent *)); 417 static void x_handle_tool_bar_click P_ ((struct frame *, XButtonEvent *));
419 static void show_mouse_face P_ ((struct x_display_info *, 418 static void show_mouse_face P_ ((struct x_display_info *,
420 enum draw_glyphs_face)); 419 enum draw_glyphs_face));
1185 && char2b->byte2 <= font->max_char_or_byte2) 1184 && char2b->byte2 <= font->max_char_or_byte2)
1186 pcm = &font->max_bounds; 1185 pcm = &font->max_bounds;
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
1194 1193
1195 /* Encode CHAR2B using encoding information from FONT_INFO. CHAR2B is 1194 /* Encode CHAR2B using encoding information from FONT_INFO. CHAR2B is
1611 static void 1610 static void
1612 x_produce_stretch_glyph (it) 1611 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;
1620 double width = 0, height = 0, ascent = 0; 1622 double width = 0, height = 0, ascent = 0;
1621 struct face *face = FACE_FROM_ID (it->f, it->face_id); 1623 struct face *face = FACE_FROM_ID (it->f, it->face_id);
2848 x_get_glyph_overhangs (glyph, f, left, right) 2850 x_get_glyph_overhangs (glyph, f, left, right)
2849 struct glyph *glyph; 2851 struct glyph *glyph;
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)
2858 { 2858 {
2859 XFontStruct *font; 2859 XFontStruct *font;
3152 } 3152 }
3153 3153
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 3157 static struct frame *x_frame_of_widget P_ ((Widget));
3158 widget WIDGET in colormap CMAP. If an exact match cannot be 3158
3159 allocated, try the nearest color available. Value is non-zero 3159
3160 if successful. This is called from lwlib. */ 3160 /* Return the frame on which widget WIDGET is used.. Abort if frame
3161 3161 cannot be determined. */
3162 int 3162
3163 x_alloc_nearest_color_for_widget (widget, cmap, color) 3163 struct frame *
3164 x_frame_of_widget (widget)
3164 Widget widget; 3165 Widget widget;
3165 Colormap cmap; 3166 {
3166 XColor *color;
3167 {
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
3175 can be called when the widget is not yet realized, so XtWindow 3174 can be called when the widget is not yet realized, so XtWindow
3176 (widget) == 0. That's the reason we can't simply use 3175 (widget) == 0. That's the reason we can't simply use
3184 if (GC_FRAMEP (XCAR (tail)) 3183 if (GC_FRAMEP (XCAR (tail))
3185 && (f = XFRAME (XCAR (tail)), 3184 && (f = XFRAME (XCAR (tail)),
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 }
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
3199 int
3200 x_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
3193 3209
3194 #endif /* USE_X_TOOLKIT */ 3210 #endif /* USE_X_TOOLKIT */
3195 3211
3196 3212
3197 /* Allocate the color COLOR->pixel on SCREEN of DISPLAY, colormap 3213 /* Allocate the color COLOR->pixel on SCREEN of DISPLAY, colormap
3268 3284
3269 color.pixel = pixel; 3285 color.pixel = pixel;
3270 BLOCK_INPUT; 3286 BLOCK_INPUT;
3271 XQueryColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), &color); 3287 XQueryColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), &color);
3272 XAllocColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), &color); 3288 XAllocColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), &color);
3289 UNBLOCK_INPUT;
3290 #ifdef DEBUG_X_COLORS
3291 register_color (pixel);
3292 #endif
3293 return color.pixel;
3294 }
3295
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
3301 unsigned long
3302 x_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);
3273 UNBLOCK_INPUT; 3313 UNBLOCK_INPUT;
3274 #ifdef DEBUG_X_COLORS 3314 #ifdef DEBUG_X_COLORS
3275 register_color (pixel); 3315 register_color (pixel);
3276 #endif 3316 #endif
3277 return color.pixel; 3317 return color.pixel;
3362 when it has been freed as many times as it was allocated, so this 3402 when it has been freed as many times as it was allocated, so this
3363 doesn't affect faces using the same colors. */ 3403 doesn't affect faces using the same colors. */
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 }
3372 3410
3373 /* Allocate new color. */ 3411 /* Allocate new color. */
4381 right-most x-position of the drawing area. */ 4419 right-most x-position of the drawing area. */
4382 4420
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; \
4390 face_id = (ROW)->glyphs[AREA][START].face_id; \ 4428 face_id = (ROW)->glyphs[AREA][START].face_id; \
4391 \ 4429 \
6129 struct window *w; 6167 struct window *w;
6130 int x, y; 6168 int x, y;
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. */
6138 for (i = 0; i < w->current_matrix->nrows; ++i) 6176 for (i = 0; i < w->current_matrix->nrows; ++i)
6139 { 6177 {
7883 XawScrollbarSetThumb (widget, top, shown); 7921 XawScrollbarSetThumb (widget, top, shown);
7884 else 7922 else
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)
7892 { 7930 {
7893 /* Xaw3d stupidly ignores resize requests while dragging 7931 /* Xaw3d stupidly ignores resize requests while dragging
10965 struct frame *f; 11003 struct frame *f;
10966 char *fontsetname; 11004 char *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;
10974 11011
10975 if (f->output_data.x->fontset == fontset) 11012 if (f->output_data.x->fontset == fontset)
11676 if (input_polling_used ()) 11713 if (input_polling_used ())
11677 { 11714 {
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 ();
11684 poll_suppress_count = old_poll_suppress_count; 11722 poll_suppress_count = old_poll_suppress_count;
11685 } 11723 }
11907 if (f->output_data.x->widget) 11945 if (f->output_data.x->widget)
11908 XtDestroyWidget (f->output_data.x->widget); 11946 XtDestroyWidget (f->output_data.x->widget);
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 }
11915 11968
11916 if (f->output_data.x->saved_menu_event) 11969 if (f->output_data.x->saved_menu_event)
12224 try_XLoadQueryFont = 1; 12277 try_XLoadQueryFont = 1;
12225 12278
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.
12233 The cache is an alist of the form: 12286 The cache is an alist of the form:
12234 (((PATTERN . MAXNAMES) (FONTNAME . WIDTH) ...) ...) 12287 (((PATTERN . MAXNAMES) (FONTNAME . WIDTH) ...) ...)