summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Grenville <pyxlcy@gmail.com>2013-10-01 23:20:22 +0800
committerRichard Grenville <pyxlcy@gmail.com>2013-10-01 23:20:22 +0800
commit70dfd1f58e94ae63eb8d035a35c4002dcd5cc14a (patch)
treeccff40216e0ae736a45adca84b47c95f99cbdeea
parent7f97d55da55d44a018de2fb065ec3d4f63ab0307 (diff)
downloadtdebase-70dfd1f5.tar.gz
tdebase-70dfd1f5.zip
Bug fix #149: --opacity-rule misbehaves on 32-bit systems & others
- Fix a bug that --opacity-rule misbehaves with a value higher than 50% on 32-bit systems. Thanks to mrinx for reporting. (#149) - Fix a bug that opacity-rule in configuration file does not work.
-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