Honor opacity explicitly set by rules

This commit is contained in:
Yuxuan Shui 2018-08-11 14:26:18 -04:00
parent 58a0b9ec39
commit bfead72d37
2 changed files with 13 additions and 8 deletions

View File

@ -1167,6 +1167,8 @@ typedef struct _win {
bool has_opacity_prop; bool has_opacity_prop;
/// Cached value of opacity window attribute. /// Cached value of opacity window attribute.
opacity_t opacity_prop; opacity_t opacity_prop;
/// true if opacity is set by some rules
bool opacity_is_set;
/// Last window opacity value we set. /// Last window opacity value we set.
opacity_t opacity_set; opacity_t opacity_set;

View File

@ -2619,21 +2619,23 @@ win_update_opacity_rule(session_t *ps, win *w) {
return; return;
#ifdef CONFIG_C2 #ifdef CONFIG_C2
// If long is 32-bit, unfortunately there's no way could we express "unset",
// so we just entirely don't distinguish "unset" and OPAQUE
opacity_t opacity = OPAQUE; opacity_t opacity = OPAQUE;
bool is_set = false;
void *val = NULL; void *val = NULL;
if (c2_matchd(ps, w, ps->o.opacity_rules, &w->cache_oparule, &val)) if (c2_matchd(ps, w, ps->o.opacity_rules, &w->cache_oparule, &val)) {
opacity = ((double) (long) val) / 100.0 * OPAQUE; opacity = ((double) (long) val) / 100.0 * OPAQUE;
is_set = true;
}
if (opacity == w->opacity_set) if (is_set == w->opacity_is_set && opacity == w->opacity_set)
return; return;
if (OPAQUE != opacity)
wid_set_opacity_prop(ps, w->id, opacity);
else if (OPAQUE != w->opacity_set)
wid_rm_opacity_prop(ps, w->id);
w->opacity_set = opacity; w->opacity_set = opacity;
w->opacity_is_set = is_set;
if (!is_set)
wid_rm_opacity_prop(ps, w->id);
else
wid_set_opacity_prop(ps, w->id, opacity);
#endif #endif
} }
@ -2880,6 +2882,7 @@ add_win(session_t *ps, Window id, Window prev) {
.opacity_tgt = 0, .opacity_tgt = 0,
.has_opacity_prop = false, .has_opacity_prop = false,
.opacity_prop = OPAQUE, .opacity_prop = OPAQUE,
.opacity_is_set = false,
.opacity_set = OPAQUE, .opacity_set = OPAQUE,
.fade = false, .fade = false,