diff --git a/meson.build b/meson.build index c320f66..909084d 100644 --- a/meson.build +++ b/meson.build @@ -38,7 +38,6 @@ xkbcommon_dep = dependency('xkbcommon') libinput_dep = dependency('libinput') libwayland_client_dep = dependency('wayland-client') pcre2_dep = dependency('libpcre2-8') -libscenefx_dep = dependency('scenefx-0.4',version: '>=0.4.1') # 获取 Git Commit Hash 和最新的 tag @@ -76,7 +75,6 @@ executable('maomao', libm, xcb, xlibs, - libscenefx_dep, wayland_server_dep, wlroots_dep, xkbcommon_dep, diff --git a/src/animation/client.h b/src/animation/client.h index 1ebd25e..553b7d5 100644 --- a/src/animation/client.h +++ b/src/animation/client.h @@ -30,26 +30,6 @@ void apply_opacity_to_rect_nodes(Client *c, struct wlr_scene_node *node, } } -enum corner_location set_client_corner_location(Client *c) { - enum corner_location current_corner_location = CORNER_LOCATION_ALL; - struct wlr_box target_geom = animations ? c->animation.current : c->geom; - if (target_geom.x + border_radius <= c->mon->m.x) { - current_corner_location &= ~CORNER_LOCATION_LEFT; // 清除左标志位 - } - if (target_geom.x + target_geom.width - border_radius >= - c->mon->m.x + c->mon->m.width) { - current_corner_location &= ~CORNER_LOCATION_RIGHT; // 清除右标志位 - } - if (target_geom.y + border_radius <= c->mon->m.y) { - current_corner_location &= ~CORNER_LOCATION_TOP; // 清除上标志位 - } - if (target_geom.y + target_geom.height - border_radius >= - c->mon->m.y + c->mon->m.height) { - current_corner_location &= ~CORNER_LOCATION_BOTTOM; // 清除下标志位 - } - return current_corner_location; -} - int is_special_animaiton_rule(Client *c) { int visible_client_number = 0; Client *count_c; @@ -216,9 +196,6 @@ void scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, int sy, if (wlr_xdg_popup_try_from_wlr_surface(surface) != NULL) return; - wlr_scene_buffer_set_corner_radius(buffer, border_radius, - scale_data->corner_location); - float target_opacity = scale_data->percent + fadein_begin_opacity; if (target_opacity > scale_data->opacity) { target_opacity = scale_data->opacity; @@ -239,128 +216,26 @@ void buffer_set_effect(Client *c, animationScale data) { if (c == grabc) data.should_scale = false; - if (c->isfullscreen || (no_radius_when_single && c->mon && - c->mon->visible_tiling_clients == 1)) { - data.corner_location = CORNER_LOCATION_NONE; - } - wlr_scene_node_for_each_buffer(&c->scene_surface->node, scene_buffer_apply_effect, &data); } -void client_draw_shadow(Client *c) { +void apply_border(Client *c) { + bool hit_no_border = false; if (c->iskilling || !client_surface(c)->mapped) return; - if (!shadows || (!c->isfloating && shadow_only_floating)) { - wlr_scene_shadow_set_size(c->shadow, 0, 0); - return; - } + hit_no_border = check_hit_no_border(c); - bool hit_no_border = check_hit_no_border(c); - enum corner_location current_corner_location = - c->isfullscreen || (no_radius_when_single && c->mon && - c->mon->visible_tiling_clients == 1) - ? CORNER_LOCATION_NONE - : CORNER_LOCATION_ALL; - - unsigned int bwoffset = c->bw != 0 && hit_no_border ? c->bw : 0; - - uint32_t width, height; - client_actual_size(c, &width, &height); - - uint32_t delta = shadows_size + c->bw - bwoffset; - - /* we calculate where to clip the shadow */ - struct wlr_box client_box = { - .x = bwoffset, - .y = bwoffset, - .width = width - 2 * bwoffset, - .height = height - 2 * bwoffset, - }; - - struct wlr_box shadow_box = { - .x = shadows_position_x, - .y = shadows_position_y, - .width = width + 2 * delta, - .height = height + 2 * delta, - }; - - struct wlr_box intersection_box; - wlr_box_intersection(&intersection_box, &client_box, &shadow_box); - /* clipped region takes shadow relative coords, so we translate everything - * by its position */ - intersection_box.x -= shadows_position_x; - intersection_box.y -= shadows_position_y; - - struct clipped_region clipped_region = { - .area = intersection_box, - .corner_radius = border_radius, - .corners = current_corner_location, - }; - - struct wlr_box absolute_shadow_box = { - .x = shadow_box.x + c->animation.current.x, - .y = shadow_box.y + c->animation.current.y, - .width = shadow_box.width, - .height = shadow_box.height, - }; - - int right_offset, bottom_offset, left_offset, top_offset; - - if (c == grabc) { - right_offset = 0; - bottom_offset = 0; - left_offset = 0; - top_offset = 0; - } else { - right_offset = - GEZERO(absolute_shadow_box.x + absolute_shadow_box.width - - c->mon->m.x - c->mon->m.width); - bottom_offset = - GEZERO(absolute_shadow_box.y + absolute_shadow_box.height - - c->mon->m.y - c->mon->m.height); - - left_offset = GEZERO(c->mon->m.x - absolute_shadow_box.x); - top_offset = GEZERO(c->mon->m.y - absolute_shadow_box.y); - } - - left_offset = MIN(left_offset, shadow_box.width); - right_offset = MIN(right_offset, shadow_box.width); - top_offset = MIN(top_offset, shadow_box.height); - bottom_offset = MIN(bottom_offset, shadow_box.height); - - wlr_scene_node_set_position(&c->shadow->node, shadow_box.x + left_offset, - shadow_box.y + top_offset); - - wlr_scene_shadow_set_size( - c->shadow, GEZERO(shadow_box.width - left_offset - right_offset), - GEZERO(shadow_box.height - top_offset - bottom_offset)); - - clipped_region.area.x = clipped_region.area.x - left_offset; - clipped_region.area.y = clipped_region.area.y - top_offset; - - wlr_scene_shadow_set_clipped_region(c->shadow, clipped_region); -} - -void apply_border(Client *c) { - if (!c || c->iskilling || !client_surface(c)->mapped) - return; - - bool hit_no_border = check_hit_no_border(c); - enum corner_location current_corner_location = - c->isfullscreen || (no_radius_when_single && c->mon && - c->mon->visible_tiling_clients == 1) - ? CORNER_LOCATION_NONE - : CORNER_LOCATION_ALL; - - // Handle no-border cases if (hit_no_border && smartgaps) { c->bw = 0; c->fake_no_border = true; } else if (hit_no_border && !smartgaps) { - wlr_scene_rect_set_size(c->border, 0, 0); + set_rect_size(c->border[0], 0, 0); + set_rect_size(c->border[1], 0, 0); + set_rect_size(c->border[2], 0, 0); + set_rect_size(c->border[3], 0, 0); wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw); c->fake_no_border = true; return; @@ -369,7 +244,7 @@ void apply_border(Client *c) { c->fake_no_border = false; } - struct wlr_box clip_box = c->animation.current; + struct wlr_box fullgeom = c->animation.current; // 一但在GEZERO如果使用无符号,那么其他数据也会转换为无符号导致没有负数出错 int bw = (int)c->bw; @@ -392,49 +267,48 @@ void apply_border(Client *c) { top_offset = GEZERO(c->mon->m.y - c->animation.current.y); } - int inner_surface_width = GEZERO(clip_box.width - 2 * bw); - int inner_surface_height = GEZERO(clip_box.height - 2 * bw); + int border_up_width = GEZERO(fullgeom.width - left_offset - right_offset); + int border_up_height = + GEZERO(bw - top_offset - GEZERO(bottom_offset + bw - fullgeom.height)); - int inner_surface_x = GEZERO(bw - left_offset); - int inner_surface_y = GEZERO(bw - top_offset); + int border_down_width = GEZERO(fullgeom.width - left_offset - right_offset); + int border_down_height = + GEZERO(bw - bottom_offset - GEZERO(top_offset + bw - fullgeom.height)); - int rect_x = left_offset; - int rect_y = top_offset; + int border_left_width = + GEZERO(bw - left_offset - GEZERO(right_offset + bw - fullgeom.width)); + int border_left_height = + GEZERO(fullgeom.height - top_offset - bottom_offset); - int rect_width = - GEZERO(c->animation.current.width - left_offset - right_offset); - int rect_height = - GEZERO(c->animation.current.height - top_offset - bottom_offset); + int border_right_width = + GEZERO(bw - right_offset - GEZERO(left_offset + bw - fullgeom.width)); + int border_right_height = + GEZERO(fullgeom.height - top_offset - bottom_offset); - if (left_offset > c->bw) - inner_surface_width = inner_surface_width - left_offset + c->bw; + int border_up_x = GEZERO(left_offset); + int border_up_y = GEZERO(top_offset); - if (top_offset > c->bw) - inner_surface_height = inner_surface_height - top_offset + c->bw; + int border_down_x = GEZERO(left_offset); + int border_down_y = GEZERO(fullgeom.height - bw); - if (right_offset > 0) { - inner_surface_width = - MIN(clip_box.width, inner_surface_width + right_offset); - } + int border_left_x = GEZERO(left_offset); + int border_left_y = GEZERO(top_offset); - if (bottom_offset > 0) { - inner_surface_height = - MIN(clip_box.height, inner_surface_height + bottom_offset); - } - - struct clipped_region clipped_region = { - .area = {inner_surface_x, inner_surface_y, inner_surface_width, - inner_surface_height}, - .corner_radius = border_radius, - .corners = current_corner_location, - }; + int border_right_x = GEZERO(fullgeom.width - bw); + int border_right_y = GEZERO(top_offset); wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw); - wlr_scene_rect_set_size(c->border, rect_width, rect_height); - wlr_scene_node_set_position(&c->border->node, rect_x, rect_y); - wlr_scene_rect_set_corner_radius(c->border, border_radius, - current_corner_location); - wlr_scene_rect_set_clipped_region(c->border, clipped_region); + set_rect_size(c->border[0], border_up_width, border_up_height); + set_rect_size(c->border[1], border_down_width, border_down_height); + set_rect_size(c->border[2], border_left_width, border_left_height); + set_rect_size(c->border[3], border_right_width, border_right_height); + wlr_scene_node_set_position(&c->border[0]->node, border_up_x, border_up_y); + wlr_scene_node_set_position(&c->border[2]->node, border_left_x, + border_left_y); + wlr_scene_node_set_position(&c->border[1]->node, border_down_x, + border_down_y); + wlr_scene_node_set_position(&c->border[3]->node, border_right_x, + border_right_y); } struct ivec2 clip_to_hide(Client *c, struct wlr_box *clip_box) { @@ -511,9 +385,6 @@ void client_apply_clip(Client *c) { struct ivec2 offset; animationScale scale_data; - enum corner_location current_corner_location = - set_client_corner_location(c); - float percent = c->animation.action == OPEN && animation_fade_in && !c->nofadein ? (double)c->animation.passed_frames / c->animation.total_frames @@ -535,7 +406,6 @@ void client_apply_clip(Client *c) { offset = clip_to_hide(c, &clip_box); apply_border(c); - client_draw_shadow(c); scale_data.opacity = c->isfullscreen ? 1 : c == selmon->sel ? c->focused_opacity @@ -546,8 +416,8 @@ void client_apply_clip(Client *c) { } wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box); - buffer_set_effect(c, (animationScale){0, 0, 0, 0, opacity, opacity, - current_corner_location, false}); + buffer_set_effect( + c, (animationScale){0, 0, 0, 0, opacity, opacity, false}); return; } @@ -575,7 +445,6 @@ void client_apply_clip(Client *c) { // 应用窗口装饰 apply_border(c); - client_draw_shadow(c); // 如果窗口剪切区域已经剪切到0,则不渲染窗口表面 if (clip_box.width <= 0 || clip_box.height <= 0) { @@ -606,7 +475,6 @@ void client_apply_clip(Client *c) { scale_data.height = clip_box.height; scale_data.width_scale = (float)scale_data.width / acutal_surface_width; scale_data.height_scale = (float)scale_data.height / acutal_surface_height; - scale_data.corner_location = current_corner_location; scale_data.percent = percent; scale_data.opacity = opacity; buffer_set_effect(c, scale_data); @@ -938,7 +806,6 @@ void resize(Client *c, struct wlr_box geo, int interact) { c->geom; wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y); - client_draw_shadow(c); apply_border(c); client_get_clip(c, &clip); wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip); diff --git a/src/animation/common.h b/src/animation/common.h index 514165b..7ae68af 100644 --- a/src/animation/common.h +++ b/src/animation/common.h @@ -99,16 +99,15 @@ static bool scene_node_snapshot(struct wlr_scene_node *node, int lx, int ly, struct wlr_scene_node *snapshot_node = NULL; switch (node->type) { - case WLR_SCENE_NODE_TREE: { + case WLR_SCENE_NODE_TREE:; struct wlr_scene_tree *scene_tree = wlr_scene_tree_from_node(node); - struct wlr_scene_node *child; wl_list_for_each(child, &scene_tree->children, link) { scene_node_snapshot(child, lx, ly, snapshot_tree); } break; - } - case WLR_SCENE_NODE_RECT: { + case WLR_SCENE_NODE_RECT:; + struct wlr_scene_rect *scene_rect = wlr_scene_rect_from_node(node); struct wlr_scene_rect *snapshot_rect = @@ -118,20 +117,10 @@ static bool scene_node_snapshot(struct wlr_scene_node *node, int lx, int ly, if (snapshot_rect == NULL) { return false; } - - wlr_scene_rect_set_clipped_region(scene_rect, - snapshot_rect->clipped_region); - wlr_scene_rect_set_backdrop_blur(scene_rect, false); - // wlr_scene_rect_set_backdrop_blur_optimized( - // scene_rect, snapshot_rect->backdrop_blur_optimized); - wlr_scene_rect_set_corner_radius( - scene_rect, snapshot_rect->corner_radius, snapshot_rect->corners); - wlr_scene_rect_set_color(scene_rect, snapshot_rect->color); - snapshot_node = &snapshot_rect->node; break; - } - case WLR_SCENE_NODE_BUFFER: { + case WLR_SCENE_NODE_BUFFER:; + struct wlr_scene_buffer *scene_buffer = wlr_scene_buffer_from_node(node); @@ -156,15 +145,6 @@ static bool scene_node_snapshot(struct wlr_scene_node *node, int lx, int ly, // Effects wlr_scene_buffer_set_opacity(snapshot_buffer, scene_buffer->opacity); - wlr_scene_buffer_set_corner_radius(snapshot_buffer, - scene_buffer->corner_radius, - scene_buffer->corners); - - // wlr_scene_buffer_set_backdrop_blur_optimized( - // snapshot_buffer, scene_buffer->backdrop_blur_optimized); - // wlr_scene_buffer_set_backdrop_blur_ignore_transparent( - // snapshot_buffer, scene_buffer->backdrop_blur_ignore_transparent); - wlr_scene_buffer_set_backdrop_blur(snapshot_buffer, false); snapshot_buffer->node.data = scene_buffer->node.data; @@ -178,31 +158,6 @@ static bool scene_node_snapshot(struct wlr_scene_node *node, int lx, int ly, } break; } - case WLR_SCENE_NODE_SHADOW: { - struct wlr_scene_shadow *scene_shadow = - wlr_scene_shadow_from_node(node); - - struct wlr_scene_shadow *snapshot_shadow = wlr_scene_shadow_create( - snapshot_tree, scene_shadow->width, scene_shadow->height, - scene_shadow->corner_radius, scene_shadow->blur_sigma, - scene_shadow->color); - if (snapshot_shadow == NULL) { - return false; - } - snapshot_node = &snapshot_shadow->node; - - wlr_scene_shadow_set_clipped_region(snapshot_shadow, - scene_shadow->clipped_region); - - snapshot_shadow->node.data = scene_shadow->node.data; - - wlr_scene_node_set_enabled(&snapshot_shadow->node, false); - - break; - } - case WLR_SCENE_NODE_OPTIMIZED_BLUR: - return true; - } if (snapshot_node != NULL) { wlr_scene_node_set_position(snapshot_node, lx, ly); diff --git a/src/animation/layer.h b/src/animation/layer.h index bd3ccc5..9f71856 100644 --- a/src/animation/layer.h +++ b/src/animation/layer.h @@ -145,55 +145,6 @@ void set_layer_open_animaiton(LayerSurface *l, struct wlr_box geo) { } } -void layer_draw_shadow(LayerSurface *l) { - - if (!l->mapped || !l->shadow) - return; - - if (!shadows || !layer_shadows || l->noshadow) { - wlr_scene_shadow_set_size(l->shadow, 0, 0); - return; - } - - uint32_t width, height; - layer_actual_size(l, &width, &height); - - uint32_t delta = shadows_size; - - /* we calculate where to clip the shadow */ - struct wlr_box layer_box = { - .x = 0, - .y = 0, - .width = width, - .height = height, - }; - - struct wlr_box shadow_box = { - .x = shadows_position_x, - .y = shadows_position_y, - .width = width + 2 * delta, - .height = height + 2 * delta, - }; - - struct wlr_box intersection_box; - wlr_box_intersection(&intersection_box, &layer_box, &shadow_box); - /* clipped region takes shadow relative coords, so we translate everything - * by its position */ - intersection_box.x -= shadows_position_x; - intersection_box.y -= shadows_position_y; - - struct clipped_region clipped_region = { - .area = intersection_box, - .corner_radius = border_radius, - .corners = border_radius_location_default, - }; - - wlr_scene_node_set_position(&l->shadow->node, shadow_box.x, shadow_box.y); - - wlr_scene_shadow_set_size(l->shadow, shadow_box.width, shadow_box.height); - wlr_scene_shadow_set_clipped_region(l->shadow, clipped_region); -} - void fadeout_layer_animation_next_tick(LayerSurface *l) { if (!l) return; @@ -404,9 +355,7 @@ bool layer_draw_frame(LayerSurface *l) { if (animations && layer_animations && l->animation.running && !l->noanim) { layer_animation_next_tick(l); - layer_draw_shadow(l); } else { - layer_draw_shadow(l); l->need_output_flush = false; } return true; diff --git a/src/client/client.h b/src/client/client.h index 2bf3b8b..06aa8d9 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -308,7 +308,9 @@ static inline void client_send_close(Client *c) { static inline void client_set_border_color(Client *c, const float color[static 4]) { - wlr_scene_rect_set_color(c->border, color); + int i; + for (i = 0; i < 4; i++) + wlr_scene_rect_set_color(c->border[i], color); } static inline void client_set_fullscreen(Client *c, int fullscreen) { diff --git a/src/config/parse_config.h b/src/config/parse_config.h index cb9445b..3f1b6e2 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -125,9 +125,7 @@ typedef struct { typedef struct { char *layer_name; // 布局名称 - int noblur; int noanim; - int noshadow; } ConfigLayerRule; typedef struct { @@ -158,7 +156,6 @@ typedef struct { int focus_cross_monitor; int focus_cross_tag; int no_border_when_single; - int no_radius_when_single; int snap_distance; int enable_floating_snap; int drag_tile_to_tile; @@ -211,20 +208,6 @@ typedef struct { unsigned int send_events_mode; unsigned int button_map; - int blur; - int blur_layer; - int blur_optimized; - int border_radius; - struct blur_data blur_params; - int shadows; - int shadow_only_floating; - int layer_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; @@ -919,40 +902,6 @@ void parse_config_line(Config *config, const char *line) { 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, "blur_layer") == 0) { - config->blur_layer = atoi(value); - } else if (strcmp(key, "blur_optimized") == 0) { - config->blur_optimized = 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, "shadow_only_floating") == 0) { - config->shadow_only_floating = atoi(value); - } else if (strcmp(key, "layer_shadows") == 0) { - config->layer_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) { @@ -961,8 +910,6 @@ void parse_config_line(Config *config, const char *line) { config->syncobj_enable = atoi(value); } else if (strcmp(key, "no_border_when_single") == 0) { config->no_border_when_single = atoi(value); - } else if (strcmp(key, "no_radius_when_single") == 0) { - config->no_radius_when_single = atoi(value); } else if (strcmp(key, "snap_distance") == 0) { config->snap_distance = atoi(value); } else if (strcmp(key, "enable_floating_snap") == 0) { @@ -1210,13 +1157,6 @@ void parse_config_line(Config *config, const char *line) { 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) { @@ -1333,9 +1273,7 @@ void parse_config_line(Config *config, const char *line) { // 设置默认值 rule->layer_name = NULL; - rule->noblur = 0; rule->noanim = 0; - rule->noshadow = 0; char *token = strtok(value, ","); while (token != NULL) { @@ -1350,12 +1288,8 @@ void parse_config_line(Config *config, const char *line) { if (strcmp(key, "layer_name") == 0) { rule->layer_name = strdup(val); - } else if (strcmp(key, "noblur") == 0) { - rule->noblur = CLAMP_INT(atoi(val), 0, 1); } else if (strcmp(key, "noanim") == 0) { rule->noanim = CLAMP_INT(atoi(val), 0, 1); - } else if (strcmp(key, "noshadow") == 0) { - rule->noshadow = CLAMP_INT(atoi(val), 0, 1); } } token = strtok(NULL, ","); @@ -2166,7 +2100,6 @@ void override_config(void) { snap_distance = CLAMP_INT(config.snap_distance, 0, 99999); cursor_size = CLAMP_INT(config.cursor_size, 4, 512); no_border_when_single = CLAMP_INT(config.no_border_when_single, 0, 1); - no_radius_when_single = CLAMP_INT(config.no_radius_when_single, 0, 1); cursor_hide_timeout = CLAMP_INT(config.cursor_hide_timeout, 0, 36000); // 0-10小时 drag_tile_to_tile = CLAMP_INT(config.drag_tile_to_tile, 0, 1); @@ -2210,26 +2143,8 @@ 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); - blur_layer = CLAMP_INT(config.blur_layer, 0, 1); - blur_optimized = CLAMP_INT(config.blur_optimized, 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); - shadow_only_floating = CLAMP_INT(config.shadow_only_floating, 0, 1); - layer_shadows = CLAMP_INT(config.layer_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, -1000, 1000); - shadows_position_y = CLAMP_INT(config.shadows_position_y, -1000, 1000); 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)); @@ -2311,7 +2226,6 @@ void set_value_default() { config.xwayland_persistence = xwayland_persistence; config.syncobj_enable = syncobj_enable; config.no_border_when_single = no_border_when_single; - config.no_radius_when_single = no_radius_when_single; config.snap_distance = snap_distance; config.drag_tile_to_tile = drag_tile_to_tile; config.enable_floating_snap = enable_floating_snap; @@ -2351,26 +2265,8 @@ void set_value_default() { config.send_events_mode = send_events_mode; config.button_map = button_map; - config.blur = blur; - config.blur_layer = blur_layer; - config.blur_optimized = blur_optimized; - 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.shadow_only_floating = shadow_only_floating; - config.layer_shadows = layer_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)); @@ -2482,33 +2378,6 @@ 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.num_passes, blur_params.radius, - blur_params.noise, blur_params.brightness, blur_params.contrast, - blur_params.saturation); - } - } 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; @@ -2519,7 +2388,6 @@ void reload_config(const Arg *arg) { init_baked_points(); handlecursoractivity(); reset_keyboard_layout(); - reset_blur_params(); run_exec(); // reset border width when config change diff --git a/src/config/preset.h b/src/config/preset.h index ae854e7..b4c4b58 100644 --- a/src/config/preset.h +++ b/src/config/preset.h @@ -175,28 +175,3 @@ static const char *tags[] = { float focused_opacity = 1.0; float unfocused_opacity = 1.0; - -int border_radius = 0; -int border_radius_location_default = CORNER_LOCATION_ALL; -int blur = 0; -int blur_layer = 0; -int blur_optimized = 1; - -struct blur_data blur_params; - -int blur_params_num_passes = 1; -int blur_params_radius = 5; -float blur_params_noise = 0.02; -float blur_params_brightness = 0.9; -float blur_params_contrast = 0.9; -float blur_params_saturation = 1.2; - -int shadows = 0; -int shadow_only_floating = 1; -int layer_shadows = 0; -unsigned int shadows_size = 10; -double shadows_blur = 15; -int shadows_position_x = 0; -int shadows_position_y = 0; -float shadowscolor[] = COLOR(0x000000ff); -; diff --git a/src/maomao.c b/src/maomao.c index 61e471a..8b1c027 100644 --- a/src/maomao.c +++ b/src/maomao.c @@ -7,11 +7,6 @@ #include #include #include -#include -#include -#include -#include -#include #include #include #include @@ -61,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -132,7 +128,6 @@ enum { XDGShell, LayerShell, X11 }; /* client types */ enum { AxisUp, AxisDown, AxisLeft, AxisRight }; // 滚轮滚动的方向 enum { LyrBg, - LyrBlur, LyrBottom, LyrTile, LyrFloat, @@ -217,7 +212,6 @@ typedef struct { int height; double percent; float opacity; - enum corner_location corner_location; bool should_scale; } animationScale; @@ -229,8 +223,7 @@ struct Client { current; /* layout-relative, includes border */ Monitor *mon; struct wlr_scene_tree *scene; - struct wlr_scene_rect *border; /* top, bottom, left, right */ - struct wlr_scene_shadow *shadow; + struct wlr_scene_rect *border[4]; /* top, bottom, left, right */ struct wlr_scene_tree *scene_surface; struct wl_list link; struct wl_list flink; @@ -356,7 +349,6 @@ typedef struct { Monitor *mon; struct wlr_scene_tree *scene; struct wlr_scene_tree *popups; - struct wlr_scene_shadow *shadow; struct wlr_scene_layer_surface_v1 *scene_layer; struct wl_list link; struct wl_list fadeout_link; @@ -370,9 +362,7 @@ typedef struct { struct dwl_animation animation; bool dirty; - int noblur; int noanim; - int noshadow; bool need_output_flush; } LayerSurface; @@ -413,7 +403,6 @@ struct Monitor { int asleep; unsigned int visible_clients; unsigned int visible_tiling_clients; - struct wlr_scene_optimized_blur *blur; char last_surface_ws_name[256]; }; @@ -655,7 +644,6 @@ static double find_animation_curve_at(double t, int type); static void apply_opacity_to_rect_nodes(Client *c, struct wlr_scene_node *node, double animation_passed); -static enum corner_location set_client_corner_location(Client *c); static double output_frame_duration_ms(); static struct wlr_scene_tree * wlr_scene_tree_snapshot(struct wlr_scene_node *node, @@ -1151,7 +1139,7 @@ void gpureset(struct wl_listener *listener, void *data) { wlr_log(WLR_DEBUG, "gpu reset"); - if (!(drw = fx_renderer_create(backend))) + if (!(drw = wlr_renderer_autocreate(backend))) die("couldn't recreate renderer"); if (!(alloc = wlr_allocator_autocreate(backend, drw))) @@ -2430,10 +2418,6 @@ void cleanupmon(struct wl_listener *listener, void *data) { wlr_scene_output_destroy(m->scene_output); closemon(m); - if (m->blur) { - wlr_scene_node_destroy(&m->blur->node); - m->blur = NULL; - } free(m); } @@ -2474,23 +2458,6 @@ void closemon(Monitor *m) { } } -static void iter_layer_scene_buffers(struct wlr_scene_buffer *buffer, int sx, - int sy, void *user_data) { - struct wlr_scene_surface *scene_surface = - wlr_scene_surface_try_from_buffer(buffer); - if (!scene_surface) { - return; - } - - wlr_scene_buffer_set_backdrop_blur(buffer, true); - wlr_scene_buffer_set_backdrop_blur_ignore_transparent(buffer, true); - if (blur_optimized) { - wlr_scene_buffer_set_backdrop_blur_optimized(buffer, true); - } else { - wlr_scene_buffer_set_backdrop_blur_optimized(buffer, false); - } -} - void maplayersurfacenotify(struct wl_listener *listener, void *data) { LayerSurface *l = wl_container_of(listener, l, map); struct wlr_layer_surface_v1 *layer_surface = l->layer_surface; @@ -2510,8 +2477,6 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) { l->noanim = 0; l->dirty = false; - l->noblur = 0; - l->shadow = NULL; l->need_output_flush = true; // 应用layer规则 @@ -2520,28 +2485,12 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) { break; if (strcmp(config.layer_rules[ji].layer_name, l->layer_surface->namespace) == 0) { - if (config.layer_rules[ji].noblur > 0) { - l->noblur = 1; - } if (config.layer_rules[ji].noanim > 0) { l->noanim = 1; } - if (config.layer_rules[ji].noshadow > 0) { - l->noshadow = 1; - } } } - // 初始化阴影 - if (layer_surface->current.exclusive_zone == 0 && - layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM && - layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) { - l->shadow = wlr_scene_shadow_create(l->scene, 0, 0, border_radius, - shadows_blur, shadowscolor); - wlr_scene_node_lower_to_bottom(&l->shadow->node); - wlr_scene_node_set_enabled(&l->shadow->node, true); - } - // 初始化动画 if (animations && layer_animations && !l->noanim) { l->animation.action = OPEN; @@ -2597,29 +2546,6 @@ void commitlayersurfacenotify(struct wl_listener *listener, void *data) { layer_set_pending_state(l); } - if (blur && blur_layer) { - // 设置非背景layer模糊 - - if (!l->noblur && - layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM && - layer_surface->current.layer != - ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) { - - wlr_scene_node_for_each_buffer(&l->scene->node, - iter_layer_scene_buffers, l); - } - } - - if (blur) { - // 如果背景层发生变化,标记优化的模糊背景缓存需要更新 - if (layer_surface->current.layer == - ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) { - if (l->mon) { - wlr_scene_optimized_blur_mark_dirty(l->mon->blur); - } - } - } - if (layer_surface == exclusive_focus && layer_surface->current.keyboard_interactive != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE) @@ -3002,14 +2928,6 @@ void createmon(struct wl_listener *listener, void *data) { wlr_output_layout_add_auto(output_layout, wlr_output); else wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y); - - if (blur) { - m->blur = wlr_scene_optimized_blur_create(&scene->tree, 0, 0); - wlr_scene_node_set_position(&m->blur->node, m->m.x, m->m.y); - 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_node_set_enabled(&m->blur->node, 1); - } } void // fix for 0.5 @@ -3821,34 +3739,6 @@ void locksession(struct wl_listener *listener, void *data) { wlr_session_lock_v1_send_locked(session_lock); } -static void iter_xdg_scene_buffers(struct wlr_scene_buffer *buffer, int sx, - int sy, void *user_data) { - Client *c = user_data; - - struct wlr_scene_surface *scene_surface = - wlr_scene_surface_try_from_buffer(buffer); - if (!scene_surface) { - return; - } - - struct wlr_surface *surface = scene_surface->surface; - /* we dont blur subsurfaces */ - if (wlr_subsurface_try_from_wlr_surface(surface) != NULL) - return; - - if (blur && c) { - wlr_scene_buffer_set_backdrop_blur(buffer, true); - wlr_scene_buffer_set_backdrop_blur_ignore_transparent(buffer, true); - if (blur_optimized) { - wlr_scene_buffer_set_backdrop_blur_optimized(buffer, true); - } else { - wlr_scene_buffer_set_backdrop_blur_optimized(buffer, false); - } - } else { - wlr_scene_buffer_set_backdrop_blur(buffer, false); - } -} - void init_client_properties(Client *c) { c->ismaxmizescreen = 0; c->isfullscreen = 0; @@ -3884,6 +3774,7 @@ mapnotify(struct wl_listener *listener, void *data) { /* Called when the surface is mapped, or ready to display on-screen. */ Client *p = NULL; Client *c = wl_container_of(listener, c, map); + int i; /* Create scene tree for this client and its border */ c->scene = client_surface(c)->data = wlr_scene_tree_create(layers[LyrTile]); wlr_scene_node_set_enabled(&c->scene->node, c->type != XDGShell); @@ -3931,22 +3822,11 @@ mapnotify(struct wl_listener *listener, void *data) { return; } - c->border = wlr_scene_rect_create(c->scene, 0, 0, - c->isurgent ? urgentcolor : bordercolor); - wlr_scene_node_lower_to_bottom(&c->border->node); - wlr_scene_node_set_position(&c->border->node, 0, 0); - wlr_scene_rect_set_corner_radius(c->border, border_radius, - border_radius_location_default); - wlr_scene_node_set_enabled(&c->border->node, true); - - c->shadow = wlr_scene_shadow_create(c->scene, 0, 0, border_radius, - shadows_blur, shadowscolor); - - wlr_scene_node_lower_to_bottom(&c->shadow->node); - wlr_scene_node_set_enabled(&c->shadow->node, true); - - wlr_scene_node_for_each_buffer(&c->scene_surface->node, - iter_xdg_scene_buffers, c); + for (i = 0; i < 4; i++) { + c->border[i] = wlr_scene_rect_create( + c->scene, 0, 0, c->isurgent ? urgentcolor : bordercolor); + c->border[i]->node.data = c; + } /* Initialize client geometry with room for border */ client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | @@ -5345,8 +5225,8 @@ void setup(void) { wlr_scene_node_place_below(&drag_icon->node, &layers[LyrBlock]->node); /* Create a renderer with the default implementation */ - if (!(drw = fx_renderer_create(backend))) - die("couldn't create renderer"); + if (!(drw = wlr_renderer_autocreate(backend))) + die("couldn't recreate renderer"); wl_signal_add(&drw->events.lost, &gpu_reset); @@ -5538,11 +5418,6 @@ void setup(void) { wl_signal_add(&output_mgr->events.apply, &output_mgr_apply); wl_signal_add(&output_mgr->events.test, &output_mgr_test); - // blur - wlr_scene_set_blur_data(scene, blur_params.num_passes, blur_params.radius, - blur_params.noise, blur_params.brightness, - blur_params.contrast, blur_params.saturation); - /* create text_input-, and input_method-protocol relevant globals */ input_method_manager = wlr_input_method_manager_v2_create(dpy); text_input_manager = wlr_text_input_manager_v3_create(dpy); @@ -6226,11 +6101,6 @@ void updatemons(struct wl_listener *listener, void *data) { */ wlr_scene_output_set_position(m->scene_output, m->m.x, m->m.y); - if (blur && m->blur) { - wlr_scene_node_set_position(&m->blur->node, m->m.x, m->m.y); - wlr_scene_optimized_blur_set_size(m->blur, m->m.width, m->m.height); - } - if (m->lock_surface) { struct wlr_scene_tree *scene_tree = m->lock_surface->surface->data; wlr_scene_node_set_position(&scene_tree->node, m->m.x, m->m.y);