Skip to content

Commit

Permalink
Translucent Menus
Browse files Browse the repository at this point in the history
  Update the Translucent colorset for menus patch to work with fvwm3.
  • Loading branch information
somiaj committed Nov 11, 2022
1 parent 9a2e418 commit 7d09860
Show file tree
Hide file tree
Showing 7 changed files with 266 additions and 20 deletions.
50 changes: 50 additions & 0 deletions fvwm/colorset.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ static char *csetopts[] =
"NoIconTint",
"IconAlpha",

/* Translucent Menus */
"Translucent",
"NoTranslucent",

NULL
};

Expand Down Expand Up @@ -620,6 +624,7 @@ void parse_colorset(int n, char *line)
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;
Expand All @@ -632,6 +637,7 @@ void parse_colorset(int n, char *line)
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;
Expand Down Expand Up @@ -758,6 +764,10 @@ void parse_colorset(int n, char *line)
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;
Expand Down Expand Up @@ -923,6 +933,24 @@ void parse_colorset(int n, char *line)
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"))
Expand Down Expand Up @@ -1624,6 +1652,25 @@ void parse_colorset(int n, char *line)
}
}

/* 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 ----------
*/
Expand Down Expand Up @@ -1720,6 +1767,7 @@ void alloc_colorset(int n)
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,
Expand All @@ -1737,6 +1785,7 @@ void alloc_colorset(int n)
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 */
Expand All @@ -1748,6 +1797,7 @@ void alloc_colorset(int n)
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++;
Expand Down
3 changes: 3 additions & 0 deletions fvwm/menuroot.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ typedef struct MenuRootDynamic
int d_npixels;
} stored_pixels;
/* alloc pixels when dithering is used for gradients */
/* x,y XMapRaise */
int x;
int y;
} MenuRootDynamic;

/* access macros to dynamic menu members */
Expand Down
Loading

0 comments on commit 7d09860

Please sign in to comment.