diff --git a/flake.lock b/flake.lock index 2917a6fd..6ed92805 100644 --- a/flake.lock +++ b/flake.lock @@ -18,6 +18,27 @@ "type": "github" } }, + "flake-utils": { + "inputs": { + "systems": [ + "scenefx", + "systems" + ] + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1750386251, @@ -58,16 +79,18 @@ }, "scenefx": { "inputs": { + "flake-utils": "flake-utils", "nixpkgs": [ "nixpkgs" - ] + ], + "systems": "systems" }, "locked": { - "lastModified": 1750785057, - "narHash": "sha256-tGX6j4W91rcb+glXJo43sjPI9zQvPotonknG1BdihR4=", + "lastModified": 1762447505, + "narHash": "sha256-VEBQ8KXkSS4c+kdAhmvq06lEd9WNeCXdRK1U+qSilFw=", "owner": "wlrfx", "repo": "scenefx", - "rev": "3a6cfb12e4ba97b43326357d14f7b3e40897adfc", + "rev": "7f9e7409f6169fa637f1265895c121a8f8b70272", "type": "github" }, "original": { @@ -75,6 +98,21 @@ "repo": "scenefx", "type": "github" } + }, + "systems": { + "locked": { + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "owner": "nix-systems", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-linux", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index b7158bbd..0207cd49 100644 --- a/flake.nix +++ b/flake.nix @@ -25,12 +25,13 @@ perSystem = { config, + system, pkgs, ... }: let - inherit (pkgs) callPackage ; + inherit (pkgs) callPackage; mango = callPackage ./nix { - inherit (inputs.scenefx.packages.${pkgs.stdenv.hostPlatform.system}) scenefx; + scenefx = inputs.scenefx.packages.${system}.default; }; shellOverride = old: { nativeBuildInputs = old.nativeBuildInputs ++ []; diff --git a/src/animation/client.h b/src/animation/client.h index 56ca3d66..aa88ea28 100644 --- a/src/animation/client.h +++ b/src/animation/client.h @@ -246,6 +246,10 @@ void buffer_set_effect(Client *c, BufferData data) { data.corner_location = CORNER_LOCATION_NONE; } + if (blur && !c->noblur) { + wlr_scene_blur_set_corner_radius(c->blur, border_radius, + data.corner_location); + } wlr_scene_node_for_each_buffer(&c->scene_surface->node, scene_buffer_apply_effect, &data); } @@ -350,6 +354,19 @@ 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 (blur && !c->noblur) { + if (c->scene_surface->node.enabled && !c->blur->node.enabled) + 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 { + if (c->blur->node.enabled) + wlr_scene_node_set_enabled(&c->blur->node, false); + } +} + void apply_border(Client *c) { if (!c || c->iskilling || !client_surface(c)->mapped) return; @@ -534,12 +551,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}); @@ -571,6 +590,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) { @@ -999,6 +1019,10 @@ void resize(Client *c, struct wlr_box geo, int interact) { apply_border(c); client_get_clip(c, &clip); wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip); + if (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; } // 如果不是工作区切换时划出去的窗口,就让动画的结束位置,就是上面的真实位置和大小 diff --git a/src/animation/common.h b/src/animation/common.h index 6e6fa048..3c8d253b 100644 --- a/src/animation/common.h +++ b/src/animation/common.h @@ -178,12 +178,6 @@ static bool scene_node_snapshot(struct wlr_scene_node *node, int lx, int ly, 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; struct wlr_scene_surface *scene_surface = @@ -218,6 +212,8 @@ static bool scene_node_snapshot(struct wlr_scene_node *node, int lx, int ly, break; } + case WLR_SCENE_NODE_BLUR: + break; case WLR_SCENE_NODE_OPTIMIZED_BLUR: return true; } diff --git a/src/animation/layer.h b/src/animation/layer.h index 141f1320..0699eac2 100644 --- a/src/animation/layer.h +++ b/src/animation/layer.h @@ -362,6 +362,10 @@ void layer_animation_next_tick(LayerSurface *l) { .height = height, }; + if (blur && 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; diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 460d997b..2b7911e8 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -973,6 +973,10 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, func = spawn_on_empty; (*arg).v = strdup(arg_value); // 注意:之后需要释放这个内存 (*arg).ui = 1 << (atoi(arg_value2) - 1); + } else if (strcmp(func_name, "comboview_spawn_on_empty") == 0) { + func = comboview_spawn_on_empty; + (*arg).v = strdup(arg_value); // 注意:之后需要释放这个内存 + (*arg).ui = 1 << (atoi(arg_value2) - 1); } else if (strcmp(func_name, "quit") == 0) { func = quit; } else if (strcmp(func_name, "create_virtual_output") == 0) { diff --git a/src/dispatch/bind_declare.h b/src/dispatch/bind_declare.h index 5bc215a2..111db1e6 100644 --- a/src/dispatch/bind_declare.h +++ b/src/dispatch/bind_declare.h @@ -23,6 +23,7 @@ int tagmon(const Arg *arg); int spawn(const Arg *arg); int spawn_shell(const Arg *arg); int spawn_on_empty(const Arg *arg); +int comboview_spawn_on_empty(const Arg *arg); int setkeymode(const Arg *arg); int switch_keyboard_layout(const Arg *arg); int setlayout(const Arg *arg); @@ -68,4 +69,4 @@ int toggle_trackpad_enable(const Arg *arg); int setoption(const Arg *arg); int disable_monitor(const Arg *arg); int enable_monitor(const Arg *arg); -int toggle_monitor(const Arg *arg); \ No newline at end of file +int toggle_monitor(const Arg *arg); diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index 96609dd0..067e9111 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -831,6 +831,40 @@ int spawn_on_empty(const Arg *arg) { return 0; } +int comboview_spawn_on_empty(const Arg *arg) { + unsigned int newtags = arg->ui & TAGMASK; + bool is_empty = true; + Client *c = NULL; + + if (!newtags || !selmon) + return 0; + + wl_list_for_each(c, &clients, link) { + if (arg->ui & c->tags && c->mon == selmon) { + is_empty = false; + break; + } + } + + if (tag_combo) { + selmon->tagset[selmon->seltags] |= newtags; + focusclient(focustop(selmon), 1); + arrange(selmon, false); + } else { + tag_combo = true; + view(&(Arg){.ui = newtags}, false); + } + if (is_empty) { + unsigned int old = selmon->tagset[selmon->seltags]; + selmon->tagset[selmon->seltags] = newtags; + spawn(arg); + selmon->tagset[selmon->seltags] = old; + } + + printstatus(); + return 0; +} + int switch_keyboard_layout(const Arg *arg) { if (!kb_group || !kb_group->wlr_group || !seat) { wlr_log(WLR_ERROR, "Invalid keyboard group or seat"); diff --git a/src/mango.c b/src/mango.c index 2c7e8753..32de6ac4 100644 --- a/src/mango.c +++ b/src/mango.c @@ -307,6 +307,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; @@ -450,6 +451,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; @@ -2166,12 +2168,16 @@ static void iter_layer_scene_buffers(struct wlr_scene_buffer *buffer, int sx, 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 (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); } } @@ -2216,13 +2222,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, border_radius, - shadows_blur, 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, border_radius, + shadows_blur, 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); } // 初始化动画 @@ -2286,7 +2296,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); @@ -3674,15 +3685,15 @@ static void iter_xdg_scene_buffers(struct wlr_scene_buffer *buffer, int sx, return; if (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); + // wlr_scene_blur_set_transparency_mask_source(c->blur, buffer); if (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); } } @@ -3805,6 +3816,9 @@ mapnotify(struct wl_listener *listener, void *data) { c->shadow = wlr_scene_shadow_create(c->scene, 0, 0, border_radius, shadows_blur, 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);