summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compton.c27
-rw-r--r--compton.h5
2 files changed, 26 insertions, 6 deletions
diff --git a/compton.c b/compton.c
index dd9341cbc..68577f1ec 100644
--- a/compton.c
+++ b/compton.c
@@ -2469,7 +2469,7 @@ static void
win_update_opacity_rule(session_t *ps, win *w) {
// If long is 32-bit, unfortunately there's no way could we express "unset",
// so we just entirely don't distinguish "unset" and OPAQUE
- long opacity = OPAQUE;
+ opacity_t opacity = OPAQUE;
void *val = NULL;
if (c2_matchd(ps, w, ps->o.opacity_rules, &w->cache_oparule, &val))
opacity = ((double) (long) val) / 100.0 * OPAQUE;
@@ -5029,9 +5029,8 @@ parse_cfg_condlst(session_t *ps, const config_t *pcfg, c2_lptr_t **pcondlst,
// Parse an array of options
if (config_setting_is_array(setting)) {
int i = config_setting_length(setting);
- while (i--) {
+ while (i--)
condlst_add(ps, pcondlst, config_setting_get_string_elem(setting, i));
- }
}
// Treat it as a single pattern if it's a string
else if (CONFIG_TYPE_STRING == config_setting_type(setting)) {
@@ -5041,6 +5040,26 @@ parse_cfg_condlst(session_t *ps, const config_t *pcfg, c2_lptr_t **pcondlst,
}
/**
+ * Parse an opacity rule list in configuration file.
+ */
+static inline void
+parse_cfg_condlst_opct(session_t *ps, const config_t *pcfg, const char *name) {
+ config_setting_t *setting = config_lookup(pcfg, name);
+ if (setting) {
+ // Parse an array of options
+ if (config_setting_is_array(setting)) {
+ int i = config_setting_length(setting);
+ while (i--)
+ parse_rule_opacity(ps, config_setting_get_string_elem(setting, i));
+ }
+ // Treat it as a single pattern if it's a string
+ else if (CONFIG_TYPE_STRING == config_setting_type(setting)) {
+ parse_rule_opacity(ps, config_setting_get_string(setting));
+ }
+ }
+}
+
+/**
* Parse a configuration file from default location.
*/
static void
@@ -5213,7 +5232,7 @@ parse_config(session_t *ps, struct options_tmp *pcfgtmp) {
// --blur-background-exclude
parse_cfg_condlst(ps, &cfg, &ps->o.blur_background_blacklist, "blur-background-exclude");
// --opacity-rule
- parse_cfg_condlst(ps, &cfg, &ps->o.opacity_rules, "opacity-rule");
+ parse_cfg_condlst_opct(ps, &cfg, "opacity-rule");
// --unredir-if-possible-exclude
parse_cfg_condlst(ps, &cfg, &ps->o.unredir_if_possible_blacklist, "unredir-if-possible-exclude");
// --blur-background
diff --git a/compton.h b/compton.h
index 11325b75c..cb16111a8 100644
--- a/compton.h
+++ b/compton.h
@@ -476,9 +476,10 @@ win_has_frame(const win *w) {
}
static inline void
-wid_set_opacity_prop(session_t *ps, Window wid, long val) {
+wid_set_opacity_prop(session_t *ps, Window wid, opacity_t val) {
+ const unsigned long v = val;
XChangeProperty(ps->dpy, wid, ps->atom_opacity, XA_CARDINAL, 32,
- PropModeReplace, (unsigned char *) &val, 1);
+ PropModeReplace, (unsigned char *) &v, 1);
}
static inline void