comparison src/xterm.c @ 25529:7ae6423812ae

(XTset_vertical_scroll_bar): Block input when clearing under newly created scroll bar. (expose_window): If window is not yet fully initialized, do nothing. This can happen when toolkit scroll bars are used and a window is split. Reconfiguring the scroll bars will generate an expose for a newly created window. (x_alloc_nearest_color_for_widget) [USE_X_TOOLKIT]: New. Allocate color for lwlib widgets. (x_alloc_nearest_color): Change parameter list include the frame on which to allocate colors. Gamma-correct colors. (x_alloc_lighter_color): Call x_alloc_lighter_color with new parameter list.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 03 Sep 1999 18:50:00 +0000
parents 8d013f20532c
children be975dcf4a0c
comparison
equal deleted inserted replaced
25528:b5dd1bafd001 25529:7ae6423812ae
2940 } 2940 }
2941 } 2941 }
2942 } 2942 }
2943 2943
2944 2944
2945 #ifdef USE_X_TOOLKIT
2946
2947 /* Allocate the color COLOR->pixel on the screen and display of
2948 widget WIDGET in colormap CMAP. If an exact match cannot be
2949 allocated, try the nearest color available. Value is non-zero
2950 if successful. This is called from lwlib. */
2951
2952 int
2953 x_alloc_nearest_color_for_widget (widget, cmap, color)
2954 Widget widget;
2955 Colormap cmap;
2956 XColor *color;
2957 {
2958 struct frame *f;
2959 struct x_display_info *dpyinfo;
2960 Lisp_Object tail, frame;
2961 Widget parent;
2962
2963 dpyinfo = x_display_info_for_display (XtDisplay (widget));
2964
2965 /* Find the top-level shell of the widget. Note that this function
2966 can be called when the widget is not yet realized, so XtWindow
2967 (widget) == 0. That's the reason we can't simply use
2968 x_any_window_to_frame. */
2969 while (!XtIsTopLevelShell (widget))
2970 widget = XtParent (widget);
2971
2972 /* Look for a frame with that top-level widget. Allocate the color
2973 on that frame to get the right gamma correction value. */
2974 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
2975 if (GC_FRAMEP (XCAR (tail))
2976 && (f = XFRAME (XCAR (tail)),
2977 (f->output_data.nothing != 1
2978 && FRAME_X_DISPLAY_INFO (f) == dpyinfo))
2979 && f->output_data.x->widget == widget)
2980 return x_alloc_nearest_color (f, cmap, color);
2981
2982 abort ();
2983 }
2984
2985 #endif /* USE_X_TOOLKIT */
2986
2987
2945 /* Allocate the color COLOR->pixel on SCREEN of DISPLAY, colormap 2988 /* Allocate the color COLOR->pixel on SCREEN of DISPLAY, colormap
2946 CMAP. If an exact match can't be allocated, try the nearest color 2989 CMAP. If an exact match can't be allocated, try the nearest color
2947 available. Value is non-zero if successful. Set *COLOR to the 2990 available. Value is non-zero if successful. Set *COLOR to the
2948 color allocated. */ 2991 color allocated. */
2949 2992
2950 int 2993 int
2951 x_alloc_nearest_color (display, screen, cmap, color) 2994 x_alloc_nearest_color (f, cmap, color)
2952 Display *display; 2995 struct frame *f;
2953 Screen *screen;
2954 Colormap cmap; 2996 Colormap cmap;
2955 XColor *color; 2997 XColor *color;
2956 { 2998 {
2957 int rc = XAllocColor (display, cmap, color); 2999 Display *display = FRAME_X_DISPLAY (f);
3000 Screen *screen = FRAME_X_SCREEN (f);
3001 int rc;
3002
3003 gamma_correct (f, color);
3004 rc = XAllocColor (display, cmap, color);
2958 if (rc == 0) 3005 if (rc == 0)
2959 { 3006 {
2960 /* If we got to this point, the colormap is full, so we're going 3007 /* If we got to this point, the colormap is full, so we're going
2961 to try to get the next closest color. The algorithm used is 3008 to try to get the next closest color. The algorithm used is
2962 a least-squares matching, which is what X uses for closest 3009 a least-squares matching, which is what X uses for closest
3022 new.red = min (0xffff, factor * color.red); 3069 new.red = min (0xffff, factor * color.red);
3023 new.green = min (0xffff, factor * color.green); 3070 new.green = min (0xffff, factor * color.green);
3024 new.blue = min (0xffff, factor * color.blue); 3071 new.blue = min (0xffff, factor * color.blue);
3025 3072
3026 /* Try to allocate the color. */ 3073 /* Try to allocate the color. */
3027 success_p = x_alloc_nearest_color (display, FRAME_X_SCREEN (f), cmap, &new); 3074 success_p = x_alloc_nearest_color (f, cmap, &new);
3028 if (success_p) 3075 if (success_p)
3029 { 3076 {
3030 if (new.pixel == *pixel) 3077 if (new.pixel == *pixel)
3031 { 3078 {
3032 /* If we end up with the same color as before, try adding 3079 /* If we end up with the same color as before, try adding
3042 XFreeColors (display, cmap, &new.pixel, 1, 0); 3089 XFreeColors (display, cmap, &new.pixel, 1, 0);
3043 3090
3044 new.red = min (0xffff, delta + color.red); 3091 new.red = min (0xffff, delta + color.red);
3045 new.green = min (0xffff, delta + color.green); 3092 new.green = min (0xffff, delta + color.green);
3046 new.blue = min (0xffff, delta + color.blue); 3093 new.blue = min (0xffff, delta + color.blue);
3047 success_p = x_alloc_nearest_color (display, FRAME_X_SCREEN (f), 3094 success_p = x_alloc_nearest_color (f, cmap, &new);
3048 cmap, &new);
3049 } 3095 }
3050 else 3096 else
3051 success_p = 1; 3097 success_p = 1;
3052 *pixel = new.pixel; 3098 *pixel = new.pixel;
3053 } 3099 }
5273 struct glyph_row *row; 5319 struct glyph_row *row;
5274 int y; 5320 int y;
5275 int yb = window_text_bottom_y (w); 5321 int yb = window_text_bottom_y (w);
5276 int cursor_cleared_p; 5322 int cursor_cleared_p;
5277 5323
5324 /* If window is not yet fully initialized, do nothing. This can
5325 happen when toolkit scroll bars are used and a window is split.
5326 Reconfiguring the scroll bar will generate an expose for a newly
5327 created window. */
5328 if (w->current_matrix == NULL)
5329 return;
5330
5278 TRACE ((stderr, "expose_window (%d, %d, %d, %d)\n", 5331 TRACE ((stderr, "expose_window (%d, %d, %d, %d)\n",
5279 r->x, r->y, r->width, r->height)); 5332 r->x, r->y, r->width, r->height));
5280 5333
5281 /* Convert to window coordinates. */ 5334 /* Convert to window coordinates. */
5282 r->x = FRAME_TO_WINDOW_PIXEL_X (w, r->x); 5335 r->x = FRAME_TO_WINDOW_PIXEL_X (w, r->x);
7908 #endif 7961 #endif
7909 7962
7910 /* Does the scroll bar exist yet? */ 7963 /* Does the scroll bar exist yet? */
7911 if (NILP (w->vertical_scroll_bar)) 7964 if (NILP (w->vertical_scroll_bar))
7912 { 7965 {
7966 BLOCK_INPUT;
7913 XClearArea (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 7967 XClearArea (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
7914 left, top, width, height, False); 7968 left, top, width, height, False);
7969 UNBLOCK_INPUT;
7915 bar = x_scroll_bar_create (w, top, sb_left, sb_width, height); 7970 bar = x_scroll_bar_create (w, top, sb_left, sb_width, height);
7916 } 7971 }
7917 else 7972 else
7918 { 7973 {
7919 /* It may just need to be moved and resized. */ 7974 /* It may just need to be moved and resized. */