blob: 0745dd05a0bdd2da28b6c18018712c1586c637fe [file] [log] [blame]
Skyler Grey51a0c612022-11-05 09:59:04 +00001diff --git a/src/config.c b/src/config.c
2index d9b2dd9..0eb49de 100644
3--- a/src/config.c
4+++ b/src/config.c
5@@ -755,6 +755,7 @@ char *parse_config(options_t *opt, const char *config_file, bool *shadow_enable,
6 .fade_in_step = 0.028,
7 .fade_out_step = 0.03,
8 .fade_delta = 10,
9+ .no_fading_larger_than = 0,
10 .no_fading_openclose = false,
11 .no_fading_destroyed_argb = false,
12 .fade_blacklist = NULL,
13diff --git a/src/config.h b/src/config.h
14index 7259dc1..a555be7 100644
15--- a/src/config.h
16+++ b/src/config.h
17@@ -165,6 +165,8 @@ typedef struct options {
18 double fade_out_step;
19 /// Fading time delta. In milliseconds.
20 int fade_delta;
21+ /// The maximum opacity change to fade on.
22+ double no_fading_larger_than;
23 /// Whether to disable fading on window open/close.
24 bool no_fading_openclose;
25 /// Whether to disable fading on ARGB managed destroyed windows.
26diff --git a/src/config_libconfig.c b/src/config_libconfig.c
27index 461fff3..1e008c2 100644
28--- a/src/config_libconfig.c
29+++ b/src/config_libconfig.c
30@@ -351,6 +351,8 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
31 // -f (fading_enable)
32 if (config_lookup_bool(&cfg, "fading", &ival))
33 *fading_enable = ival;
34+ // --no-fading-larger-than
35+ config_lookup_float(&cfg, "no-fading-larger-than", &opt->no_fading_larger_than);
36 // --no-fading-open-close
37 lcfg_lookup_bool(&cfg, "no-fading-openclose", &opt->no_fading_openclose);
38 // --no-fading-destroyed-argb
39diff --git a/src/dbus.c b/src/dbus.c
40index 8b17b30..59d527e 100644
41--- a/src/dbus.c
42+++ b/src/dbus.c
43@@ -1289,6 +1289,15 @@ static bool cdbus_process_opts_set(session_t *ps, DBusMessage *msg) {
44 goto cdbus_process_opts_set_success;
45 }
46
47+ // no_fading_larger_than
48+ if (!strcmp("no_fading_larger_than", target)) {
49+ double val = 0.0;
50+ if (!cdbus_msg_get_arg(msg, 1, DBUS_TYPE_DOUBLE, &val))
51+ return false;
52+ ps->o.no_fading_larger_than = normalize_d(val);
53+ goto cdbus_process_opts_set_success;
54+ }
55+
56 // no_fading_openclose
57 if (!strcmp("no_fading_openclose", target)) {
58 dbus_bool_t val = FALSE;
59diff --git a/src/options.c b/src/options.c
60index ba7485d..69e1a40 100644
61--- a/src/options.c
62+++ b/src/options.c
63@@ -175,6 +175,7 @@ static const struct picom_option picom_options[] = {
64 "you want to attach a debugger to picom"},
65 {"no-ewmh-fullscreen" , no_argument , 803, NULL , "Do not use EWMH to detect fullscreen windows. Reverts to checking if a "
66 "window is fullscreen based only on its size and coordinates."},
67+ {"no-fading-larger-than" , required_argument, 804, NULL , "do not fade when the opacity difference would be larger than this value"},
68 };
69 // clang-format on
70
71@@ -402,6 +403,7 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
72 // These options are handled by get_early_config()
73 break;
74 P_CASEINT('D', fade_delta);
75+ case 804: opt->no_fading_larger_than = normalize_d(atof(optarg)); break;
76 case 'I': opt->fade_in_step = normalize_d(atof(optarg)); break;
77 case 'O': opt->fade_out_step = normalize_d(atof(optarg)); break;
78 case 'c': shadow_enable = true; break;
79diff --git a/src/picom.c b/src/picom.c
80index fd693fc..1a475c5 100644
81--- a/src/picom.c
82+++ b/src/picom.c
83@@ -992,7 +992,6 @@ void force_repaint(session_t *ps) {
84 /** @name DBus hooks
85 */
86 ///@{
87-
88 /**
89 * Set no_fading_openclose option.
90 *
91diff --git a/src/win.c b/src/win.c
92index 370fbfd..baea80b 100644
93--- a/src/win.c
94+++ b/src/win.c
95@@ -864,6 +864,10 @@ bool win_should_fade(session_t *ps, const struct managed_win *w) {
96 if (w->fade_force != UNSET) {
97 return w->fade_force;
98 }
99+ if (ps->o.no_fading_larger_than &&
100+ ps->o.no_fading_larger_than < fabs(w->opacity - w->opacity_target)) {
101+ return false;
102+ }
103 if (ps->o.no_fading_openclose && w->in_openclose) {
104 return false;
105 }