Skip to content

Instantly share code, notes, and snippets.

@richardgv
Created October 3, 2014 09:49
Show Gist options
  • Save richardgv/3debcae0351b32af0604 to your computer and use it in GitHub Desktop.
Save richardgv/3debcae0351b32af0604 to your computer and use it in GitHub Desktop.
chjj/compton #232: Add window-type-based shadow opacity
diff --git a/src/common.h b/src/common.h
index 0aa4f18..37faee4 100644
--- a/src/common.h
+++ b/src/common.h
@@ -628,6 +628,8 @@ typedef struct _options_t {
// === Shadow ===
/// Enable/disable shadow for specific window types.
bool wintype_shadow[NUM_WINTYPES];
+ /// Shadow opacity factors for specific window types.
+ double wintype_shadow_opacity_factors[NUM_WINTYPES];
/// Red, green and blue tone of the shadow.
double shadow_red, shadow_green, shadow_blue;
int shadow_radius;
@@ -1183,6 +1185,8 @@ typedef struct _win {
switch_t shadow_force;
/// Opacity of the shadow. Affected by window opacity and frame opacity.
double shadow_opacity;
+ /// Factor to be applied on shadow opacity.
+ double shadow_opacity_factor;
/// X offset of shadow. Affected by commandline argument.
int shadow_dx;
/// Y offset of shadow. Affected by commandline argument.
diff --git a/src/compton.c b/src/compton.c
index b967372..01004d1 100644
--- a/src/compton.c
+++ b/src/compton.c
@@ -1318,7 +1318,7 @@ win_paint_shadow(session_t *ps, win *w,
}
render(ps, 0, 0, w->a.x + w->shadow_dx, w->a.y + w->shadow_dy,
- w->shadow_width, w->shadow_height, w->shadow_opacity, true, false,
+ w->shadow_width, w->shadow_height, normalize_d(w->shadow_opacity * w->shadow_opacity_factor), true, false,
w->shadow_paint.pict, w->shadow_paint.ptex, reg_paint, pcache_reg, NULL);
}
@@ -2541,6 +2541,9 @@ win_determine_shadow(session_t *ps, win *w) {
&& !(ps->o.respect_prop_shadow && 0 == w->prop_shadow));
win_set_shadow(ps, w, shadow_new);
+ w->shadow_opacity_factor =
+ ps->o.wintype_shadow_opacity_factors[w->window_type];
+ // FIXME: Force damage
}
static void
@@ -5560,6 +5563,8 @@ parse_config(session_t *ps, struct options_tmp *pcfgtmp) {
if (setting) {
if (config_setting_lookup_bool(setting, "shadow", &ival))
ps->o.wintype_shadow[i] = (bool) ival;
+ config_setting_lookup_float(setting, "shadow-opacity-factor",
+ &ps->o.wintype_shadow_opacity_factors[i]);
if (config_setting_lookup_bool(setting, "fade", &ival))
ps->o.wintype_fade[i] = (bool) ival;
if (config_setting_lookup_bool(setting, "focus", &ival))
@@ -5715,6 +5720,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
for (i = 0; i < NUM_WINTYPES; ++i) {
ps->o.wintype_fade[i] = false;
ps->o.wintype_shadow[i] = false;
+ ps->o.wintype_shadow_opacity_factors[i] = 1.0f;
ps->o.wintype_opacity[i] = 1.0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment