1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2024-11-25 14:06:08 -05:00

Merge pull request #454 from adelin-b/feat/shadowHex

add shadow-hex option
This commit is contained in:
yshui 2020-08-18 02:23:49 +01:00 committed by GitHub
commit f99be829d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 0 deletions

View file

@ -151,6 +151,9 @@ OPTIONS
*--shadow-exclude* 'CONDITION':: *--shadow-exclude* 'CONDITION'::
Specify a list of conditions of windows that should have no shadow. Specify a list of conditions of windows that should have no shadow.
*--shadow-hex* 'STRING'::
Color of shadow using hex string ('#000000')
*--fade-exclude* 'CONDITION':: *--fade-exclude* 'CONDITION'::
Specify a list of conditions of windows that should not be faded. Specify a list of conditions of windows that should not be faded.

View file

@ -44,6 +44,9 @@ shadow-offset-y = -7;
# Blue color value of shadow (0.0 - 1.0, defaults to 0). # Blue color value of shadow (0.0 - 1.0, defaults to 0).
# shadow-blue = 0 # shadow-blue = 0
# Hex string color value of shadow (#000000 - #FFFFFF, defaults to #000000). This option will override options set shadow-(red/green/blue)
# shadow-hex = "#000000"
# Do not paint shadows on shaped windows. Note shaped windows # Do not paint shadows on shaped windows. Note shaped windows
# here means windows setting its shape through X Shape extension. # here means windows setting its shape through X Shape extension.
# Those using ARGB background is beyond our control. # Those using ARGB background is beyond our control.

View file

@ -515,6 +515,7 @@ char *parse_config(options_t *opt, const char *config_file, bool *shadow_enable,
.sw_opti = false, .sw_opti = false,
.use_damage = true, .use_damage = true,
.shadow_hex = "#000000",
.shadow_red = 0.0, .shadow_red = 0.0,
.shadow_green = 0.0, .shadow_green = 0.0,
.shadow_blue = 0.0, .shadow_blue = 0.0,

View file

@ -140,6 +140,7 @@ typedef struct options {
// === Shadow === // === Shadow ===
/// 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;
char *shadow_hex;
int shadow_radius; int shadow_radius;
int shadow_offset_x, shadow_offset_y; int shadow_offset_x, shadow_offset_y;
double shadow_opacity; double shadow_opacity;

View file

@ -21,6 +21,21 @@
#pragma GCC diagnostic error "-Wunused-parameter" #pragma GCC diagnostic error "-Wunused-parameter"
/**
* Hex color to rgb
*/
struct color hex_to_rgb(const char *hex) {
struct color rgb;
// Ignore the # in front of the string
const char *sane_hex = hex + 1;
int hex_color = (int)strtol(sane_hex, NULL, 16);
rgb.red = (float)(hex_color >> 16) / 256;
rgb.green = (float)((hex_color & 0x00ff00) >> 8) / 256;
rgb.blue = (float)(hex_color & 0x0000ff) / 256;
return rgb;
}
/** /**
* Wrapper of libconfig's <code>config_lookup_int</code>. * Wrapper of libconfig's <code>config_lookup_int</code>.
* *
@ -410,6 +425,14 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
config_lookup_float(&cfg, "shadow-green", &opt->shadow_green); config_lookup_float(&cfg, "shadow-green", &opt->shadow_green);
// --shadow-blue // --shadow-blue
config_lookup_float(&cfg, "shadow-blue", &opt->shadow_blue); config_lookup_float(&cfg, "shadow-blue", &opt->shadow_blue);
// --shadow-hex
if (config_lookup_string(&cfg, "shadow-hex", &sval)) {
struct color rgb;
rgb = hex_to_rgb(sval);
opt->shadow_red = rgb.red;
opt->shadow_green = rgb.green;
opt->shadow_blue = rgb.blue;
}
// --shadow-exclude-reg // --shadow-exclude-reg
if (config_lookup_string(&cfg, "shadow-exclude-reg", &sval)) if (config_lookup_string(&cfg, "shadow-exclude-reg", &sval))
opt->shadow_exclude_reg_str = strdup(sval); opt->shadow_exclude_reg_str = strdup(sval);