Index: fvwm/colorset.c =================================================================== RCS file: /home/cvs/fvwm/fvwm/fvwm/colorset.c,v retrieving revision 1.45 diff -u -r1.45 colorset.c --- fvwm/colorset.c 25 Aug 2003 06:47:08 -0000 1.45 +++ fvwm/colorset.c 31 Aug 2003 19:48:14 -0000 @@ -159,7 +159,9 @@ "IconTint", "NoIconTint", "IconAlpha", - + + "Translucent", + "NoTranslucent", NULL }; @@ -616,6 +618,7 @@ char *fg_tint = NULL; char *bg_tint = NULL; char *icon_tint = NULL; + char *translucent_tint = NULL; Bool have_pixels_changed = False; Bool has_icon_pixels_changed = False; Bool has_fg_changed = False; @@ -628,6 +631,7 @@ Bool has_fg_tint_changed = False; Bool has_bg_tint_changed = False; Bool has_icon_tint_changed = False; + Bool has_translucent_tint_changed = False; Bool has_pixmap_changed = False; Bool has_shape_changed = False; Bool has_image_alpha_changed = False; @@ -754,6 +758,10 @@ case 21: /* Plain */ has_pixmap_changed = True; free_colorset_background(cs, True); + cs->is_translucent = False; + cs->translucent_tint_percent = 0; + cs->color_flags &= ~TRANSLUCENT_TINT_SUPPLIED; + has_translucent_tint_changed = True; break; case 22: /* NoShape */ has_shape_changed = True; @@ -920,6 +928,24 @@ cs->icon_alpha_percent = tmp; } break; + case 42: /* Translucent */ + cs->is_translucent = True; + parse_simple_tint( + cs, args, &translucent_tint, + TRANSLUCENT_TINT_SUPPLIED, + &has_translucent_tint_changed, &percent, + "Translucent"); + if (has_translucent_tint_changed) + { + cs->translucent_tint_percent = percent; + } + break; + case 43: /* NoTranslucent */ + cs->is_translucent = False; + cs->translucent_tint_percent = 0; + cs->color_flags &= ~TRANSLUCENT_TINT_SUPPLIED; + has_translucent_tint_changed = True; + break; default: /* test for ?Gradient */ if (option[0] && StrEquals(&option[1], "Gradient")) @@ -1602,6 +1628,27 @@ } } + /* + * ---------- change the translucent tint colour ---------- + */ + if (has_translucent_tint_changed) + { + /* user specified colour */ + if (translucent_tint != NULL) + { + PictureFreeColors( + dpy, Pcmap, &cs->translucent_tint, 1, 0, True); + cs->translucent_tint = GetColor(translucent_tint); + } + else + { + /* default */ + PictureFreeColors( + dpy, Pcmap, &cs->translucent_tint, 1, 0, True); + cs->translucent_tint = GetColor(black); + } + } + /* * ---------- send new colorset to fvwm and clean up ---------- */ @@ -1698,6 +1745,7 @@ ncs->fgsh = GetColor(white); ncs->tint = GetColor(black); ncs->icon_tint = GetColor(black); + ncs->translucent_tint = GetColor(black); ncs->pixmap = XCreatePixmapFromBitmapData( dpy, Scr.NoFocusWin, &g_bits[4 * (nColorsets % 3)], 4, 4, @@ -1715,6 +1763,7 @@ ncs->fgsh = GetForeShadow(ncs->fg, ncs->bg); ncs->tint = GetColor(black); ncs->icon_tint = GetColor(black); + ncs->translucent_tint = GetColor(black); } ncs->fg_tint = ncs->bg_tint = GetColor(black); /* set flags for fg contrast, bg average */ @@ -1726,6 +1775,7 @@ ncs->icon_alpha_percent = 100; ncs->tint_percent = 0; ncs->icon_tint_percent = 0; + ncs->translucent_tint_percent = 0; ncs->fg_tint_percent = ncs->bg_tint_percent = 0; ncs->dither = (PictureDitherByDefault())? True:False; nColorsets++; Index: fvwm/menus.c =================================================================== RCS file: /home/cvs/fvwm/fvwm/fvwm/menus.c,v retrieving revision 1.372 diff -u -r1.372 menus.c --- fvwm/menus.c 28 Aug 2003 20:26:13 -0000 1.372 +++ fvwm/menus.c 31 Aug 2003 19:48:39 -0000 @@ -65,6 +65,11 @@ /* ---------------------------- local macros ------------------------------- */ +#define MENU_IS_TRANSLUCENT(mr,cs) \ + (!MR_IS_TEAR_OFF_MENU(mr) && CSET_IS_TRANSLUCENT(cs)) +#define MENU_IS_TRANSPARENT(mr,cs) \ + (MENU_IS_TRANSLUCENT(mr,cs) || CSET_IS_TRANSPARENT(cs)) + /* ---------------------------- imports ------------------------------------ */ /* This external is safe. It's written only during startup. */ @@ -405,7 +410,7 @@ /* move it back */ if (ST_HAS_MENU_CSET(MR_STYLE(mr)) && - CSET_IS_TRANSPARENT(ST_CSET_MENU(MR_STYLE(mr)))) + MENU_IS_TRANSPARENT(mr,ST_CSET_MENU(MR_STYLE(mr)))) { transparent_bg = True; get_menu_repaint_transparent_parameters( @@ -2419,6 +2424,7 @@ /* Doh. Use the standard display instead. */ MR_CREATE_DPY(mr) = dpy; } + MR_IS_TEAR_OFF_MENU(mr) = 1; } else { @@ -3202,7 +3208,38 @@ } MR_IS_PAINTED(mr) = 1; /* paint the menu background */ - if (ms && ST_HAS_MENU_CSET(ms)) + if (ms && ST_HAS_MENU_CSET(ms) && + MENU_IS_TRANSLUCENT(mr,ST_CSET_MENU(ms))) + { + Pixmap trans = None; + FvwmRenderAttributes fra; + colorset_t *colorset = &Colorset[ST_CSET_MENU(ms)]; + + fra.mask = 0; + if (colorset->translucent_tint_percent > 0) + { + fra.mask = FRAM_HAVE_TINT; + fra.tint = colorset->translucent_tint; + fra.tint_percent = colorset->translucent_tint_percent; + } + if (MR_IS_BACKGROUND_SET(mr) == False) + { + trans = PGraphicsCreateTranslucent( + dpy, MR_WINDOW(mr), &fra, + BACK_GC(ST_MENU_INACTIVE_GCS(ms)), + MR_X(mr), MR_Y(mr), MR_WIDTH(mr), MR_HEIGHT(mr)); + XMapRaised(dpy, MR_WINDOW(mr)); + if (trans != None) + { + XSetWindowBackgroundPixmap( + dpy, MR_WINDOW(mr), trans); + MR_IS_BACKGROUND_SET(mr) = True; + clear_expose_menu_area(MR_WINDOW(mr), pevent); + XFreePixmap(dpy, trans); + } + } + } + else if (ms && ST_HAS_MENU_CSET(ms)) { if (MR_IS_BACKGROUND_SET(mr) == False) { @@ -3996,8 +4033,8 @@ } MR_XANIMATION(parent_menu) += end_x - prev_x; if (ST_HAS_MENU_CSET(MR_STYLE(parent_menu)) && - CSET_IS_TRANSPARENT( - ST_CSET_MENU(MR_STYLE(mr)))) + MENU_IS_TRANSPARENT( + mr,ST_CSET_MENU(MR_STYLE(mr)))) { transparent_bg = True; get_menu_repaint_transparent_parameters( @@ -4172,10 +4209,22 @@ */ XMoveWindow(dpy, MR_WINDOW(mr), x, y); + MR_X(mr) = x; + MR_Y(mr) = y; XSelectInput(dpy, MR_WINDOW(mr), event_mask); - XMapRaised(dpy, MR_WINDOW(mr)); - if (popdown_window) - XUnmapWindow(dpy, popdown_window); + if (MR_STYLE(mr) && ST_HAS_MENU_CSET(MR_STYLE(mr)) && + MENU_IS_TRANSLUCENT(mr,ST_CSET_MENU(MR_STYLE(mr)))) + { + if (popdown_window) + XUnmapWindow(dpy, popdown_window); + paint_menu(mr, NULL, fw); + } + else + { + XMapRaised(dpy, MR_WINDOW(mr)); + if (popdown_window) + XUnmapWindow(dpy, popdown_window); + } XFlush(dpy); MR_MAPPED_COPIES(mr)++; MST_USAGE_COUNT(mr)++; @@ -6589,15 +6638,45 @@ { last = True; } - if (!last && CSET_IS_TRANSPARENT_PR_TINT(ST_CSET_MENU(ms))) + if (!last && + (CSET_IS_TRANSPARENT_PR_TINT(ST_CSET_MENU(ms)) || + MENU_IS_TRANSLUCENT(mr,ST_CSET_MENU(ms)))) { /* too slow ... */ return; } - SetWindowBackground( - dpy, MR_WINDOW(mr), MR_WIDTH(mr), MR_HEIGHT(mr), - &Colorset[ST_CSET_MENU(ms)], Pdepth, - FORE_GC(MST_MENU_INACTIVE_GCS(mr)), False); + if (MENU_IS_TRANSLUCENT(mr,ST_CSET_MENU(ms))) + { + Pixmap trans; + FvwmRenderAttributes fra; + colorset_t *colorset = &Colorset[ST_CSET_MENU(ms)]; + + fra.mask = 0; + if (colorset->translucent_tint_percent > 0) + { + fra.mask = FRAM_HAVE_TINT; + fra.tint = colorset->translucent_tint; + fra.tint_percent = colorset->translucent_tint_percent; + } + XUnmapWindow(dpy, MR_WINDOW(mr)); + MR_X(mr) = x; + MR_Y(mr) = y; + trans = PGraphicsCreateTranslucent( + dpy, MR_WINDOW(mr), &fra, + BACK_GC(ST_MENU_INACTIVE_GCS(ms)), + MR_X(mr), MR_Y(mr), MR_WIDTH(mr), MR_HEIGHT(mr)); + XMapRaised(dpy, MR_WINDOW(mr)); + XSetWindowBackgroundPixmap( + dpy, MR_WINDOW(mr), trans); + XFreePixmap(dpy, trans); + } + else + { + SetWindowBackground( + dpy, MR_WINDOW(mr), MR_WIDTH(mr), MR_HEIGHT(mr), + &Colorset[ST_CSET_MENU(ms)], Pdepth, + FORE_GC(MST_MENU_INACTIVE_GCS(mr)), False); + } /* redraw the background of non active item */ for (mi = MR_FIRST_ITEM(mr); mi != NULL; mi = MI_NEXT_ITEM(mi)) { @@ -7213,7 +7292,6 @@ } } - for (t = Scr.FvwmRoot.next; t != NULL; t = t->next) { MenuRoot *mr = NULL; @@ -7230,10 +7308,12 @@ SetWindowBackground( dpy, MR_WINDOW(mr), MR_WIDTH(mr), MR_HEIGHT(mr), - &Colorset[ST_CSET_MENU(ms)], - Pdepth, + &Colorset[ST_CSET_MENU(ms)], Pdepth, FORE_GC(MST_MENU_INACTIVE_GCS(mr)), - True); + False); + XClearArea( + dpy, MR_WINDOW(mr), 0, 0, MR_WIDTH(mr), + MR_HEIGHT(mr), True); } else if ((ST_HAS_ACTIVE_CSET(ms) && ST_CSET_ACTIVE(ms) == cset) || Index: fvwm/menus.h =================================================================== RCS file: /home/cvs/fvwm/fvwm/fvwm/menus.h,v retrieving revision 1.103 diff -u -r1.103 menus.h --- fvwm/menus.h 28 Aug 2003 20:26:14 -0000 1.103 +++ fvwm/menus.h 31 Aug 2003 19:48:41 -0000 @@ -141,6 +141,9 @@ MenuItem *submenu_item; /* x distance window was moved by animation */ int xanimation; + /* x,y XMapRaise */ + int x; + int y; /* dynamic temp flags */ struct { @@ -182,6 +185,8 @@ #define MR_SELECTED_ITEM(m) ((m)->d->selected_item) #define MR_SUBMENU_ITEM(m) ((m)->d->submenu_item) #define MR_XANIMATION(m) ((m)->d->xanimation) +#define MR_X(m) ((m)->d->x) +#define MR_Y(m) ((m)->d->y) #define MR_STORED_ITEM(m) ((m)->d->stored_item) #define MR_STORED_PIXELS(m) ((m)->d->stored_pixels) /* flags */ Index: libs/Colorset.h =================================================================== RCS file: /home/cvs/fvwm/fvwm/libs/Colorset.h,v retrieving revision 1.36 diff -u -r1.36 Colorset.h --- libs/Colorset.h 29 Jun 2003 19:53:23 -0000 1.36 +++ libs/Colorset.h 31 Aug 2003 19:48:43 -0000 @@ -51,6 +51,10 @@ Bool dither; Bool allows_buffered_transparency; Bool is_maybe_root_transparent; + /* only use by fvwm menu (non tear-off) */ + Bool is_translucent; + Pixel translucent_tint; + unsigned int translucent_tint_percent : 7; #endif } colorset_t; @@ -78,6 +82,7 @@ #define FG_TINT_SUPPLIED 0x100 #define BG_TINT_SUPPLIED 0x200 #define ICON_TINT_SUPPLIED 0x400 +#define TRANSLUCENT_TINT_SUPPLIED 0x800 #endif /* colorsets are stored as an array of structs to permit fast dereferencing */ @@ -152,6 +157,11 @@ #define CSETS_IS_TRANSPARENT_PR_TINT(cset) \ (cset >= 0 && cset->pixmap == ParentRelative && \ cset->tint_percent > 0) + +#define CSET_IS_TRANSLUCENT(cset) \ + (cset >= 0 && Colorset[cset].is_translucent) +#define CSETS_IS_TRANSLUCENT(cset) \ + (cset && cset->is_translucent) #ifndef FVWM_COLORSET_PRIVATE /* Create n new colorsets, fvwm/colorset.c does its own thing (different size) Index: libs/PictureGraphics.c =================================================================== RCS file: /home/cvs/fvwm/fvwm/libs/PictureGraphics.c,v retrieving revision 1.25 diff -u -r1.25 PictureGraphics.c --- libs/PictureGraphics.c 27 Aug 2003 13:37:04 -0000 1.25 +++ libs/PictureGraphics.c 31 Aug 2003 19:48:50 -0000 @@ -1338,7 +1338,7 @@ } } -#if 0 /* humm... maybe usefull one day with menus */ +#if 1 /* humm... maybe usefull one day with menus */ Pixmap PGraphicsCreateTranslucent( Display *dpy, Window win, FvwmRenderAttributes *fra, GC gc, int x, int y, int width, int height) Index: libs/PictureGraphics.h =================================================================== RCS file: /home/cvs/fvwm/fvwm/libs/PictureGraphics.h,v retrieving revision 1.12 diff -u -r1.12 PictureGraphics.h --- libs/PictureGraphics.h 29 Jun 2003 19:53:24 -0000 1.12 +++ libs/PictureGraphics.h 31 Aug 2003 19:48:50 -0000 @@ -122,7 +122,9 @@ Display *dpy, Window win, Pixel tint, int tint_percent, Drawable dest, Bool dest_is_a_window, GC gc, GC mono_gc, GC alpha_gc, int dest_x, int dest_y, int dest_w, int dest_h); - +Pixmap PGraphicsCreateTranslucent( + Display *dpy, Window win, FvwmRenderAttributes *fra, GC gc, + int x, int y, int width, int height); /* never used ! */ Pixmap PGraphicsCreateDitherPixmap( Display *dpy, Window win, Drawable src, Pixmap mask, int depth, GC gc,