mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-06-19 14:33:16 -04:00
version: chase wlroots 0.20
This commit is contained in:
parent
adc1239075
commit
0fc7559c3c
13 changed files with 330 additions and 1208 deletions
|
|
@ -9,23 +9,28 @@ 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 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;
|
||||
}
|
||||
|
|
@ -235,8 +240,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 scene_buffer_apply_overview_effect(struct wlr_scene_buffer *buffer,
|
||||
|
|
@ -268,8 +272,7 @@ void scene_buffer_apply_overview_effect(struct wlr_scene_buffer *buffer,
|
|||
if (is_subsurface)
|
||||
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) {
|
||||
|
|
@ -285,10 +288,13 @@ 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);
|
||||
}
|
||||
|
||||
if (c->overview_scene_surface) {
|
||||
|
|
@ -316,11 +322,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;
|
||||
|
||||
|
|
@ -350,7 +356,6 @@ void client_draw_shadow(Client *c) {
|
|||
|
||||
struct clipped_region clipped_region = {
|
||||
.area = intersection_box,
|
||||
.corner_radius = config.border_radius,
|
||||
.corners = current_corner_location,
|
||||
};
|
||||
|
||||
|
|
@ -398,6 +403,46 @@ void client_draw_shadow(Client *c) {
|
|||
wlr_scene_shadow_set_clipped_region(c->shadow, clipped_region);
|
||||
}
|
||||
|
||||
void apply_shield(Client *c, struct wlr_box clip_box) {
|
||||
|
||||
if (clip_box.width <= 0 || clip_box.height <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (active_capture_count > 0 && c->shield_when_capture) {
|
||||
wlr_scene_node_raise_to_top(&c->shield->node);
|
||||
wlr_scene_node_set_position(&c->shield->node, clip_box.x, clip_box.y);
|
||||
wlr_scene_rect_set_size(c->shield, clip_box.width, clip_box.height);
|
||||
wlr_scene_node_set_enabled(&c->shield->node, true);
|
||||
} else {
|
||||
if (c->shield->node.enabled) {
|
||||
wlr_scene_node_lower_to_bottom(&c->shield->node);
|
||||
wlr_scene_rect_set_size(c->shield, c->animation.current.width,
|
||||
c->animation.current.height);
|
||||
wlr_scene_node_set_enabled(&c->shield->node, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void client_draw_blur(Client *c, struct wlr_box clip_box, struct ivec2 offset) {
|
||||
|
||||
if (c->isfullscreen) {
|
||||
if (c->blur->node.enabled) {
|
||||
wlr_scene_node_set_enabled(&c->blur->node, false);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
if (config.blur && !c->noblur) {
|
||||
wlr_scene_node_set_enabled(&c->blur->node, true);
|
||||
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);
|
||||
} else {
|
||||
wlr_scene_node_set_enabled(&c->blur->node, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void global_draw_tab_bar(Client *c, int32_t x, int32_t y, int32_t width,
|
||||
int32_t height) {
|
||||
if (!c->tab_bar_node)
|
||||
|
|
@ -509,7 +554,8 @@ void apply_border(Client *c) {
|
|||
|
||||
if (c->isfullscreen) {
|
||||
if (c->border->node.enabled) {
|
||||
wlr_scene_node_set_position(&c->scene_surface->node, 0, 0);
|
||||
wlr_scene_node_set_enabled(&c->splitindicator[0]->node, false);
|
||||
wlr_scene_node_set_enabled(&c->splitindicator[1]->node, false);
|
||||
wlr_scene_node_set_enabled(&c->border->node, false);
|
||||
}
|
||||
return;
|
||||
|
|
@ -520,16 +566,13 @@ void apply_border(Client *c) {
|
|||
}
|
||||
|
||||
bool hit_no_border = check_hit_no_border(c);
|
||||
|
||||
apply_split_border(c, hit_no_border);
|
||||
|
||||
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;
|
||||
|
|
@ -602,15 +645,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);
|
||||
}
|
||||
|
||||
|
|
@ -882,7 +923,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 && !c->overview_scene_surface) {
|
||||
|
|
@ -897,6 +938,8 @@ void client_apply_clip(Client *c, float factor) {
|
|||
|
||||
apply_border(c);
|
||||
client_draw_shadow(c);
|
||||
client_draw_blur(c, clip_box, offset);
|
||||
apply_shield(c, clip_box);
|
||||
|
||||
if (clip_box.width <= 0 || clip_box.height <= 0) {
|
||||
return;
|
||||
|
|
@ -938,6 +981,8 @@ void client_apply_clip(Client *c, float factor) {
|
|||
// 应用窗口装饰
|
||||
apply_border(c);
|
||||
client_draw_shadow(c);
|
||||
apply_shield(c, clip_box);
|
||||
client_draw_blur(c, clip_box, offset);
|
||||
|
||||
// 如果窗口剪切区域已经剪切到0,则不渲染窗口表面
|
||||
if (clip_box.width <= 0 || clip_box.height <= 0) {
|
||||
|
|
@ -1135,6 +1180,10 @@ void init_fadeout_client(Client *c) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (c->shield_when_capture && active_capture_count > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((c->animation_type_close &&
|
||||
strcmp(c->animation_type_close, "none") == 0) ||
|
||||
(!c->animation_type_close &&
|
||||
|
|
@ -1379,10 +1428,15 @@ void resize(Client *c, struct wlr_box geo, int32_t 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);
|
||||
apply_shield(c, clip);
|
||||
client_draw_shadow(c);
|
||||
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;
|
||||
}
|
||||
// 如果不是工作区切换时划出去的窗口,就让动画的结束位置,就是上面的真实位置和大小
|
||||
|
|
@ -1512,6 +1566,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) {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue