From 7817f52cb1e1087004ee77914a7cb0dc08dd704d Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sat, 7 Mar 2020 12:11:55 +0000 Subject: [PATCH] Rename wintype "notify" to "notification" "notify" is the only wintype that has a name inconsistent with its Xorg name. So fix that. Compatibility code is added as well, so the old "notify" wintype name still works. Fixes #323 Signed-off-by: Yuxuan Shui --- man/picom.1.asciidoc | 2 +- src/config_libconfig.c | 77 +++++++++++++++++++++++------------------- src/picom.c | 6 ++-- 3 files changed, 47 insertions(+), 38 deletions(-) diff --git a/man/picom.1.asciidoc b/man/picom.1.asciidoc index b22030b..cca7ccd 100644 --- a/man/picom.1.asciidoc +++ b/man/picom.1.asciidoc @@ -361,7 +361,7 @@ wintypes: }; ------------ -'WINDOW_TYPE' is one of the 15 window types defined in EWMH standard: "unknown", "desktop", "dock", "toolbar", "menu", "utility", "splash", "dialog", "normal", "dropdown_menu", "popup_menu", "tooltip", "notify", "combo", and "dnd". +'WINDOW_TYPE' is one of the 15 window types defined in EWMH standard: "unknown", "desktop", "dock", "toolbar", "menu", "utility", "splash", "dialog", "normal", "dropdown_menu", "popup_menu", "tooltip", "notification", "combo", and "dnd". Following per window-type options are available: :: diff --git a/src/config_libconfig.c b/src/config_libconfig.c index 6cce394..b07155c 100644 --- a/src/config_libconfig.c +++ b/src/config_libconfig.c @@ -250,6 +250,43 @@ parse_cfg_condlst_opct(options_t *opt, const config_t *pcfg, const char *name) { } } +static inline void parse_wintype_config(const config_t *cfg, const char *member_name, + win_option_t *o, win_option_mask_t *mask) { + char *str = mstrjoin("wintypes.", member_name); + const config_setting_t *setting = config_lookup(cfg, str); + free(str); + + int ival = 0; + if (setting) { + if (config_setting_lookup_bool(setting, "shadow", &ival)) { + o->shadow = ival; + mask->shadow = true; + } + if (config_setting_lookup_bool(setting, "fade", &ival)) { + o->fade = ival; + mask->fade = true; + } + 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; + } + if (config_setting_lookup_bool(setting, "redir-ignore", &ival)) { + o->redir_ignore = ival; + mask->redir_ignore = true; + } + + double fval; + if (config_setting_lookup_float(setting, "opacity", &fval)) { + o->opacity = normalize_d(fval); + mask->opacity = true; + } + } +} + /** * Parse a configuration file from default location. * @@ -604,42 +641,14 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad // XXX ! Refactor all the wintype_* arrays into a struct for (wintype_t i = 0; i < NUM_WINTYPES; ++i) { - char *str = mstrjoin("wintypes.", WINTYPES[i]); - config_setting_t *setting = config_lookup(&cfg, str); - free(str); - - win_option_t *o = &opt->wintype_option[i]; - win_option_mask_t *mask = &winopt_mask[i]; - if (setting) { - if (config_setting_lookup_bool(setting, "shadow", &ival)) { - o->shadow = ival; - mask->shadow = true; - } - if (config_setting_lookup_bool(setting, "fade", &ival)) { - o->fade = ival; - mask->fade = true; - } - 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; - } - if (config_setting_lookup_bool(setting, "redir-ignore", &ival)) { - o->redir_ignore = ival; - mask->redir_ignore = true; - } - - double fval; - if (config_setting_lookup_float(setting, "opacity", &fval)) { - o->opacity = normalize_d(fval); - mask->opacity = true; - } - } + parse_wintype_config(&cfg, WINTYPES[i], &opt->wintype_option[i], + &winopt_mask[i]); } + // Compatibility with the old name for notification windows. + parse_wintype_config(&cfg, "notify", &opt->wintype_option[WINTYPE_NOTIFICATION], + &winopt_mask[WINTYPE_NOTIFICATION]); + config_destroy(&cfg); return path; diff --git a/src/picom.c b/src/picom.c index 93d425e..51e91e1 100644 --- a/src/picom.c +++ b/src/picom.c @@ -76,9 +76,9 @@ static void unredirect(session_t *ps); /// Name strings for window types. const char *const WINTYPES[NUM_WINTYPES] = { - "unknown", "desktop", "dock", "toolbar", "menu", - "utility", "splash", "dialog", "normal", "dropdown_menu", - "popup_menu", "tooltip", "notify", "combo", "dnd", + "unknown", "desktop", "dock", "toolbar", "menu", + "utility", "splash", "dialog", "normal", "dropdown_menu", + "popup_menu", "tooltip", "notification", "combo", "dnd", }; // clang-format off