mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-11-09 13:29:54 -05:00
feat: scenefx blur shadow corner radius and opacity
This commit is contained in:
parent
d892b1048f
commit
55f82231a6
5 changed files with 588 additions and 230 deletions
|
|
@ -60,6 +60,8 @@ typedef struct {
|
|||
int noswallow;
|
||||
int scratchpad_width;
|
||||
int scratchpad_height;
|
||||
float focused_opacity;
|
||||
float unfocused_opacity;
|
||||
uint32_t passmod;
|
||||
xkb_keysym_t keysym;
|
||||
KeyBinding globalkeybinding;
|
||||
|
|
@ -151,6 +153,8 @@ typedef struct {
|
|||
int enable_floating_snap;
|
||||
int drag_tile_to_tile;
|
||||
unsigned int swipe_min_threshold;
|
||||
float focused_opacity;
|
||||
float unfocused_opacity;
|
||||
float *scroller_proportion_preset;
|
||||
int scroller_proportion_preset_count;
|
||||
|
||||
|
|
@ -192,6 +196,16 @@ typedef struct {
|
|||
unsigned int accel_profile;
|
||||
double accel_speed;
|
||||
|
||||
int blur;
|
||||
int border_radius;
|
||||
struct blur_data blur_params;
|
||||
int shadows;
|
||||
unsigned int shadows_size;
|
||||
float shadows_blur;
|
||||
int shadows_position_x;
|
||||
int shadows_position_y;
|
||||
float shadowscolor[4];
|
||||
|
||||
int smartgaps;
|
||||
unsigned int gappih;
|
||||
unsigned int gappiv;
|
||||
|
|
@ -866,6 +880,34 @@ void parse_config_line(Config *config, const char *line) {
|
|||
config->focus_cross_monitor = atoi(value);
|
||||
} else if (strcmp(key, "focus_cross_tag") == 0) {
|
||||
config->focus_cross_tag = atoi(value);
|
||||
} else if (strcmp(key, "focus_cross_tag") == 0) {
|
||||
config->focus_cross_tag = atoi(value);
|
||||
} else if (strcmp(key, "blur") == 0) {
|
||||
config->blur = atoi(value);
|
||||
} else if (strcmp(key, "border_radius") == 0) {
|
||||
config->border_radius = atoi(value);
|
||||
} else if (strcmp(key, "blur_params_num_passes") == 0) {
|
||||
config->blur_params.num_passes = atoi(value);
|
||||
} else if (strcmp(key, "blur_params_radius") == 0) {
|
||||
config->blur_params.radius = atoi(value);
|
||||
} else if (strcmp(key, "blur_params_noise") == 0) {
|
||||
config->blur_params.noise = atof(value);
|
||||
} else if (strcmp(key, "blur_params_brightness") == 0) {
|
||||
config->blur_params.brightness = atof(value);
|
||||
} else if (strcmp(key, "blur_params_contrast") == 0) {
|
||||
config->blur_params.contrast = atof(value);
|
||||
} else if (strcmp(key, "blur_params_saturation") == 0) {
|
||||
config->blur_params.saturation = atof(value);
|
||||
} else if (strcmp(key, "shadows") == 0) {
|
||||
config->shadows = atoi(value);
|
||||
} else if (strcmp(key, "shadows_size") == 0) {
|
||||
config->shadows_size = atoi(value);
|
||||
} else if (strcmp(key, "shadows_blur") == 0) {
|
||||
config->shadows_blur = atof(value);
|
||||
} else if (strcmp(key, "shadows_position_x") == 0) {
|
||||
config->shadows_position_x = atoi(value);
|
||||
} else if (strcmp(key, "shadows_position_y") == 0) {
|
||||
config->shadows_position_y = atoi(value);
|
||||
} else if (strcmp(key, "single_scratchpad") == 0) {
|
||||
config->single_scratchpad = atoi(value);
|
||||
} else if (strcmp(key, "xwayland_persistence") == 0) {
|
||||
|
|
@ -880,6 +922,10 @@ void parse_config_line(Config *config, const char *line) {
|
|||
config->drag_tile_to_tile = atoi(value);
|
||||
} else if (strcmp(key, "swipe_min_threshold") == 0) {
|
||||
config->swipe_min_threshold = atoi(value);
|
||||
} else if (strcmp(key, "focused_opacity") == 0) {
|
||||
config->focused_opacity = atof(value);
|
||||
} else if (strcmp(key, "unfocused_opacity") == 0) {
|
||||
config->unfocused_opacity = atof(value);
|
||||
} else if (strcmp(key, "xkb_rules_rules") == 0) {
|
||||
strncpy(xkb_rules_rules, value, sizeof(xkb_rules_rules) - 1);
|
||||
xkb_rules_rules[sizeof(xkb_rules_rules) - 1] =
|
||||
|
|
@ -1100,6 +1146,14 @@ void parse_config_line(Config *config, const char *line) {
|
|||
} else {
|
||||
convert_hex_to_rgba(config->rootcolor, color);
|
||||
}
|
||||
|
||||
} else if (strcmp(key, "shadowscolor") == 0) {
|
||||
long int color = parse_color(value);
|
||||
if (color == -1) {
|
||||
fprintf(stderr, "Error: Invalid shadowscolor format: %s\n", value);
|
||||
} else {
|
||||
convert_hex_to_rgba(config->shadowscolor, color);
|
||||
}
|
||||
} else if (strcmp(key, "bordercolor") == 0) {
|
||||
long int color = parse_color(value);
|
||||
if (color == -1) {
|
||||
|
|
@ -1229,6 +1283,8 @@ void parse_config_line(Config *config, const char *line) {
|
|||
rule->no_force_center = -1;
|
||||
rule->scratchpad_width = 0;
|
||||
rule->scratchpad_height = 0;
|
||||
rule->focused_opacity = 0;
|
||||
rule->unfocused_opacity = 0;
|
||||
rule->width = 0;
|
||||
rule->height = 0;
|
||||
rule->animation_type_open = NULL;
|
||||
|
|
@ -2010,6 +2066,23 @@ void override_config(void) {
|
|||
borderpx = CLAMP_INT(config.borderpx, 0, 200);
|
||||
smartgaps = CLAMP_INT(config.smartgaps, 0, 1);
|
||||
|
||||
blur = CLAMP_INT(config.blur, 0, 1);
|
||||
border_radius = CLAMP_INT(config.border_radius, 0, 100);
|
||||
blur_params.num_passes = CLAMP_INT(config.blur_params.num_passes, 0, 10);
|
||||
blur_params.radius = CLAMP_INT(config.blur_params.radius, 0, 100);
|
||||
blur_params.noise = CLAMP_FLOAT(config.blur_params.noise, 0, 1);
|
||||
blur_params.brightness = CLAMP_FLOAT(config.blur_params.brightness, 0, 1);
|
||||
blur_params.contrast = CLAMP_FLOAT(config.blur_params.contrast, 0, 1);
|
||||
blur_params.saturation = CLAMP_FLOAT(config.blur_params.saturation, 0, 1);
|
||||
shadows = CLAMP_INT(config.shadows, 0, 1);
|
||||
shadows_size = CLAMP_INT(config.shadows_size, 0, 100);
|
||||
shadows_blur = CLAMP_INT(config.shadows_blur, 0, 100);
|
||||
shadows_position_x = CLAMP_INT(config.shadows_position_x, 0, 100);
|
||||
shadows_position_y = CLAMP_INT(config.shadows_position_y, 0, 100);
|
||||
focused_opacity = CLAMP_FLOAT(config.focused_opacity, 0.0f, 1.0f);
|
||||
unfocused_opacity = CLAMP_FLOAT(config.unfocused_opacity, 0.0f, 1.0f);
|
||||
memcpy(shadowscolor, config.shadowscolor, sizeof(shadowscolor));
|
||||
|
||||
// 复制颜色数组
|
||||
memcpy(rootcolor, config.rootcolor, sizeof(rootcolor));
|
||||
memcpy(bordercolor, config.bordercolor, sizeof(bordercolor));
|
||||
|
|
@ -2120,6 +2193,23 @@ void set_value_default() {
|
|||
config.accel_profile = accel_profile;
|
||||
config.accel_speed = accel_speed;
|
||||
|
||||
config.blur = blur;
|
||||
config.border_radius = border_radius;
|
||||
config.blur_params.num_passes = blur_params_num_passes;
|
||||
config.blur_params.radius = blur_params_radius;
|
||||
config.blur_params.noise = blur_params_noise;
|
||||
config.blur_params.brightness = blur_params_brightness;
|
||||
config.blur_params.contrast = blur_params_contrast;
|
||||
config.blur_params.saturation = blur_params_saturation;
|
||||
config.shadows = shadows;
|
||||
config.shadows_size = shadows_size;
|
||||
config.shadows_blur = shadows_blur;
|
||||
config.shadows_position_x = shadows_position_x;
|
||||
config.shadows_position_y = shadows_position_y;
|
||||
config.focused_opacity = focused_opacity;
|
||||
config.unfocused_opacity = unfocused_opacity;
|
||||
memcpy(config.shadowscolor, shadowscolor, sizeof(shadowscolor));
|
||||
|
||||
memcpy(config.animation_curve_move, animation_curve_move,
|
||||
sizeof(animation_curve_move));
|
||||
memcpy(config.animation_curve_open, animation_curve_open,
|
||||
|
|
@ -2230,6 +2320,30 @@ void parse_config(void) {
|
|||
override_config();
|
||||
}
|
||||
|
||||
void reset_blur_params(void) {
|
||||
if (blur) {
|
||||
Monitor *m;
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
if (m->blur != NULL) {
|
||||
wlr_scene_node_destroy(&m->blur->node);
|
||||
}
|
||||
m->blur = wlr_scene_optimized_blur_create(&scene->tree, 0, 0);
|
||||
wlr_scene_node_reparent(&m->blur->node, layers[LyrBlur]);
|
||||
wlr_scene_optimized_blur_set_size(m->blur, m->m.width, m->m.height);
|
||||
wlr_scene_set_blur_data(scene, blur_params);
|
||||
}
|
||||
} else {
|
||||
Monitor *m;
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
|
||||
if (m->blur) {
|
||||
wlr_scene_node_destroy(&m->blur->node);
|
||||
m->blur = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void reload_config(const Arg *arg) {
|
||||
Client *c;
|
||||
Monitor *m;
|
||||
|
|
@ -2239,6 +2353,7 @@ void reload_config(const Arg *arg) {
|
|||
init_baked_points();
|
||||
handlecursoractivity();
|
||||
reset_keyboard_layout();
|
||||
reset_blur_params();
|
||||
run_exec();
|
||||
|
||||
// reset border width when config change
|
||||
|
|
@ -2246,6 +2361,8 @@ void reload_config(const Arg *arg) {
|
|||
if (c && !c->iskilling) {
|
||||
if (c->bw) {
|
||||
c->bw = borderpx;
|
||||
c->focused_opacity = focused_opacity;
|
||||
c->unfocused_opacity = unfocused_opacity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue