Skip to content

Commit

Permalink
win: don't change window OPACITY property
Browse files Browse the repository at this point in the history
Don't override the OPACITY property set by the user on the window.

Fixes #134

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
  • Loading branch information
yshui committed Jul 26, 2019
1 parent 3434ea2 commit 79fc36b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
26 changes: 4 additions & 22 deletions src/win.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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));
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/win.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 79fc36b

Please sign in to comment.