On Mon, Aug 25, 2003 at 09:00:32PM +0200, Dawid Kuroczko wrote:
> Hello. :-)
>
> I did manage to make pseudo-transparent menus, but now I'd like
> to make something more "real". What I'd like to do is to have
> something like there is in KDE.
>
> It should work like this:
> 1. user clicks thus calling a Menu.
> 2. current screen dump is taken (with all the windows, but
> without a menu just as yet).
> 3. this screen dump is made available to Menu as
> root background pixmap.
> 4. Menu is displayed with tinted real background.
>
> This way it's pretty easy to make an illusion of real
> transparency (and looks "l33t", as some may say).
>
> My question is, how to do it to, and make it good. I came up
> with a function which would call xwd, convert and fvwm-root
> and then call Menu. Which is slow (convert) and does set
> background instead of just making it "virtually" available
> to Menu...
>
>
Humm, ... in fact some code in fvwm was already there for this.
Apply the attached patch to the current cvs (really current)
or to the next snapshot and use the following config:
Colorset 5 Transparent, Tint black 50
MenuStyle * MenuColorset 5, PopupOffset 0 100, AnimationOff
and you get what you want :o)
However, I do not think that such patch will be applied before
fvwm-2.6.
Regards, Olivier
Index: fvwm/menus.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/menus.c,v
retrieving revision 1.371
diff -u -r1.371 menus.c
--- fvwm/menus.c 5 Jul 2003 01:37:47 -0000 1.371
+++ fvwm/menus.c 27 Aug 2003 13:04:23 -0000
@@ -3202,7 +3202,39 @@
}
MR_IS_PAINTED(mr) = 1;
/* paint the menu background */
- if (ms && ST_HAS_MENU_CSET(ms))
+ if (ms && ST_HAS_MENU_CSET(ms) &&
+ CSET_IS_TRANSPARENT_PR(ST_CSET_MENU(ms)) &&
+ !MR_IS_TEAR_OFF_MENU(mr))
+ {
+ Pixmap trans = None;
+ FvwmRenderAttributes fra;
+ colorset_t *colorset = &Colorset[ST_CSET_MENU(ms)];
+
+ fra.mask = 0;
+ if (colorset->tint_percent > 0)
+ {
+ fra.mask = FRAM_HAVE_TINT;
+ fra.tint = colorset->tint;
+ fra.tint_percent = colorset->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)
{
@@ -4172,10 +4204,23 @@
*/
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)) &&
+ CSET_IS_TRANSPARENT_PR(ST_CSET_MENU(MR_STYLE(mr))) &&
+ !MR_IS_TEAR_OFF_MENU(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)++;
Index: fvwm/menus.h
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/menus.h,v
retrieving revision 1.102
diff -u -r1.102 menus.h
--- fvwm/menus.h 29 Jun 2003 19:53:23 -0000 1.102
+++ fvwm/menus.h 27 Aug 2003 13:04:24 -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,7 +185,9 @@
#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/PictureGraphics.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/libs/PictureGraphics.c,v
retrieving revision 1.24
diff -u -r1.24 PictureGraphics.c
--- libs/PictureGraphics.c 27 Aug 2003 12:59:25 -0000 1.24
+++ libs/PictureGraphics.c 27 Aug 2003 13:04:36 -0000
@@ -1338,8 +1338,8 @@
}
}
-#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 27 Aug 2003 13:04:36 -0000
@@ -122,8 +122,10 @@
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,