Add clip-shadow-above configuration and wintype option

Added the new `clip-shadow-above` configuration and wintype option.
These allow the user to select windows to clip from the shadow region of
other windows, i.e. don't paint shadows on top of them.

This should provide a more useful and userfriendly alternative to the
deprecated `shadow-exclude-reg` option — especially for docks and bars.
This commit is contained in:
Bernd Busse
2021-07-09 19:17:23 +02:00
parent 98fe8998c7
commit 4b5cc050d5
11 changed files with 91 additions and 3 deletions

View File

@@ -1046,6 +1046,10 @@ void paint_all(session_t *ps, struct managed_win *t, bool ignore_damage) {
reg_paint = &region;
}
// Region on screen we don't want any shadows on
region_t reg_shadow_clip;
pixman_region32_init(&reg_shadow_clip);
set_tgt_clip(ps, reg_paint);
paint_root(ps, reg_paint);
@@ -1074,6 +1078,9 @@ void paint_all(session_t *ps, struct managed_win *t, bool ignore_damage) {
if (pixman_region32_not_empty(&ps->shadow_exclude_reg))
pixman_region32_subtract(&reg_tmp, &reg_tmp,
&ps->shadow_exclude_reg);
if (pixman_region32_not_empty(&reg_shadow_clip)) {
pixman_region32_subtract(&reg_tmp, &reg_tmp, &reg_shadow_clip);
}
// Might be worth while to crop the region to shadow
// border
@@ -1109,6 +1116,20 @@ void paint_all(session_t *ps, struct managed_win *t, bool ignore_damage) {
}
}
// Only clip shadows above visible windows
if (w->opacity * MAX_ALPHA >= 1) {
if (w->clip_shadow_above) {
// Add window bounds to shadow-clip region
pixman_region32_union(&reg_shadow_clip, &reg_shadow_clip,
&bshape_corners);
} else {
// Remove overlapping window bounds from shadow-clip
// region
pixman_region32_subtract(
&reg_shadow_clip, &reg_shadow_clip, &bshape_corners);
}
}
// Calculate the paint region based on the reg_ignore of the current
// window and its bounding region.
// Remember, reg_ignore is the union of all windows above the current
@@ -1160,6 +1181,7 @@ void paint_all(session_t *ps, struct managed_win *t, bool ignore_damage) {
// Free up all temporary regions
pixman_region32_fini(&reg_tmp);
pixman_region32_fini(&reg_shadow_clip);
// Move the head of the damage ring
ps->damage = ps->damage - 1;