Skip to content

Instantly share code, notes, and snippets.

@richardgv
Created November 22, 2012 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richardgv/4131170 to your computer and use it in GitHub Desktop.
Save richardgv/4131170 to your computer and use it in GitHub Desktop.
chjj/compton #64: Add --inactive-shadow-opacity.
diff --git a/src/compton.c b/src/compton.c
index 6e2784f..b5b1fa9 100644
--- a/src/compton.c
+++ b/src/compton.c
@@ -1297,10 +1297,13 @@ paint_preprocess(session_t *ps, win *list) {
w->frame_alpha_pict = get_alpha_pict_d(ps, w->frame_opacity);
// Calculate shadow opacity
- if (w->frame_opacity)
- w->shadow_opacity = ps->o.shadow_opacity * w->frame_opacity;
- else
- w->shadow_opacity = ps->o.shadow_opacity * get_opacity_percent(w);
+ {
+ double shadow_opacity = (w->focused ? ps->o.shadow_opacity: ps->o.inactive_shadow_opacity);
+ if (w->frame_opacity)
+ w->shadow_opacity = shadow_opacity * w->frame_opacity;
+ else
+ w->shadow_opacity = shadow_opacity * get_opacity_percent(w);
+ }
// Rebuild shadow_pict if necessary
if (w->flags & WFLAG_SIZE_CHANGE)
@@ -3826,6 +3829,7 @@ get_cfg(session_t *ps, int argc, char *const *argv) {
{ "use-ewmh-active-win", no_argument, NULL, 276 },
{ "respect-prop-shadow", no_argument, NULL, 277 },
{ "unredir-if-possible", no_argument, NULL, 278 },
+ { "inactive-shadow-opacity", required_argument, NULL, 14352 },
// Must terminate with a NULL entry
{ NULL, 0, NULL, 0 },
};
@@ -4027,6 +4031,10 @@ get_cfg(session_t *ps, int argc, char *const *argv) {
// --unredir-if-possible
ps->o.unredir_if_possible = true;
break;
+ case 14352:
+ // --inactive-shadow-opacity
+ ps->o.inactive_shadow_opacity = atof(optarg);
+ break;
default:
usage();
}
@@ -4044,7 +4052,12 @@ get_cfg(session_t *ps, int argc, char *const *argv) {
ps->o.shadow_blue = normalize_d(ps->o.shadow_blue);
ps->o.inactive_dim = normalize_d(ps->o.inactive_dim);
ps->o.frame_opacity = normalize_d(ps->o.frame_opacity);
+
ps->o.shadow_opacity = normalize_d(ps->o.shadow_opacity);
+ ps->o.inactive_shadow_opacity = normalize_d(ps->o.inactive_shadow_opacity);
+ if (!ps->o.inactive_shadow_opacity)
+ ps->o.inactive_shadow_opacity = ps->o.shadow_opacity;
+
cfgtmp.menu_opacity = normalize_d(cfgtmp.menu_opacity);
ps->o.refresh_rate = normalize_i_range(ps->o.refresh_rate, 0, 300);
ps->o.alpha_step = normalize_d_range(ps->o.alpha_step, 0.01, 1.0);
@@ -4068,7 +4081,8 @@ get_cfg(session_t *ps, int argc, char *const *argv) {
// Other variables determined by options
// Determine whether we need to track focus changes
- if (ps->o.inactive_opacity || ps->o.inactive_dim) {
+ if (ps->o.inactive_opacity || ps->o.inactive_dim
+ || ps->o.shadow_opacity != ps->o.inactive_shadow_opacity) {
ps->o.track_focus = true;
}
@@ -4539,6 +4553,7 @@ session_init(session_t *ps_old, int argc, char **argv) {
.shadow_blacklist = NULL,
.shadow_ignore_shaped = false,
.respect_prop_shadow = false,
+ .inactive_shadow_opacity = 0.0,
.wintype_fade = { false },
.fade_in_step = 0.028 * OPAQUE,
diff --git a/src/compton.h b/src/compton.h
index ed32500..4cbff9a 100644
--- a/src/compton.h
+++ b/src/compton.h
@@ -258,6 +258,8 @@ typedef struct {
bool shadow_ignore_shaped;
/// Whether to respect _COMPTON_SHADOW.
bool respect_prop_shadow;
+ /// Shadow opacity for inactive windows.
+ double inactive_shadow_opacity;
// === Fading ===
bool wintype_fade[NUM_WINTYPES];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment