From 211e9bff8c9061a57ccd8adeb65a61fc0f849c20 Mon Sep 17 00:00:00 2001 From: Frantisek Bohacek Date: Sat, 3 Aug 2024 10:51:58 +0200 Subject: [PATCH] feat(mako): do not reapply config for already visible notifications --- home/modules/profiles/desktop/dwl/default.nix | 13 +++-- .../desktop/dwl/mako-keep-config.patch | 54 +++++++++++++++++++ 2 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 home/modules/profiles/desktop/dwl/mako-keep-config.patch diff --git a/home/modules/profiles/desktop/dwl/default.nix b/home/modules/profiles/desktop/dwl/default.nix index 703143e..d61775c 100644 --- a/home/modules/profiles/desktop/dwl/default.nix +++ b/home/modules/profiles/desktop/dwl/default.nix @@ -120,6 +120,11 @@ in { rutherther.programs.mako = { enable = true; + package = pkgs.mako.overrideAttrs { + patches = [ + ./mako-keep-config.patch + ]; + }; config = with config.themes.default; { default = { @@ -144,15 +149,9 @@ in { { conditions = { mode = "idle"; }; config = { - # Sadly this affects even existing notifications. - # It would be good if only those that actuallly came to - # be in this mode were colored with this border color. border-color = "#${background.secondary}FF"; ignore-timeout = 1; - # mako overrides already existing notifications - # if the default timeout is 0, whereas otherwise - # it will keep the current one. - default-timeout = 3 * 60 * 60 * 1000; + default-timeout = 0; }; } diff --git a/home/modules/profiles/desktop/dwl/mako-keep-config.patch b/home/modules/profiles/desktop/dwl/mako-keep-config.patch new file mode 100644 index 0000000..1b3ec0d --- /dev/null +++ b/home/modules/profiles/desktop/dwl/mako-keep-config.patch @@ -0,0 +1,54 @@ +From 7f98798f30f27cda30282d140bbe3627c71fdd20 Mon Sep 17 00:00:00 2001 +From: Rutherther +Date: Sat, 3 Aug 2024 10:43:08 +0200 +Subject: [PATCH] Do not reapply config for already rendered notifications on + mode + +This removes reapplying config when mode is changing, +and also on rendering, to prevent changing the notification's +settings when it's already displayed. This allows for modes +to change border's only of those notifications that are actually +sent in that mode. +--- + dbus/mako.c | 4 ---- + render.c | 2 +- + 2 files changed, 1 insertion(+), 5 deletions(-) + +diff --git a/dbus/mako.c b/dbus/mako.c +index 4c95881..6030473 100644 +--- a/dbus/mako.c ++++ b/dbus/mako.c +@@ -335,8 +335,6 @@ static int handle_set_mode(sd_bus_message *msg, void *data, + + set_modes(state, &mode, 1); + +- reapply_config(state); +- + return sd_bus_reply_method_return(msg, ""); + } + +@@ -428,8 +426,6 @@ static int handle_set_modes(sd_bus_message *msg, void *data, + + wl_array_release(&modes_arr); + +- reapply_config(state); +- + return sd_bus_reply_method_return(msg, ""); + } + +diff --git a/render.c b/render.c +index 5b68632..e734c15 100644 +--- a/render.c ++++ b/render.c +@@ -355,7 +355,7 @@ void render(struct mako_surface *surface, struct pool_buffer *buffer, int scale, + // Immediately before rendering we need to re-match all of the criteria + // so that matches against the anchor and output work even if the + // output was automatically assigned by the compositor. +- int rematch_count = apply_each_criteria(&state->config.criteria, notif); ++ int rematch_count = 1; + if (rematch_count == -1) { + // We encountered an allocation failure or similar while applying + // criteria. The notification may be partially matched, but the +-- +2.45.2 + -- 2.48.1