Clean up the wintype option logic
I just realized wintype option shadow and fade never worked. If you set the global shadow option to true, wintype shadow option will have no effect. Now the wintype options will properly override the global ones. Also remove deprecated options from compton.sample.conf. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
a3f753105f
commit
f97cf48865
|
@ -1,8 +1,5 @@
|
||||||
# Shadow
|
# Shadow
|
||||||
shadow = true;
|
shadow = true;
|
||||||
no-dnd-shadow = true;
|
|
||||||
no-dock-shadow = true;
|
|
||||||
clear-shadow = true;
|
|
||||||
shadow-radius = 7;
|
shadow-radius = 7;
|
||||||
shadow-offset-x = -7;
|
shadow-offset-x = -7;
|
||||||
shadow-offset-y = -7;
|
shadow-offset-y = -7;
|
||||||
|
@ -22,7 +19,6 @@ shadow-exclude = [
|
||||||
# xinerama-shadow-crop = true;
|
# xinerama-shadow-crop = true;
|
||||||
|
|
||||||
# Opacity
|
# Opacity
|
||||||
menu-opacity = 0.8;
|
|
||||||
inactive-opacity = 0.8;
|
inactive-opacity = 0.8;
|
||||||
# active-opacity = 0.8;
|
# active-opacity = 0.8;
|
||||||
frame-opacity = 0.7;
|
frame-opacity = 0.7;
|
||||||
|
@ -59,8 +55,6 @@ detect-rounded-corners = true;
|
||||||
detect-client-opacity = true;
|
detect-client-opacity = true;
|
||||||
refresh-rate = 0;
|
refresh-rate = 0;
|
||||||
vsync = "none";
|
vsync = "none";
|
||||||
dbe = false;
|
|
||||||
paint-on-overlay = true;
|
|
||||||
# sw-opti = true;
|
# sw-opti = true;
|
||||||
# unredir-if-possible = true;
|
# unredir-if-possible = true;
|
||||||
# unredir-if-possible-delay = 5000;
|
# unredir-if-possible-delay = 5000;
|
||||||
|
@ -83,4 +77,8 @@ glx-swap-method = "undefined";
|
||||||
wintypes:
|
wintypes:
|
||||||
{
|
{
|
||||||
tooltip = { fade = true; shadow = true; opacity = 0.75; focus = true; full-shadow = false; };
|
tooltip = { fade = true; shadow = true; opacity = 0.75; focus = true; full-shadow = false; };
|
||||||
|
dock = { shadow = false; }
|
||||||
|
dnd = { shadow = false; }
|
||||||
|
popup_menu = { opacity = 0.8; }
|
||||||
|
dropdown_menu = { opacity = 0.8; }
|
||||||
};
|
};
|
||||||
|
|
31
src/common.h
31
src/common.h
|
@ -64,6 +64,8 @@
|
||||||
|
|
||||||
#define MAX_ALPHA (255)
|
#define MAX_ALPHA (255)
|
||||||
|
|
||||||
|
#define ARR_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
|
||||||
|
|
||||||
// === Includes ===
|
// === Includes ===
|
||||||
|
|
||||||
// For some special functions
|
// For some special functions
|
||||||
|
@ -435,6 +437,24 @@ typedef struct _latom {
|
||||||
|
|
||||||
#define REG_DATA_INIT { NULL, 0 }
|
#define REG_DATA_INIT { NULL, 0 }
|
||||||
|
|
||||||
|
typedef struct win_option_mask {
|
||||||
|
bool shadow: 1;
|
||||||
|
bool fade: 1;
|
||||||
|
bool focus: 1;
|
||||||
|
bool full_shadow: 1;
|
||||||
|
bool redir_ignore: 1;
|
||||||
|
bool opacity: 1;
|
||||||
|
} win_option_mask_t;
|
||||||
|
|
||||||
|
typedef struct win_option {
|
||||||
|
bool shadow;
|
||||||
|
bool fade;
|
||||||
|
bool focus;
|
||||||
|
bool full_shadow;
|
||||||
|
bool redir_ignore;
|
||||||
|
double opacity;
|
||||||
|
} win_option_t;
|
||||||
|
|
||||||
/// Structure representing all options.
|
/// Structure representing all options.
|
||||||
typedef struct options_t {
|
typedef struct options_t {
|
||||||
// === Debugging ===
|
// === Debugging ===
|
||||||
|
@ -512,6 +532,8 @@ typedef struct options_t {
|
||||||
bool show_all_xerrors;
|
bool show_all_xerrors;
|
||||||
/// Whether to avoid acquiring X Selection.
|
/// Whether to avoid acquiring X Selection.
|
||||||
bool no_x_selection;
|
bool no_x_selection;
|
||||||
|
/// Window type option override.
|
||||||
|
win_option_t wintype_option[NUM_WINTYPES];
|
||||||
|
|
||||||
// === VSync & software optimization ===
|
// === VSync & software optimization ===
|
||||||
/// User-specified refresh rate.
|
/// User-specified refresh rate.
|
||||||
|
@ -527,9 +549,6 @@ typedef struct options_t {
|
||||||
bool vsync_use_glfinish;
|
bool vsync_use_glfinish;
|
||||||
|
|
||||||
// === Shadow ===
|
// === Shadow ===
|
||||||
/// Enable/disable shadow for specific window types.
|
|
||||||
bool wintype_shadow[NUM_WINTYPES];
|
|
||||||
bool wintype_full_shadow[NUM_WINTYPES];
|
|
||||||
/// Red, green and blue tone of the shadow.
|
/// Red, green and blue tone of the shadow.
|
||||||
double shadow_red, shadow_green, shadow_blue;
|
double shadow_red, shadow_green, shadow_blue;
|
||||||
int shadow_radius;
|
int shadow_radius;
|
||||||
|
@ -547,8 +566,6 @@ typedef struct options_t {
|
||||||
bool xinerama_shadow_crop;
|
bool xinerama_shadow_crop;
|
||||||
|
|
||||||
// === Fading ===
|
// === Fading ===
|
||||||
/// Enable/disable fading for specific window types.
|
|
||||||
bool wintype_fade[NUM_WINTYPES];
|
|
||||||
/// How much to fade in in a single fading step.
|
/// How much to fade in in a single fading step.
|
||||||
opacity_t fade_in_step;
|
opacity_t fade_in_step;
|
||||||
/// How much to fade out in a single fading step.
|
/// How much to fade out in a single fading step.
|
||||||
|
@ -563,8 +580,6 @@ typedef struct options_t {
|
||||||
c2_lptr_t *fade_blacklist;
|
c2_lptr_t *fade_blacklist;
|
||||||
|
|
||||||
// === Opacity ===
|
// === Opacity ===
|
||||||
/// Default opacity for specific window types
|
|
||||||
double wintype_opacity[NUM_WINTYPES];
|
|
||||||
/// Default opacity for inactive windows.
|
/// Default opacity for inactive windows.
|
||||||
/// 32-bit integer with the format of _NET_WM_OPACITY. 0 stands for
|
/// 32-bit integer with the format of _NET_WM_OPACITY. 0 stands for
|
||||||
/// not enabled, default.
|
/// not enabled, default.
|
||||||
|
@ -605,8 +620,6 @@ typedef struct options_t {
|
||||||
c2_lptr_t *opacity_rules;
|
c2_lptr_t *opacity_rules;
|
||||||
|
|
||||||
// === Focus related ===
|
// === Focus related ===
|
||||||
/// Consider windows of specific types to be always focused.
|
|
||||||
bool wintype_focus[NUM_WINTYPES];
|
|
||||||
/// Whether to try to detect WM windows and mark them as focused.
|
/// Whether to try to detect WM windows and mark them as focused.
|
||||||
bool mark_wmwin_focused;
|
bool mark_wmwin_focused;
|
||||||
/// Whether to mark override-redirect windows as focused.
|
/// Whether to mark override-redirect windows as focused.
|
||||||
|
|
|
@ -1904,7 +1904,7 @@ paint_all(session_t *ps, region_t *region, const region_t *region_real, win * co
|
||||||
// Mask out the body of the window from the shadow if needed
|
// Mask out the body of the window from the shadow if needed
|
||||||
// Doing it here instead of in make_shadow() for saving GPU
|
// Doing it here instead of in make_shadow() for saving GPU
|
||||||
// power and handling shaped windows (XXX unconfirmed)
|
// power and handling shaped windows (XXX unconfirmed)
|
||||||
if (!ps->o.wintype_full_shadow[w->window_type])
|
if (!ps->o.wintype_option[w->window_type].full_shadow)
|
||||||
pixman_region32_subtract(®_tmp, ®_tmp, &bshape);
|
pixman_region32_subtract(®_tmp, ®_tmp, &bshape);
|
||||||
|
|
||||||
#ifdef CONFIG_XINERAMA
|
#ifdef CONFIG_XINERAMA
|
||||||
|
@ -3920,7 +3920,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
|
||||||
{ NULL, 0, NULL, 0 },
|
{ NULL, 0, NULL, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
int o = 0, longopt_idx = -1, i = 0;
|
int o = 0, longopt_idx = -1;
|
||||||
|
|
||||||
if (first_pass) {
|
if (first_pass) {
|
||||||
// Pre-parse the commandline arguments to check for --config and invalid
|
// Pre-parse the commandline arguments to check for --config and invalid
|
||||||
|
@ -3955,25 +3955,16 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct options_tmp cfgtmp = {
|
|
||||||
.no_dock_shadow = false,
|
|
||||||
.no_dnd_shadow = false,
|
|
||||||
.menu_opacity = NAN,
|
|
||||||
};
|
|
||||||
bool shadow_enable = false, fading_enable = false;
|
bool shadow_enable = false, fading_enable = false;
|
||||||
char *lc_numeric_old = mstrcpy(setlocale(LC_NUMERIC, NULL));
|
char *lc_numeric_old = mstrcpy(setlocale(LC_NUMERIC, NULL));
|
||||||
|
|
||||||
for (i = 0; i < NUM_WINTYPES; ++i) {
|
win_option_mask_t winopt_mask[NUM_WINTYPES] = {{0}};
|
||||||
ps->o.wintype_fade[i] = false;
|
|
||||||
ps->o.wintype_shadow[i] = false;
|
|
||||||
ps->o.wintype_opacity[i] = NAN;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enforce LC_NUMERIC locale "C" here to make sure dots are recognized
|
// Enforce LC_NUMERIC locale "C" here to make sure dots are recognized
|
||||||
// instead of commas in atof().
|
// instead of commas in atof().
|
||||||
setlocale(LC_NUMERIC, "C");
|
setlocale(LC_NUMERIC, "C");
|
||||||
|
|
||||||
parse_config(ps, &cfgtmp);
|
parse_config(ps, &shadow_enable, &fading_enable, winopt_mask);
|
||||||
|
|
||||||
// Parse commandline arguments. Range checking will be done later.
|
// Parse commandline arguments. Range checking will be done later.
|
||||||
|
|
||||||
|
@ -4012,13 +4003,20 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
|
||||||
shadow_enable = true;
|
shadow_enable = true;
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
cfgtmp.no_dock_shadow = true;
|
winopt_mask[WINTYPE_DOCK].shadow = true;
|
||||||
|
ps->o.wintype_option[WINTYPE_DOCK].shadow = true;
|
||||||
break;
|
break;
|
||||||
case 'G':
|
case 'G':
|
||||||
cfgtmp.no_dnd_shadow = true;
|
winopt_mask[WINTYPE_DND].shadow = true;
|
||||||
|
ps->o.wintype_option[WINTYPE_DND].shadow = true;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':;
|
||||||
cfgtmp.menu_opacity = atof(optarg);
|
double tmp;
|
||||||
|
tmp = normalize_d(atof(optarg));
|
||||||
|
winopt_mask[WINTYPE_DROPDOWN_MENU].opacity = true;
|
||||||
|
winopt_mask[WINTYPE_POPUP_MENU].opacity = true;
|
||||||
|
ps->o.wintype_option[WINTYPE_POPUP_MENU].opacity = tmp;
|
||||||
|
ps->o.wintype_option[WINTYPE_DROPDOWN_MENU].opacity = tmp;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
case 'F':
|
case 'F':
|
||||||
|
@ -4232,22 +4230,20 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
|
||||||
ps->o.inactive_dim = normalize_d(ps->o.inactive_dim);
|
ps->o.inactive_dim = normalize_d(ps->o.inactive_dim);
|
||||||
ps->o.frame_opacity = normalize_d(ps->o.frame_opacity);
|
ps->o.frame_opacity = normalize_d(ps->o.frame_opacity);
|
||||||
ps->o.shadow_opacity = normalize_d(ps->o.shadow_opacity);
|
ps->o.shadow_opacity = normalize_d(ps->o.shadow_opacity);
|
||||||
cfgtmp.menu_opacity = normalize_d(cfgtmp.menu_opacity);
|
|
||||||
ps->o.refresh_rate = normalize_i_range(ps->o.refresh_rate, 0, 300);
|
ps->o.refresh_rate = normalize_i_range(ps->o.refresh_rate, 0, 300);
|
||||||
|
|
||||||
if (shadow_enable)
|
// Apply default wintype options that are dependent on global options
|
||||||
wintype_arr_enable(ps->o.wintype_shadow);
|
for (int i = 0; i < NUM_WINTYPES; i++) {
|
||||||
ps->o.wintype_shadow[WINTYPE_DESKTOP] = false;
|
auto wo = &ps->o.wintype_option[i];
|
||||||
if (cfgtmp.no_dock_shadow)
|
auto mask = &winopt_mask[i];
|
||||||
ps->o.wintype_shadow[WINTYPE_DOCK] = false;
|
if (!mask->shadow) {
|
||||||
if (cfgtmp.no_dnd_shadow)
|
wo->shadow = shadow_enable;
|
||||||
ps->o.wintype_shadow[WINTYPE_DND] = false;
|
mask->shadow = true;
|
||||||
if (fading_enable)
|
}
|
||||||
wintype_arr_enable(ps->o.wintype_fade);
|
if (!mask->fade) {
|
||||||
|
wo->fade = fading_enable;
|
||||||
if (!safe_isnan(cfgtmp.menu_opacity)) {
|
mask->fade = true;
|
||||||
ps->o.wintype_opacity[WINTYPE_DROPDOWN_MENU] = cfgtmp.menu_opacity;
|
}
|
||||||
ps->o.wintype_opacity[WINTYPE_POPUP_MENU] = cfgtmp.menu_opacity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --blur-background-frame implies --blur-background
|
// --blur-background-frame implies --blur-background
|
||||||
|
@ -5064,8 +5060,6 @@ session_init(session_t *ps_old, int argc, char **argv) {
|
||||||
.vsync = VSYNC_NONE,
|
.vsync = VSYNC_NONE,
|
||||||
.vsync_aggressive = false,
|
.vsync_aggressive = false,
|
||||||
|
|
||||||
.wintype_shadow = { false },
|
|
||||||
.wintype_full_shadow = { false },
|
|
||||||
.shadow_red = 0.0,
|
.shadow_red = 0.0,
|
||||||
.shadow_green = 0.0,
|
.shadow_green = 0.0,
|
||||||
.shadow_blue = 0.0,
|
.shadow_blue = 0.0,
|
||||||
|
@ -5078,7 +5072,6 @@ session_init(session_t *ps_old, int argc, char **argv) {
|
||||||
.respect_prop_shadow = false,
|
.respect_prop_shadow = false,
|
||||||
.xinerama_shadow_crop = false,
|
.xinerama_shadow_crop = false,
|
||||||
|
|
||||||
.wintype_fade = { false },
|
|
||||||
.fade_in_step = 0.028 * OPAQUE,
|
.fade_in_step = 0.028 * OPAQUE,
|
||||||
.fade_out_step = 0.03 * OPAQUE,
|
.fade_out_step = 0.03 * OPAQUE,
|
||||||
.fade_delta = 10,
|
.fade_delta = 10,
|
||||||
|
@ -5086,7 +5079,6 @@ session_init(session_t *ps_old, int argc, char **argv) {
|
||||||
.no_fading_destroyed_argb = false,
|
.no_fading_destroyed_argb = false,
|
||||||
.fade_blacklist = NULL,
|
.fade_blacklist = NULL,
|
||||||
|
|
||||||
.wintype_opacity = { NAN },
|
|
||||||
.inactive_opacity = OPAQUE,
|
.inactive_opacity = OPAQUE,
|
||||||
.inactive_opacity_override = false,
|
.inactive_opacity_override = false,
|
||||||
.active_opacity = OPAQUE,
|
.active_opacity = OPAQUE,
|
||||||
|
@ -5103,7 +5095,6 @@ session_init(session_t *ps_old, int argc, char **argv) {
|
||||||
.invert_color_list = NULL,
|
.invert_color_list = NULL,
|
||||||
.opacity_rules = NULL,
|
.opacity_rules = NULL,
|
||||||
|
|
||||||
.wintype_focus = { false },
|
|
||||||
.use_ewmh_active_win = false,
|
.use_ewmh_active_win = false,
|
||||||
.focus_blacklist = NULL,
|
.focus_blacklist = NULL,
|
||||||
.detect_transient = false,
|
.detect_transient = false,
|
||||||
|
@ -5203,11 +5194,6 @@ session_init(session_t *ps_old, int argc, char **argv) {
|
||||||
ps->ignore_tail = &ps->ignore_head;
|
ps->ignore_tail = &ps->ignore_head;
|
||||||
gettimeofday(&ps->time_start, NULL);
|
gettimeofday(&ps->time_start, NULL);
|
||||||
|
|
||||||
wintype_arr_enable(ps->o.wintype_focus);
|
|
||||||
ps->o.wintype_focus[WINTYPE_UNKNOWN] = false;
|
|
||||||
ps->o.wintype_focus[WINTYPE_NORMAL] = false;
|
|
||||||
ps->o.wintype_focus[WINTYPE_UTILITY] = false;
|
|
||||||
|
|
||||||
// First pass
|
// First pass
|
||||||
get_cfg(ps, argc, argv, true);
|
get_cfg(ps, argc, argv, true);
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,8 @@ parse_cfg_condlst(session_t *ps, const config_t *pcfg, c2_lptr_t **pcondlst,
|
||||||
const char *name);
|
const char *name);
|
||||||
|
|
||||||
void
|
void
|
||||||
parse_config(session_t *ps, struct options_tmp *pcfgtmp);
|
parse_config(session_t *ps, bool *shadow_enable,
|
||||||
|
bool *fading_enable, win_option_mask_t *winopt_mask);
|
||||||
#else
|
#else
|
||||||
static inline void parse_config(session_t *a, struct options_tmp *b) {
|
static inline void parse_config() {}
|
||||||
(void)a;
|
|
||||||
(void)b;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -156,8 +156,9 @@ parse_cfg_condlst_opct(session_t *ps, const config_t *pcfg, const char *name) {
|
||||||
/**
|
/**
|
||||||
* Parse a configuration file from default location.
|
* Parse a configuration file from default location.
|
||||||
*/
|
*/
|
||||||
void
|
void parse_config(session_t *ps, bool *shadow_enable, bool *fading_enable,
|
||||||
parse_config(session_t *ps, struct options_tmp *pcfgtmp) {
|
win_option_mask_t *winopt_mask)
|
||||||
|
{
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
config_t cfg;
|
config_t cfg;
|
||||||
|
@ -240,17 +241,35 @@ parse_config(session_t *ps, struct options_tmp *pcfgtmp) {
|
||||||
// -e (frame_opacity)
|
// -e (frame_opacity)
|
||||||
config_lookup_float(&cfg, "frame-opacity", &ps->o.frame_opacity);
|
config_lookup_float(&cfg, "frame-opacity", &ps->o.frame_opacity);
|
||||||
// -c (shadow_enable)
|
// -c (shadow_enable)
|
||||||
if (config_lookup_bool(&cfg, "shadow", &ival) && ival)
|
if (config_lookup_bool(&cfg, "shadow", &ival))
|
||||||
wintype_arr_enable(ps->o.wintype_shadow);
|
*shadow_enable = ival;
|
||||||
// -C (no_dock_shadow)
|
// -C (no_dock_shadow)
|
||||||
lcfg_lookup_bool(&cfg, "no-dock-shadow", &pcfgtmp->no_dock_shadow);
|
if (config_lookup_bool(&cfg, "no-dock-shadow", &ival)) {
|
||||||
|
printf_errf("(): option `no-dock-shadow` is deprecated, and will be removed.\n"
|
||||||
|
" Please use the wintype option `shadow` of `dock` instead.");
|
||||||
|
ps->o.wintype_option[WINTYPE_DOCK].shadow = false;
|
||||||
|
winopt_mask[WINTYPE_DOCK].shadow = true;
|
||||||
|
}
|
||||||
// -G (no_dnd_shadow)
|
// -G (no_dnd_shadow)
|
||||||
lcfg_lookup_bool(&cfg, "no-dnd-shadow", &pcfgtmp->no_dnd_shadow);
|
if (config_lookup_bool(&cfg, "no-dnd-shadow", &ival)) {
|
||||||
|
printf_errf("(): option `no-dnd-shadow` is deprecated, and will be removed.\n"
|
||||||
|
" Please use the wintype option `shadow` of `dnd` instead.");
|
||||||
|
ps->o.wintype_option[WINTYPE_DND].shadow = false;
|
||||||
|
winopt_mask[WINTYPE_DND].shadow = true;
|
||||||
|
};
|
||||||
// -m (menu_opacity)
|
// -m (menu_opacity)
|
||||||
config_lookup_float(&cfg, "menu-opacity", &pcfgtmp->menu_opacity);
|
if (config_lookup_float(&cfg, "menu-opacity", &dval)) {
|
||||||
|
printf_errf("(): option `menu-opacity` is deprecated, and will be removed.\n"
|
||||||
|
"Please use the wintype option `opacity` of `popup_menu` and\n"
|
||||||
|
"`dropdown_menu` instead.");
|
||||||
|
ps->o.wintype_option[WINTYPE_DROPDOWN_MENU].opacity = dval;
|
||||||
|
ps->o.wintype_option[WINTYPE_POPUP_MENU].opacity = dval;
|
||||||
|
winopt_mask[WINTYPE_DROPDOWN_MENU].opacity = true;
|
||||||
|
winopt_mask[WINTYPE_POPUP_MENU].opacity = true;
|
||||||
|
}
|
||||||
// -f (fading_enable)
|
// -f (fading_enable)
|
||||||
if (config_lookup_bool(&cfg, "fading", &ival) && ival)
|
if (config_lookup_bool(&cfg, "fading", &ival))
|
||||||
wintype_arr_enable(ps->o.wintype_fade);
|
*fading_enable = ival;
|
||||||
// --no-fading-open-close
|
// --no-fading-open-close
|
||||||
lcfg_lookup_bool(&cfg, "no-fading-openclose", &ps->o.no_fading_openclose);
|
lcfg_lookup_bool(&cfg, "no-fading-openclose", &ps->o.no_fading_openclose);
|
||||||
// --no-fading-destroyed-argb
|
// --no-fading-destroyed-argb
|
||||||
|
@ -381,19 +400,69 @@ parse_config(session_t *ps, struct options_tmp *pcfgtmp) {
|
||||||
char *str = mstrjoin("wintypes.", WINTYPES[i]);
|
char *str = mstrjoin("wintypes.", WINTYPES[i]);
|
||||||
config_setting_t *setting = config_lookup(&cfg, str);
|
config_setting_t *setting = config_lookup(&cfg, str);
|
||||||
free(str);
|
free(str);
|
||||||
|
|
||||||
|
win_option_t *o = &ps->o.wintype_option[i];
|
||||||
|
win_option_mask_t *mask = &winopt_mask[i];
|
||||||
if (setting) {
|
if (setting) {
|
||||||
if (config_setting_lookup_bool(setting, "shadow", &ival))
|
if (config_setting_lookup_bool(setting, "shadow", &ival)) {
|
||||||
ps->o.wintype_shadow[i] = (bool) ival;
|
o->shadow = ival;
|
||||||
if (config_setting_lookup_bool(setting, "fade", &ival))
|
mask->shadow = true;
|
||||||
ps->o.wintype_fade[i] = (bool) ival;
|
}
|
||||||
if (config_setting_lookup_bool(setting, "focus", &ival))
|
if (config_setting_lookup_bool(setting, "fade", &ival)) {
|
||||||
ps->o.wintype_focus[i] = (bool) ival;
|
o->fade = ival;
|
||||||
if (config_setting_lookup_bool(setting, "full-shadow", &ival))
|
mask->fade = true;
|
||||||
ps->o.wintype_full_shadow[i] = ival;
|
}
|
||||||
|
if (config_setting_lookup_bool(setting, "focus", &ival)) {
|
||||||
|
o->focus = ival;
|
||||||
|
mask->focus = true;
|
||||||
|
}
|
||||||
|
if (config_setting_lookup_bool(setting, "full-shadow", &ival)) {
|
||||||
|
o->full_shadow = ival;
|
||||||
|
mask->full_shadow = true;
|
||||||
|
}
|
||||||
|
|
||||||
double fval;
|
double fval;
|
||||||
if (config_setting_lookup_float(setting, "opacity", &fval))
|
if (config_setting_lookup_float(setting, "opacity", &fval)) {
|
||||||
ps->o.wintype_opacity[i] = normalize_d(fval);
|
o->opacity = normalize_d(fval);
|
||||||
|
mask->opacity = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply default wintype options that does not depends on global options.
|
||||||
|
// For example, wintype shadow option will depend on the global shadow
|
||||||
|
// option, so it is not set here.
|
||||||
|
//
|
||||||
|
// Except desktop windows are always drawn without shadow.
|
||||||
|
if (!winopt_mask[WINTYPE_DESKTOP].shadow) {
|
||||||
|
winopt_mask[WINTYPE_DESKTOP].shadow = true;
|
||||||
|
ps->o.wintype_option[WINTYPE_DESKTOP].shadow = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Focused/unfocused state only apply to a few window types, all other windows
|
||||||
|
// are always considered focused.
|
||||||
|
const wintype_t nofocus_type[] =
|
||||||
|
{ WINTYPE_UNKNOWN, WINTYPE_NORMAL, WINTYPE_UTILITY };
|
||||||
|
for (unsigned long i = 0; i < ARR_SIZE(nofocus_type); i++) {
|
||||||
|
if (!winopt_mask[nofocus_type[i]].focus) {
|
||||||
|
winopt_mask[nofocus_type[i]].focus = true;
|
||||||
|
ps->o.wintype_option[nofocus_type[i]].focus = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (unsigned long i = 0; i < NUM_WINTYPES; i++) {
|
||||||
|
if (!winopt_mask[i].focus) {
|
||||||
|
winopt_mask[i].focus = true;
|
||||||
|
ps->o.wintype_option[i].focus = true;
|
||||||
|
}
|
||||||
|
if (!winopt_mask[i].full_shadow) {
|
||||||
|
winopt_mask[i].full_shadow = true;
|
||||||
|
ps->o.wintype_option[i].full_shadow = false;
|
||||||
|
}
|
||||||
|
if (!winopt_mask[i].opacity) {
|
||||||
|
winopt_mask[i].opacity = true;
|
||||||
|
// Opacity is not set to a concrete number here because the opacity logic
|
||||||
|
// is complicated, and needs an "unset" state
|
||||||
|
ps->o.wintype_option[i].opacity = NAN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
src/win.c
10
src/win.c
|
@ -323,8 +323,8 @@ void win_calc_opacity(session_t *ps, 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 = w->opacity_prop;
|
opacity = w->opacity_prop;
|
||||||
else if (!safe_isnan(ps->o.wintype_opacity[w->window_type]))
|
else if (!safe_isnan(ps->o.wintype_option[w->window_type].opacity))
|
||||||
opacity = ps->o.wintype_opacity[w->window_type] * OPAQUE;
|
opacity = ps->o.wintype_option[w->window_type].opacity * OPAQUE;
|
||||||
else {
|
else {
|
||||||
// Respect active_opacity only when the window is physically focused
|
// Respect active_opacity only when the window is physically focused
|
||||||
if (win_is_focused_real(ps, w))
|
if (win_is_focused_real(ps, w))
|
||||||
|
@ -384,7 +384,7 @@ void win_determine_fade(session_t *ps, win *w) {
|
||||||
} else if (c2_match(ps, w, ps->o.fade_blacklist, &w->cache_fblst, NULL))
|
} else if (c2_match(ps, w, ps->o.fade_blacklist, &w->cache_fblst, NULL))
|
||||||
w->fade = false;
|
w->fade = false;
|
||||||
else
|
else
|
||||||
w->fade = ps->o.wintype_fade[w->window_type];
|
w->fade = ps->o.wintype_option[w->window_type].fade;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -454,7 +454,7 @@ void win_determine_shadow(session_t *ps, win *w) {
|
||||||
if (UNSET != w->shadow_force)
|
if (UNSET != w->shadow_force)
|
||||||
shadow_new = w->shadow_force;
|
shadow_new = w->shadow_force;
|
||||||
else if (w->a.map_state == XCB_MAP_STATE_VIEWABLE)
|
else if (w->a.map_state == XCB_MAP_STATE_VIEWABLE)
|
||||||
shadow_new = (ps->o.wintype_shadow[w->window_type] &&
|
shadow_new = (ps->o.wintype_option[w->window_type].shadow &&
|
||||||
!c2_match(ps, w, ps->o.shadow_blacklist, &w->cache_sblst, NULL) &&
|
!c2_match(ps, w, ps->o.shadow_blacklist, &w->cache_sblst, NULL) &&
|
||||||
!(ps->o.shadow_ignore_shaped && w->bounding_shaped &&
|
!(ps->o.shadow_ignore_shaped && w->bounding_shaped &&
|
||||||
!w->rounded_corners) &&
|
!w->rounded_corners) &&
|
||||||
|
@ -914,7 +914,7 @@ void win_update_focused(session_t *ps, win *w) {
|
||||||
|
|
||||||
// Use wintype_focus, and treat WM windows and override-redirected
|
// Use wintype_focus, and treat WM windows and override-redirected
|
||||||
// windows specially
|
// windows specially
|
||||||
if (ps->o.wintype_focus[w->window_type]
|
if (ps->o.wintype_option[w->window_type].focus
|
||||||
|| (ps->o.mark_wmwin_focused && w->wmwin)
|
|| (ps->o.mark_wmwin_focused && w->wmwin)
|
||||||
|| (ps->o.mark_ovredir_focused &&
|
|| (ps->o.mark_ovredir_focused &&
|
||||||
w->id == w->client_win && !w->wmwin)
|
w->id == w->client_win && !w->wmwin)
|
||||||
|
|
Loading…
Reference in New Issue