summaryrefslogtreecommitdiff
path: root/lwlib
diff options
context:
space:
mode:
authorGerd Moellmann <gerd@gnu.org>2000-06-16 18:34:17 +0000
committerGerd Moellmann <gerd@gnu.org>2000-06-16 18:34:17 +0000
commitbba2a92393b328310ebd23694f66f0c96fb39a4f (patch)
tree9d747028c43e2bbd563e15dd324d932f32285e55 /lwlib
parent457d47f892c3254256e1b7c7ad5ff0c45fbd8ba8 (diff)
downloademacs-bba2a92393b328310ebd23694f66f0c96fb39a4f.tar.gz
(make_shadow_gcs): Set free_top_shadow_color_p
and free_top_shadow_color_p flags in the menu widget if top and bottom shadow colors must be freed. (release_shadow_gcs): Free colors only if they must be freed.
Diffstat (limited to 'lwlib')
-rw-r--r--lwlib/xlwmenu.c67
1 files changed, 46 insertions, 21 deletions
diff --git a/lwlib/xlwmenu.c b/lwlib/xlwmenu.c
index 034875f53ca..3a1a490710b 100644
--- a/lwlib/xlwmenu.c
+++ b/lwlib/xlwmenu.c
@@ -1444,10 +1444,18 @@ make_shadow_gcs (mw)
XColor topc, botc;
int top_frobbed = 0, bottom_frobbed = 0;
+ mw->menu.free_top_shadow_color_p = 0;
+ mw->menu.free_bottom_shadow_color_p = 0;
+
if (mw->menu.top_shadow_color == -1)
mw->menu.top_shadow_color = mw->core.background_pixel;
+ else
+ mw->menu.top_shadow_color = mw->menu.top_shadow_color;
+
if (mw->menu.bottom_shadow_color == -1)
mw->menu.bottom_shadow_color = mw->menu.foreground;
+ else
+ mw->menu.bottom_shadow_color = mw->menu.bottom_shadow_color;
if (mw->menu.top_shadow_color == mw->core.background_pixel ||
mw->menu.top_shadow_color == mw->menu.foreground)
@@ -1465,6 +1473,7 @@ make_shadow_gcs (mw)
#endif
{
mw->menu.top_shadow_color = topc.pixel;
+ mw->menu.free_top_shadow_color_p = 1;
top_frobbed = 1;
}
}
@@ -1483,6 +1492,7 @@ make_shadow_gcs (mw)
#endif
{
mw->menu.bottom_shadow_color = botc.pixel;
+ mw->menu.free_bottom_shadow_color_p = 1;
bottom_frobbed = 1;
}
}
@@ -1501,17 +1511,23 @@ make_shadow_gcs (mw)
{
if (botc.pixel == mw->menu.foreground)
{
- x_free_dpy_colors (dpy, screen, cmap,
- &mw->menu.top_shadow_color, 1);
- mw->menu.top_shadow_color
- = x_copy_dpy_color (dpy, cmap, mw->core.background_pixel);
+ if (mw->menu.free_top_shadow_color_p)
+ {
+ x_free_dpy_colors (dpy, screen, cmap,
+ &mw->menu.top_shadow_color, 1);
+ mw->menu.free_top_shadow_color_p = 0;
+ }
+ mw->menu.top_shadow_color = mw->core.background_pixel;
}
else
{
- x_free_dpy_colors (dpy, screen, cmap,
- &mw->menu.bottom_shadow_color, 1);
- mw->menu.bottom_shadow_color
- = x_copy_dpy_color (dpy, cmap, mw->menu.foreground);
+ if (mw->menu.free_bottom_shadow_color_p)
+ {
+ x_free_dpy_colors (dpy, screen, cmap,
+ &mw->menu.bottom_shadow_color, 1);
+ mw->menu.free_bottom_shadow_color_p = 0;
+ }
+ mw->menu.bottom_shadow_color = mw->menu.foreground;
}
}
}
@@ -1520,20 +1536,24 @@ make_shadow_gcs (mw)
mw->menu.top_shadow_color == mw->core.background_pixel)
{
mw->menu.top_shadow_pixmap = mw->menu.gray_pixmap;
- if (top_frobbed)
- x_free_dpy_colors (dpy, screen, cmap, &mw->menu.top_shadow_color, 1);
- mw->menu.top_shadow_color = x_copy_dpy_color (dpy, cmap,
- mw->menu.foreground);
+ if (mw->menu.free_top_shadow_color_p)
+ {
+ x_free_dpy_colors (dpy, screen, cmap, &mw->menu.top_shadow_color, 1);
+ mw->menu.free_top_shadow_color_p = 0;
+ }
+ mw->menu.top_shadow_color = mw->menu.foreground;
}
if (!mw->menu.bottom_shadow_pixmap &&
mw->menu.bottom_shadow_color == mw->core.background_pixel)
{
mw->menu.bottom_shadow_pixmap = mw->menu.gray_pixmap;
- if (bottom_frobbed)
- x_free_dpy_colors (dpy, screen, cmap,
- &mw->menu.bottom_shadow_color, 1);
- mw->menu.bottom_shadow_color = x_copy_dpy_color (dpy, cmap,
- mw->menu.foreground);
+ if (mw->menu.free_bottom_shadow_color_p)
+ {
+ x_free_dpy_colors (dpy, screen, cmap,
+ &mw->menu.bottom_shadow_color, 1);
+ mw->menu.free_bottom_shadow_color_p = 0;
+ }
+ mw->menu.bottom_shadow_color = mw->menu.foreground;
}
xgcv.fill_style = FillStippled;
@@ -1557,10 +1577,15 @@ release_shadow_gcs (mw)
Screen *screen = XtScreen ((Widget) mw);
Colormap cmap = mw->core.colormap;
Pixel px[2];
-
- px[0] = mw->menu.top_shadow_color;
- px[1] = mw->menu.bottom_shadow_color;
- x_free_dpy_colors (dpy, screen, cmap, px, 2);
+ int i = 0;
+
+ if (mw->menu.free_top_shadow_color_p)
+ px[i++] = mw->menu.top_shadow_color;
+ if (mw->menu.free_bottom_shadow_color_p)
+ px[i++] = mw->menu.bottom_shadow_color;
+ if (i > 0)
+ x_free_dpy_colors (dpy, screen, cmap, px, i);
+
XtReleaseGC ((Widget) mw, mw->menu.shadow_top_gc);
XtReleaseGC ((Widget) mw, mw->menu.shadow_bottom_gc);
}