2000-11-18 Miles Bader * xterm.h (struct x_output): Add scroll_bar_top_shadow_pixel and scroll_bar_bottom_shadow_pixel fields. * xterm.c (x_create_toolkit_scroll_bar): Try to allocate colors for the shadows, and tell the toolkit about them if we succeed. (x_destroy_window) [USE_TOOLKIT_SCROLL_BARS]: Free scroll-bar shadow colors. * xfns.c (x_set_scroll_bar_background) [USE_TOOLKIT_SCROLL_BARS]: Free scroll-bar shadow colors when the background color changes. (Fx_create_frame, x_create_tip_frame) [USE_TOOLKIT_SCROLL_BARS]: Initialize scroll-bar shadow-color fields. diff src/xterm.h.~1.109.~ src/xterm.h --- src/xterm.h.~1.109.~ Thu Oct 19 20:01:08 2000 +++ src/xterm.h Sat Nov 18 21:56:52 2000 @@ -481,6 +481,11 @@ bars). */ unsigned long scroll_bar_background_pixel; + /* Top and bottom shadow colors for 3d toolkit scrollbars. -1 means + let the scroll compute them itself. */ + unsigned long scroll_bar_top_shadow_pixel; + unsigned long scroll_bar_bottom_shadow_pixel; + /* Descriptor for the cursor in use for this window. */ Cursor text_cursor; Cursor nontext_cursor; diff -u src/xterm.c.~1.558.~ src/xterm.c --- src/xterm.c.~1.558.~ Tue Nov 14 19:56:04 2000 +++ src/xterm.c Sat Nov 18 23:15:22 2000 @@ -8063,7 +8063,6 @@ XtSetArg (av[ac], XtNorientation, XtorientVertical); ++ac; /* For smoother scrolling with Xaw3d -sm */ /* XtSetArg (av[ac], XtNpickTop, True); ++ac; */ - /* XtSetArg (av[ac], XtNbeNiceToColormap, True); ++ac; */ pixel = f->output_data.x->scroll_bar_foreground_pixel; if (pixel != -1) @@ -8078,7 +8077,61 @@ XtSetArg (av[ac], XtNbackground, pixel); ++ac; } - + + /* Top/bottom shadow colors. */ + + /* Allocate them, if necessary. */ + if (f->output_data.x->scroll_bar_top_shadow_pixel == -1) + { + pixel = f->output_data.x->scroll_bar_background_pixel; + if (!x_alloc_lighter_color (f, FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), + &pixel, 1.2, 0x8000)) + pixel = -1; + f->output_data.x->scroll_bar_top_shadow_pixel = pixel; + } + if (f->output_data.x->scroll_bar_bottom_shadow_pixel == -1) + { + pixel = f->output_data.x->scroll_bar_background_pixel; + if (!x_alloc_lighter_color (f, FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), + &pixel, 0.6, 0x4000)) + pixel = -1; + f->output_data.x->scroll_bar_bottom_shadow_pixel = pixel; + } + + /* Tell the toolkit about them. */ + if (f->output_data.x->scroll_bar_top_shadow_pixel == -1 + || f->output_data.x->scroll_bar_bottom_shadow_pixel == -1) + /* We tried to allocate a color for the top/bottom shadow, and + failed, so tell Xaw3d to use dithering instead. */ + { + XtSetArg (av[ac], XtNbeNiceToColormap, True); + ++ac; + } + else + /* Tell what colors Xaw3d should use for the top/bottom shadow, to + be more consistent with other emacs 3d colors, and since Xaw3d is + not good at dealing with allocation failure. */ + { + /* This tells Xaw3d to use real colors instead of dithering for + the shadows. */ + XtSetArg (av[ac], XtNbeNiceToColormap, False); + ++ac; + + /* Specify the colors. */ + pixel = f->output_data.x->scroll_bar_top_shadow_pixel; + if (pixel != -1) + { + XtSetArg (av[ac], "topShadowPixel", pixel); + ++ac; + } + pixel = f->output_data.x->scroll_bar_bottom_shadow_pixel; + if (pixel != -1) + { + XtSetArg (av[ac], "bottomShadowPixel", pixel); + ++ac; + } + } + widget = XtCreateWidget (scroll_bar_name, scrollbarWidgetClass, f->output_data.x->edit_widget, av, ac); @@ -12386,6 +12439,13 @@ 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); +#ifdef USE_TOOLKIT_SCROLL_BARS + /* Scrollbar shadow colors. */ + if (f->output_data.x->scroll_bar_top_shadow_pixel != -1) + unload_color (f, f->output_data.x->scroll_bar_top_shadow_pixel); + 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) unload_color (f, f->output_data.x->white_relief.pixel); if (f->output_data.x->black_relief.allocated_p) diff -u src/xfns.c.~1.440.~ src/xfns.c --- src/xfns.c.~1.440.~ Tue Nov 7 20:15:49 2000 +++ src/xfns.c Sat Nov 18 22:54:06 2000 @@ -2102,6 +2102,20 @@ if (f->output_data.x->scroll_bar_background_pixel != -1) unload_color (f, f->output_data.x->scroll_bar_background_pixel); +#ifdef USE_TOOLKIT_SCROLL_BARS + /* Scrollbar shadow colors. */ + if (f->output_data.x->scroll_bar_top_shadow_pixel != -1) + { + unload_color (f, f->output_data.x->scroll_bar_top_shadow_pixel); + f->output_data.x->scroll_bar_top_shadow_pixel = -1; + } + if (f->output_data.x->scroll_bar_bottom_shadow_pixel != -1) + { + unload_color (f, f->output_data.x->scroll_bar_bottom_shadow_pixel); + f->output_data.x->scroll_bar_bottom_shadow_pixel = -1; + } +#endif /* USE_TOOLKIT_SCROLL_BARS */ + f->output_data.x->scroll_bar_background_pixel = pixel; if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f)) { @@ -4034,6 +4048,10 @@ f->output_data.x->fontset = -1; f->output_data.x->scroll_bar_foreground_pixel = -1; f->output_data.x->scroll_bar_background_pixel = -1; +#ifdef USE_TOOLKIT_SCROLL_BARS + 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->icon_name = x_get_arg (dpyinfo, parms, Qicon_name, "iconName", "Title", @@ -10272,6 +10290,10 @@ f->output_data.x->fontset = -1; f->output_data.x->scroll_bar_foreground_pixel = -1; f->output_data.x->scroll_bar_background_pixel = -1; +#ifdef USE_TOOLKIT_SCROLL_BARS + 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->icon_name = Qnil; FRAME_X_DISPLAY_INFO (f) = dpyinfo; #ifdef MULTI_KBOARD