changeset 31341:1c5d68acbded

(x_alloc_lighter_color_for_widget): New extern declaration. (make_shadow_gcs) [emacs]: Use x_alloc_lighter_color_for_widget to do shadow calculation. (make_shadow_gcs): Remove code that tests whether the top shadow is dimmer than the bottom shadow--it shouldn't ever happen.
author Miles Bader <miles@gnu.org>
date Sun, 03 Sep 2000 11:37:45 +0000
parents 6b2ed557e09c
children 8d5c06c62809
files lwlib/xlwmenu.c
diffstat 1 files changed, 14 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/lwlib/xlwmenu.c	Sun Sep 03 11:33:29 2000 +0000
+++ b/lwlib/xlwmenu.c	Sun Sep 03 11:37:45 2000 +0000
@@ -46,6 +46,9 @@
 
 /* Defined in xterm.c.  */
 extern int x_alloc_nearest_color_for_widget __P ((Widget, Colormap, XColor*));
+extern int x_alloc_lighter_color_for_widget __P ((Widget, Display*, Colormap,
+						  unsigned long *,
+						  double, int));
 extern int x_catch_errors __P ((Display*));
 extern int x_uncatch_errors __P ((Display*, int));
 extern int x_had_errors_p __P ((Display*));
@@ -1476,14 +1479,16 @@
       mw->menu.top_shadow_color == mw->menu.foreground)
     {
       topc.pixel = mw->core.background_pixel;
+#ifdef emacs
+      if (x_alloc_lighter_color_for_widget ((Widget) mw, dpy, cmap,
+					    &topc.pixel,
+					    1.2, 0x8000))
+#else
       XQueryColor (dpy, cmap, &topc);
       /* don't overflow/wrap! */
       topc.red   = MINL (65535, topc.red   * 1.2);
       topc.green = MINL (65535, topc.green * 1.2);
       topc.blue  = MINL (65535, topc.blue  * 1.2);
-#ifdef emacs
-      if (x_alloc_nearest_color_for_widget ((Widget) mw, cmap, &topc))
-#else
       if (XAllocColor (dpy, cmap, &topc))
 #endif
 	{
@@ -1496,13 +1501,15 @@
       mw->menu.bottom_shadow_color == mw->core.background_pixel)
     {
       botc.pixel = mw->core.background_pixel;
+#ifdef emacs
+      if (x_alloc_lighter_color_for_widget ((Widget) mw, dpy, cmap,
+					    &botc.pixel,
+					    0.6, 0x4000))
+#else
       XQueryColor (dpy, cmap, &botc);
       botc.red   *= 0.6;
       botc.green *= 0.6;
       botc.blue  *= 0.6;
-#ifdef emacs
-      if (x_alloc_nearest_color_for_widget ((Widget) mw, cmap, &botc))
-#else
       if (XAllocColor (dpy, cmap, &botc))
 #endif
 	{
@@ -1514,15 +1521,7 @@
 
   if (top_frobbed && bottom_frobbed)
     {
-      int top_avg = ((topc.red / 3) + (topc.green / 3) + (topc.blue / 3));
-      int bot_avg = ((botc.red / 3) + (botc.green / 3) + (botc.blue / 3));
-      if (bot_avg > top_avg)
-	{
-	  Pixel tmp = mw->menu.top_shadow_color;
-	  mw->menu.top_shadow_color = mw->menu.bottom_shadow_color;
-	  mw->menu.bottom_shadow_color = tmp;
-	}
-      else if (topc.pixel == botc.pixel)
+      if (topc.pixel == botc.pixel)
 	{
 	  if (botc.pixel == mw->menu.foreground)
 	    {