Allow setting active/inactive opacity to 0

This commit is contained in:
Yuxuan Shui 2018-08-11 14:48:37 -04:00
parent 15e3c525e3
commit c8bfbd6b11
2 changed files with 15 additions and 23 deletions

View File

@ -69,7 +69,7 @@ OPTIONS
Equals to *-f*. Deprecated. Equals to *-f*. Deprecated.
*-i*, *--inactive-opacity*='OPACITY':: *-i*, *--inactive-opacity*='OPACITY'::
Opacity of inactive windows. (0.1 - 1.0, disabled by default) Opacity of inactive windows. (0.1 - 1.0, defaults to 1.0)
*-e*, *--frame-opacity*='OPACITY':: *-e*, *--frame-opacity*='OPACITY'::
Opacity of window titlebars and borders. (0.1 - 1.0, disabled by default) Opacity of window titlebars and borders. (0.1 - 1.0, disabled by default)
@ -105,7 +105,7 @@ OPTIONS
Let inactive opacity set by *-i* overrides the windows' '_NET_WM_OPACITY' values. Let inactive opacity set by *-i* overrides the windows' '_NET_WM_OPACITY' values.
*--active-opacity* 'OPACITY':: *--active-opacity* 'OPACITY'::
Default opacity for active windows. (0.0 - 1.0) Default opacity for active windows. (0.0 - 1.0, defaults to 1.0)
*--inactive-dim* 'VALUE':: *--inactive-dim* 'VALUE'::
Dim inactive windows. (0.0 - 1.0, defaults to 0.0) Dim inactive windows. (0.0 - 1.0, defaults to 0.0)

View File

@ -2379,22 +2379,19 @@ calc_opacity(session_t *ps, win *w) {
// Try obeying opacity property and window type opacity firstly // Try obeying opacity property and window type opacity firstly
if(w->has_opacity_prop) if(w->has_opacity_prop)
opacity = w->opacity_prop; opacity = w->opacity_prop;
else { else if (!isnan(ps->o.wintype_opacity[w->window_type]))
if (!isnan(ps->o.wintype_opacity[w->window_type]))
opacity = ps->o.wintype_opacity[w->window_type] * OPAQUE; opacity = ps->o.wintype_opacity[w->window_type] * OPAQUE;
else { else {
// Respect active_opacity only when the window is physically focused // Respect active_opacity only when the window is physically focused
if (ps->o.active_opacity && win_is_focused_real(ps, w)) if (win_is_focused_real(ps, w))
opacity = ps->o.active_opacity; opacity = ps->o.active_opacity;
else if (ps->o.inactive_opacity && false == w->focused) else if (false == w->focused)
// Respect inactive_opacity in some cases // Respect inactive_opacity in some cases
opacity = ps->o.inactive_opacity; opacity = ps->o.inactive_opacity;
} }
}
// respect inactive override // respect inactive override
if (ps->o.inactive_opacity && false == w->focused && if (ps->o.inactive_opacity_override && false == w->focused)
ps->o.inactive_opacity_override)
opacity = ps->o.inactive_opacity; opacity = ps->o.inactive_opacity;
} }
@ -6060,12 +6057,6 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
cfgtmp.menu_opacity = normalize_d(cfgtmp.menu_opacity); cfgtmp.menu_opacity = normalize_d(cfgtmp.menu_opacity);
ps->o.refresh_rate = normalize_i_range(ps->o.refresh_rate, 0, 300); 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); ps->o.alpha_step = normalize_d_range(ps->o.alpha_step, 0.01, 1.0);
if (OPAQUE == ps->o.inactive_opacity) {
ps->o.inactive_opacity = 0;
}
if (OPAQUE == ps->o.active_opacity) {
ps->o.active_opacity = 0;
}
if (shadow_enable) if (shadow_enable)
wintype_arr_enable(ps->o.wintype_shadow); wintype_arr_enable(ps->o.wintype_shadow);
ps->o.wintype_shadow[WINTYPE_DESKTOP] = false; ps->o.wintype_shadow[WINTYPE_DESKTOP] = false;
@ -6090,7 +6081,8 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
// Other variables determined by options // Other variables determined by options
// Determine whether we need to track focus changes // 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.track_focus = true; ps->o.track_focus = true;
} }
@ -7027,9 +7019,9 @@ session_init(session_t *ps_old, int argc, char **argv) {
.fade_blacklist = NULL, .fade_blacklist = NULL,
.wintype_opacity = { NAN }, .wintype_opacity = { NAN },
.inactive_opacity = 0, .inactive_opacity = OPAQUE,
.inactive_opacity_override = false, .inactive_opacity_override = false,
.active_opacity = 0, .active_opacity = OPAQUE,
.frame_opacity = 0.0, .frame_opacity = 0.0,
.detect_client_opacity = false, .detect_client_opacity = false,
.alpha_step = 0.03, .alpha_step = 0.03,