mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-03-23 05:35:53 -04:00
Merge 0e5e86b3f8 into 74d24c3cd9
This commit is contained in:
commit
7cc6a0c0b1
5 changed files with 101 additions and 64 deletions
|
|
@ -8,23 +8,27 @@ void set_rect_size(struct wlr_scene_rect *rect, int32_t width, int32_t height) {
|
|||
wlr_scene_rect_set_size(rect, GEZERO(width), GEZERO(height));
|
||||
}
|
||||
|
||||
enum corner_location set_client_corner_location(Client *c) {
|
||||
enum corner_location current_corner_location = CORNER_LOCATION_ALL;
|
||||
struct wlr_box target_geom =
|
||||
config.animations ? c->animation.current : c->geom;
|
||||
struct fx_corner_radii set_client_corner_location(Client *c) {
|
||||
struct fx_corner_radii current_corner_location =
|
||||
corner_radii_all(config.border_radius);
|
||||
struct wlr_box target_geom = config.animations ? c->animation.current : c->geom;
|
||||
if (target_geom.x + config.border_radius <= c->mon->m.x) {
|
||||
current_corner_location &= ~CORNER_LOCATION_LEFT;
|
||||
current_corner_location.top_left = 0; // 清除左标志位
|
||||
current_corner_location.bottom_left = 0; // 清除左标志位
|
||||
}
|
||||
if (target_geom.x + target_geom.width - config.border_radius >=
|
||||
c->mon->m.x + c->mon->m.width) {
|
||||
current_corner_location &= ~CORNER_LOCATION_RIGHT;
|
||||
current_corner_location.top_right = 0; // 清除右标志位
|
||||
current_corner_location.bottom_right = 0; // 清除右标志位
|
||||
}
|
||||
if (target_geom.y + config.border_radius <= c->mon->m.y) {
|
||||
current_corner_location &= ~CORNER_LOCATION_TOP;
|
||||
current_corner_location.top_left = 0; // 清除上标志位
|
||||
current_corner_location.top_right = 0; // 清除上标志位
|
||||
}
|
||||
if (target_geom.y + target_geom.height - config.border_radius >=
|
||||
c->mon->m.y + c->mon->m.height) {
|
||||
current_corner_location &= ~CORNER_LOCATION_BOTTOM;
|
||||
current_corner_location.bottom_left = 0; // 清除下标志位
|
||||
current_corner_location.bottom_right = 0; // 清除下标志位
|
||||
}
|
||||
return current_corner_location;
|
||||
}
|
||||
|
|
@ -226,8 +230,7 @@ void scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int32_t sx,
|
|||
if (wlr_xdg_popup_try_from_wlr_surface(surface) != NULL)
|
||||
return;
|
||||
|
||||
wlr_scene_buffer_set_corner_radius(buffer, config.border_radius,
|
||||
buffer_data->corner_location);
|
||||
wlr_scene_buffer_set_corner_radii(buffer, buffer_data->corner_location);
|
||||
}
|
||||
|
||||
void buffer_set_effect(Client *c, BufferData data) {
|
||||
|
|
@ -243,12 +246,14 @@ void buffer_set_effect(Client *c, BufferData data) {
|
|||
if (c == grabc)
|
||||
data.should_scale = false;
|
||||
|
||||
if (c->isnoradius || c->isfullscreen ||
|
||||
(config.no_radius_when_single && c->mon &&
|
||||
c->mon->visible_tiling_clients == 1)) {
|
||||
data.corner_location = CORNER_LOCATION_NONE;
|
||||
if (c->isfullscreen || (config.no_radius_when_single && c->mon &&
|
||||
c->mon->visible_tiling_clients == 1)) {
|
||||
data.corner_location = corner_radii_none();
|
||||
}
|
||||
|
||||
if (config.blur && !c->noblur) {
|
||||
wlr_scene_blur_set_corner_radii(c->blur, data.corner_location);
|
||||
}
|
||||
wlr_scene_node_for_each_buffer(&c->scene_surface->node,
|
||||
scene_buffer_apply_effect, &data);
|
||||
}
|
||||
|
|
@ -268,11 +273,11 @@ void client_draw_shadow(Client *c) {
|
|||
}
|
||||
|
||||
bool hit_no_border = check_hit_no_border(c);
|
||||
enum corner_location current_corner_location =
|
||||
struct fx_corner_radii current_corner_location =
|
||||
c->isfullscreen || (config.no_radius_when_single && c->mon &&
|
||||
c->mon->visible_tiling_clients == 1)
|
||||
? CORNER_LOCATION_NONE
|
||||
: CORNER_LOCATION_ALL;
|
||||
? corner_radii_none()
|
||||
: set_client_corner_location(c);
|
||||
|
||||
int32_t bwoffset = c->bw != 0 && hit_no_border ? (int32_t)c->bw : 0;
|
||||
|
||||
|
|
@ -302,7 +307,6 @@ void client_draw_shadow(Client *c) {
|
|||
|
||||
struct clipped_region clipped_region = {
|
||||
.area = intersection_box,
|
||||
.corner_radius = config.border_radius,
|
||||
.corners = current_corner_location,
|
||||
};
|
||||
|
||||
|
|
@ -350,18 +354,24 @@ void client_draw_shadow(Client *c) {
|
|||
wlr_scene_shadow_set_clipped_region(c->shadow, clipped_region);
|
||||
}
|
||||
|
||||
void client_draw_blur(Client *c, struct wlr_box clip_box, struct ivec2 offset) {
|
||||
if (config.blur && !c->noblur && c->blur) {
|
||||
wlr_scene_node_set_position(&c->blur->node, offset.x, offset.y);
|
||||
wlr_scene_blur_set_size(c->blur, clip_box.width - c->bw,
|
||||
clip_box.height - c->bw);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
if (c->isfullscreen || (config.no_radius_when_single && c->mon &&
|
||||
c->mon->visible_tiling_clients == 1)) {
|
||||
current_corner_location = CORNER_LOCATION_NONE;
|
||||
} else {
|
||||
current_corner_location = set_client_corner_location(c);
|
||||
}
|
||||
struct fx_corner_radii current_corner_location =
|
||||
c->isfullscreen || (config.no_radius_when_single && c->mon &&
|
||||
c->mon->visible_tiling_clients == 1)
|
||||
? corner_radii_none()
|
||||
: set_client_corner_location(c);
|
||||
|
||||
if (hit_no_border && config.smartgaps) {
|
||||
c->bw = 0;
|
||||
|
|
@ -434,15 +444,13 @@ void apply_border(Client *c) {
|
|||
struct clipped_region clipped_region = {
|
||||
.area = {inner_surface_x, inner_surface_y, inner_surface_width,
|
||||
inner_surface_height},
|
||||
.corner_radius = config.border_radius,
|
||||
.corners = current_corner_location,
|
||||
};
|
||||
|
||||
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, config.border_radius,
|
||||
current_corner_location);
|
||||
wlr_scene_rect_set_corner_radii(c->border, current_corner_location);
|
||||
wlr_scene_rect_set_clipped_region(c->border, clipped_region);
|
||||
}
|
||||
|
||||
|
|
@ -520,7 +528,7 @@ void client_apply_clip(Client *c, float factor) {
|
|||
struct ivec2 offset;
|
||||
BufferData buffer_data;
|
||||
|
||||
enum corner_location current_corner_location =
|
||||
struct fx_corner_radii current_corner_location =
|
||||
set_client_corner_location(c);
|
||||
|
||||
if (!config.animations) {
|
||||
|
|
@ -535,12 +543,14 @@ void client_apply_clip(Client *c, float factor) {
|
|||
|
||||
apply_border(c);
|
||||
client_draw_shadow(c);
|
||||
client_draw_blur(c, clip_box, offset);
|
||||
|
||||
if (clip_box.width <= 0 || clip_box.height <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box);
|
||||
|
||||
buffer_set_effect(c, (BufferData){1.0f, 1.0f, clip_box.width,
|
||||
clip_box.height,
|
||||
current_corner_location, true});
|
||||
|
|
@ -572,6 +582,7 @@ void client_apply_clip(Client *c, float factor) {
|
|||
// 应用窗口装饰
|
||||
apply_border(c);
|
||||
client_draw_shadow(c);
|
||||
client_draw_blur(c, clip_box, offset);
|
||||
|
||||
// 如果窗口剪切区域已经剪切到0,则不渲染窗口表面
|
||||
if (clip_box.width <= 0 || clip_box.height <= 0) {
|
||||
|
|
@ -1005,6 +1016,10 @@ void resize(Client *c, struct wlr_box geo, int32_t interact) {
|
|||
apply_border(c);
|
||||
client_get_clip(c, &clip);
|
||||
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
|
||||
if (config.blur && !c->noblur)
|
||||
wlr_scene_blur_set_size(c->blur,
|
||||
c->animation.current.width - 2 * c->bw,
|
||||
c->animation.current.height - 2 * c->bw);
|
||||
return;
|
||||
}
|
||||
// 如果不是工作区切换时划出去的窗口,就让动画的结束位置,就是上面的真实位置和大小
|
||||
|
|
@ -1124,6 +1139,16 @@ bool client_apply_focus_opacity(Client *c) {
|
|||
sizeof(c->opacity_animation.current_border_color));
|
||||
c->opacity_animation.current_opacity = target_opacity;
|
||||
client_set_opacity(c, target_opacity);
|
||||
if (config.blur && !c->noblur && !config.blur_optimized) {
|
||||
wlr_scene_blur_set_strength(
|
||||
c->blur, MIN(percent * (1.0 - config.fadein_begin_opacity) +
|
||||
config.fadein_begin_opacity,
|
||||
1.0));
|
||||
wlr_scene_blur_set_alpha(
|
||||
c->blur, MIN(percent * (1.0 - config.fadein_begin_opacity) +
|
||||
config.fadein_begin_opacity,
|
||||
1.0));
|
||||
}
|
||||
client_set_border_color(c, c->opacity_animation.target_border_color);
|
||||
} else if (config.animations && c->opacity_animation.running) {
|
||||
|
||||
|
|
|
|||
|
|
@ -175,15 +175,8 @@ static bool scene_node_snapshot(struct wlr_scene_node *node, int32_t lx,
|
|||
|
||||
// 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);
|
||||
wlr_scene_buffer_set_corner_radii(snapshot_buffer,
|
||||
scene_buffer->corners);
|
||||
|
||||
snapshot_buffer->node.data = scene_buffer->node.data;
|
||||
|
||||
|
|
@ -219,6 +212,8 @@ static bool scene_node_snapshot(struct wlr_scene_node *node, int32_t lx,
|
|||
|
||||
break;
|
||||
}
|
||||
case WLR_SCENE_NODE_BLUR:
|
||||
break;
|
||||
case WLR_SCENE_NODE_OPTIMIZED_BLUR:
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,8 +187,7 @@ void layer_draw_shadow(LayerSurface *l) {
|
|||
|
||||
struct clipped_region clipped_region = {
|
||||
.area = intersection_box,
|
||||
.corner_radius = config.border_radius,
|
||||
.corners = config.border_radius_location_default,
|
||||
.corners = corner_radii_all(config.border_radius),
|
||||
};
|
||||
|
||||
wlr_scene_node_set_position(&l->shadow->node, shadow_box.x, shadow_box.y);
|
||||
|
|
@ -328,9 +327,14 @@ void layer_animation_next_tick(LayerSurface *l) {
|
|||
opacity_eased_progress * (1.0 - config.fadein_begin_opacity),
|
||||
1.0f);
|
||||
|
||||
if (config.animation_fade_in)
|
||||
if (config.animation_fade_in) {
|
||||
if (config.blur && !l->noblur && !config.blur_optimized) {
|
||||
wlr_scene_blur_set_strength(l->blur, opacity);
|
||||
wlr_scene_blur_set_alpha(l->blur, opacity);
|
||||
}
|
||||
wlr_scene_node_for_each_buffer(&l->scene->node,
|
||||
scene_buffer_apply_opacity, &opacity);
|
||||
}
|
||||
|
||||
wlr_scene_node_set_position(&l->scene->node, x, y);
|
||||
|
||||
|
|
@ -358,6 +362,10 @@ void layer_animation_next_tick(LayerSurface *l) {
|
|||
.height = height,
|
||||
};
|
||||
|
||||
if (config.blur && config.blur_layer && !l->noblur && l->blur)
|
||||
wlr_scene_blur_set_size(l->blur, l->animation.current.width,
|
||||
l->animation.current.height);
|
||||
|
||||
if (animation_passed >= 1.0) {
|
||||
l->animation.running = false;
|
||||
l->need_output_flush = false;
|
||||
|
|
|
|||
|
|
@ -3363,7 +3363,6 @@ void set_value_default() {
|
|||
config.blur_layer = 0;
|
||||
config.blur_optimized = 1;
|
||||
config.border_radius = 0;
|
||||
config.border_radius_location_default = CORNER_LOCATION_ALL;
|
||||
config.blur_params.num_passes = 1;
|
||||
config.blur_params.radius = 5;
|
||||
config.blur_params.noise = 0.02f;
|
||||
|
|
|
|||
54
src/mango.c
54
src/mango.c
|
|
@ -11,7 +11,6 @@
|
|||
#include <scenefx/render/fx_renderer/fx_renderer.h>
|
||||
#include <scenefx/types/fx/blur_data.h>
|
||||
#include <scenefx/types/fx/clipped_region.h>
|
||||
#include <scenefx/types/fx/corner_location.h>
|
||||
#include <scenefx/types/wlr_scene.h>
|
||||
#include <signal.h>
|
||||
#include <stdbool.h>
|
||||
|
|
@ -301,7 +300,7 @@ typedef struct {
|
|||
float height_scale;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
enum corner_location corner_location;
|
||||
struct fx_corner_radii corner_location;
|
||||
bool should_scale;
|
||||
} BufferData;
|
||||
|
||||
|
|
@ -315,6 +314,7 @@ struct Client {
|
|||
struct wlr_scene_tree *scene;
|
||||
struct wlr_scene_rect *border; /* top, bottom, left, right */
|
||||
struct wlr_scene_shadow *shadow;
|
||||
struct wlr_scene_blur *blur;
|
||||
struct wlr_scene_tree *scene_surface;
|
||||
struct wl_list link;
|
||||
struct wl_list flink;
|
||||
|
|
@ -465,6 +465,7 @@ typedef struct {
|
|||
struct wlr_scene_tree *scene;
|
||||
struct wlr_scene_tree *popups;
|
||||
struct wlr_scene_shadow *shadow;
|
||||
struct wlr_scene_blur *blur;
|
||||
struct wlr_scene_layer_surface_v1 *scene_layer;
|
||||
struct wl_list link;
|
||||
struct wl_list fadeout_link;
|
||||
|
|
@ -763,7 +764,7 @@ static double find_animation_curve_at(double t, int32_t 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 struct fx_corner_radii set_client_corner_location(Client *c);
|
||||
static double all_output_frame_duration_ms();
|
||||
static struct wlr_scene_tree *
|
||||
wlr_scene_tree_snapshot(struct wlr_scene_node *node,
|
||||
|
|
@ -2377,12 +2378,16 @@ static void iter_layer_scene_buffers(struct wlr_scene_buffer *buffer,
|
|||
return;
|
||||
}
|
||||
|
||||
wlr_scene_buffer_set_backdrop_blur(buffer, true);
|
||||
wlr_scene_buffer_set_backdrop_blur_ignore_transparent(buffer, true);
|
||||
LayerSurface *l = (LayerSurface *)user_data;
|
||||
|
||||
wlr_scene_node_set_enabled(&l->blur->node, true);
|
||||
wlr_scene_blur_set_transparency_mask_source(l->blur, buffer);
|
||||
wlr_scene_blur_set_size(l->blur, l->geom.width, l->geom.height);
|
||||
|
||||
if (config.blur_optimized) {
|
||||
wlr_scene_buffer_set_backdrop_blur_optimized(buffer, true);
|
||||
wlr_scene_blur_set_should_only_blur_bottom_layer(l->blur, true);
|
||||
} else {
|
||||
wlr_scene_buffer_set_backdrop_blur_optimized(buffer, false);
|
||||
wlr_scene_blur_set_should_only_blur_bottom_layer(l->blur, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2440,14 +2445,17 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
|
||||
// 初始化阴影
|
||||
if (layer_surface->current.exclusive_zone == 0 &&
|
||||
layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM &&
|
||||
if (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, config.border_radius,
|
||||
config.shadows_blur, config.shadowscolor);
|
||||
wlr_scene_node_lower_to_bottom(&l->shadow->node);
|
||||
wlr_scene_node_set_enabled(&l->shadow->node, true);
|
||||
if (layer_surface->current.exclusive_zone == 0) {
|
||||
l->shadow = wlr_scene_shadow_create(l->scene, 0, 0, config.border_radius,
|
||||
config.shadows_blur, config.shadowscolor);
|
||||
wlr_scene_node_lower_to_bottom(&l->shadow->node);
|
||||
wlr_scene_node_set_enabled(&l->shadow->node, true);
|
||||
}
|
||||
|
||||
l->blur = wlr_scene_blur_create(l->scene, 0, 0);
|
||||
wlr_scene_node_lower_to_bottom(&l->blur->node);
|
||||
}
|
||||
|
||||
// 初始化动画
|
||||
|
|
@ -2519,7 +2527,8 @@ void commitlayersurfacenotify(struct wl_listener *listener, void *data) {
|
|||
if (!l->noblur &&
|
||||
layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM &&
|
||||
layer_surface->current.layer !=
|
||||
ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) {
|
||||
ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND &&
|
||||
l->blur) {
|
||||
|
||||
wlr_scene_node_for_each_buffer(&l->scene->node,
|
||||
iter_layer_scene_buffers, l);
|
||||
|
|
@ -3997,15 +4006,14 @@ static void iter_xdg_scene_buffers(struct wlr_scene_buffer *buffer, int32_t sx,
|
|||
return;
|
||||
|
||||
if (config.blur && c && !c->noblur) {
|
||||
wlr_scene_buffer_set_backdrop_blur(buffer, true);
|
||||
wlr_scene_buffer_set_backdrop_blur_ignore_transparent(buffer, false);
|
||||
wlr_scene_node_set_enabled(&c->blur->node, true);
|
||||
if (config.blur_optimized) {
|
||||
wlr_scene_buffer_set_backdrop_blur_optimized(buffer, true);
|
||||
wlr_scene_blur_set_should_only_blur_bottom_layer(c->blur, true);
|
||||
} else {
|
||||
wlr_scene_buffer_set_backdrop_blur_optimized(buffer, false);
|
||||
wlr_scene_blur_set_should_only_blur_bottom_layer(c->blur, false);
|
||||
}
|
||||
} else {
|
||||
wlr_scene_buffer_set_backdrop_blur(buffer, false);
|
||||
wlr_scene_node_set_enabled(&c->blur->node, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4155,14 +4163,16 @@ mapnotify(struct wl_listener *listener, void *data) {
|
|||
c->scene, 0, 0, c->isurgent ? config.urgentcolor : config.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, config.border_radius,
|
||||
config.border_radius_location_default);
|
||||
wlr_scene_rect_set_corner_radii(c->border, corner_radii_all(config.border_radius));
|
||||
wlr_scene_node_set_enabled(&c->border->node, true);
|
||||
|
||||
c->shadow =
|
||||
wlr_scene_shadow_create(c->scene, 0, 0, config.border_radius,
|
||||
config.shadows_blur, config.shadowscolor);
|
||||
|
||||
c->blur = wlr_scene_blur_create(c->scene_surface, 0, 0);
|
||||
wlr_scene_node_lower_to_bottom(&c->blur->node);
|
||||
|
||||
wlr_scene_node_lower_to_bottom(&c->shadow->node);
|
||||
wlr_scene_node_set_enabled(&c->shadow->node, true);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue