From 79fc36b3e30989fd638aa0531588e02b564a906c Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Fri, 26 Jul 2019 22:28:53 +0100 Subject: [PATCH] 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 --- src/win.c | 26 ++++---------------------- src/win.h | 2 +- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/src/win.c b/src/win.c index 6f14e35..52479b1 100644 --- a/src/win.c +++ b/src/win.c @@ -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. * @@ -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 if (w->has_opacity_prop) { 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)) { opacity = ps->o.wintype_option[w->window_type].opacity; } else { @@ -739,13 +731,11 @@ void win_determine_blur_background(session_t *ps, struct managed_win *w) { /** * 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) { - if (w->a.map_state != XCB_MAP_STATE_VIEWABLE) + if (w->a.map_state != XCB_MAP_STATE_VIEWABLE) { return; + } double opacity = 1.0; bool is_set = false; @@ -755,16 +745,8 @@ void win_update_opacity_rule(session_t *ps, struct managed_win *w) { is_set = true; } - if (is_set == w->opacity_is_set && opacity == w->opacity_set) - return; - w->opacity_set = opacity; 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)); - } } /** diff --git a/src/win.h b/src/win.h index 90e6af4..61f511e 100644 --- a/src/win.h +++ b/src/win.h @@ -271,7 +271,7 @@ struct managed_win { 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 set by the rules. double opacity_set; // Fading-related members