Skip to content

Instantly share code, notes, and snippets.

@richardgv
Created February 1, 2014 14:09
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/8752853 to your computer and use it in GitHub Desktop.
Save richardgv/8752853 to your computer and use it in GitHub Desktop.
chjj/compton #173: Add --active-dim support
diff --git a/src/common.h b/src/common.h
index 7786f82..7735184 100644
--- a/src/common.h
+++ b/src/common.h
@@ -587,6 +587,8 @@ typedef struct {
XFixed *blur_kerns[MAX_BLUR_PASS];
/// How much to dim an inactive window. 0.0 - 1.0, 0 to disable.
double inactive_dim;
+ /// How much to dim an (really) active window. 0.0 - 1.0, 0 to disable.
+ double active_dim;
/// Whether to use fixed inactive dim opacity, instead of deciding
/// based on window opacity.
bool inactive_dim_fixed;
@@ -1043,8 +1045,8 @@ typedef struct _win {
long prop_shadow;
// Dim-related members
- /// Whether the window is to be dimmed.
- bool dim;
+ /// Window dim strength.
+ double dim;
/// Whether to invert window color.
bool invert_color;
diff --git a/src/compton.c b/src/compton.c
index 3a14d82..bc327c0 100644
--- a/src/compton.c
+++ b/src/compton.c
@@ -1637,8 +1637,8 @@ win_paint_win(session_t *ps, win *w, XserverRegion reg_paint,
free_picture(ps, &pict);
// Dimming the window if needed
- if (w->dim) {
- double dim_opacity = ps->o.inactive_dim;
+ if (w->dim > 0.01f) {
+ double dim_opacity = w->dim;
if (!ps->o.inactive_dim_fixed)
dim_opacity *= get_opacity_percent(w);
@@ -2331,17 +2331,16 @@ calc_opacity(session_t *ps, win *w) {
*/
static void
calc_dim(session_t *ps, win *w) {
- bool dim;
+ double dim = 0.0f;
// Make sure we do nothing if the window is unmapped / destroyed
if (w->destroyed || IsViewable != w->a.map_state)
return;
- if (ps->o.inactive_dim && !(w->focused)) {
- dim = true;
- } else {
- dim = false;
- }
+ if (ps->o.inactive_dim && !(w->focused))
+ dim = ps->o.inactive_dim;
+ else if (ps->o.active_dim && win_is_focused_real(ps, w))
+ dim = ps->o.active_dim;
if (dim != w->dim) {
w->dim = dim;
@@ -5462,6 +5461,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
{ "unredir-if-possible-delay", required_argument, NULL, 309 },
{ "write-pid-path", required_argument, NULL, 310 },
{ "vsync-use-glfinish", no_argument, NULL, 311 },
+ { "active-dim", required_argument, NULL, 787 },
// Must terminate with a NULL entry
{ NULL, 0, NULL, 0 },
};
@@ -5597,6 +5597,10 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
// --inactive-dim
ps->o.inactive_dim = atof(optarg);
break;
+ case 787:
+ // --active-dim
+ ps->o.active_dim = atof(optarg);
+ break;
P_CASEBOOL(262, mark_wmwin_focused);
case 263:
// --shadow-exclude
@@ -5728,6 +5732,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
ps->o.shadow_green = normalize_d(ps->o.shadow_green);
ps->o.shadow_blue = normalize_d(ps->o.shadow_blue);
ps->o.inactive_dim = normalize_d(ps->o.inactive_dim);
+ ps->o.active_dim = normalize_d(ps->o.active_dim);
ps->o.frame_opacity = normalize_d(ps->o.frame_opacity);
ps->o.shadow_opacity = normalize_d(ps->o.shadow_opacity);
cfgtmp.menu_opacity = normalize_d(cfgtmp.menu_opacity);
@@ -5760,7 +5765,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
// Other variables determined by options
// Determine whether we need to track focus changes
- if (ps->o.inactive_opacity || ps->o.active_opacity || ps->o.inactive_dim) {
+ if (ps->o.inactive_opacity || ps->o.active_opacity || ps->o.inactive_dim || ps->o.active_dim) {
ps->o.track_focus = true;
}
diff --git a/src/dbus.c b/src/dbus.c
index 8aec9ea..5ea71a0 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -943,6 +943,7 @@ cdbus_process_opts_get(session_t *ps, DBusMessage *msg) {
cdbus_m_opts_get_do(blur_background_fixed, cdbus_reply_bool);
cdbus_m_opts_get_do(inactive_dim, cdbus_reply_double);
+ cdbus_m_opts_get_do(active_dim, cdbus_reply_double);
cdbus_m_opts_get_do(inactive_dim_fixed, cdbus_reply_bool);
cdbus_m_opts_get_do(use_ewmh_active_win, cdbus_reply_bool);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment