win: don't change window OPACITY property

Don't override the OPACITY property set by the user on the window.

Fixes #134

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-07-26 22:28:53 +01:00
parent 3434ea25f4
commit 79fc36b3e3
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
2 changed files with 5 additions and 23 deletions

View File

@ -68,16 +68,6 @@ static inline void clear_cache_win_leaders(session_t *ps) {
} }
} }
static inline void wid_set_opacity_prop(session_t *ps, xcb_window_t wid, opacity_t val) {
const uint32_t v = val;
xcb_change_property(ps->c, XCB_PROP_MODE_REPLACE, wid,
ps->atoms->a_NET_WM_WINDOW_OPACITY, XCB_ATOM_CARDINAL, 32, 1, &v);
}
static inline void wid_rm_opacity_prop(session_t *ps, xcb_window_t wid) {
xcb_delete_property(ps->c, wid, ps->atoms->a_NET_WM_WINDOW_OPACITY);
}
/** /**
* Run win_update_focused() on all windows with the same leader window. * Run win_update_focused() on all windows with the same leader window.
* *
@ -483,6 +473,8 @@ double win_calc_opacity_target(session_t *ps, const struct managed_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 = ((double)w->opacity_prop) / OPAQUE; opacity = ((double)w->opacity_prop) / OPAQUE;
} else if (w->opacity_is_set) {
opacity = w->opacity_set;
} else if (!safe_isnan(ps->o.wintype_option[w->window_type].opacity)) { } else if (!safe_isnan(ps->o.wintype_option[w->window_type].opacity)) {
opacity = ps->o.wintype_option[w->window_type].opacity; opacity = ps->o.wintype_option[w->window_type].opacity;
} else { } else {
@ -739,13 +731,11 @@ void win_determine_blur_background(session_t *ps, struct managed_win *w) {
/** /**
* Update window opacity according to opacity rules. * Update window opacity according to opacity rules.
*
* TODO This override the window's opacity property, may not be
* a good idea.
*/ */
void win_update_opacity_rule(session_t *ps, struct managed_win *w) { void win_update_opacity_rule(session_t *ps, struct managed_win *w) {
if (w->a.map_state != XCB_MAP_STATE_VIEWABLE) if (w->a.map_state != XCB_MAP_STATE_VIEWABLE) {
return; return;
}
double opacity = 1.0; double opacity = 1.0;
bool is_set = false; bool is_set = false;
@ -755,16 +745,8 @@ void win_update_opacity_rule(session_t *ps, struct managed_win *w) {
is_set = true; is_set = true;
} }
if (is_set == w->opacity_is_set && opacity == w->opacity_set)
return;
w->opacity_set = opacity; w->opacity_set = opacity;
w->opacity_is_set = is_set; w->opacity_is_set = is_set;
if (!is_set) {
wid_rm_opacity_prop(ps, w->base.id);
} else {
wid_set_opacity_prop(ps, w->base.id, (opacity_t)(opacity * OPAQUE));
}
} }
/** /**

View File

@ -271,7 +271,7 @@ struct managed_win {
opacity_t opacity_prop; opacity_t opacity_prop;
/// true if opacity is set by some rules /// true if opacity is set by some rules
bool opacity_is_set; bool opacity_is_set;
/// Last window opacity value we set. /// Last window opacity value set by the rules.
double opacity_set; double opacity_set;
// Fading-related members // Fading-related members