From b75d35adb43efac49d40d3542de39a4f340b7065 Mon Sep 17 00:00:00 2001 From: fwsmit Date: Wed, 10 Mar 2021 23:27:11 +0100 Subject: [PATCH 1/8] queues: correctly sort notifications even when sort is false. The sort name is a bit misleading. It should actually be called sort_urgency or something. Notifications are still not sorted based on time, but ID. --- src/notification.c | 4 +-- test/queues.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/src/notification.c b/src/notification.c index b16d671..ffe01a2 100644 --- a/src/notification.c +++ b/src/notification.c @@ -192,7 +192,7 @@ const char *notification_urgency_to_string(const enum urgency urgency) /* see notification.h */ int notification_cmp(const struct notification *a, const struct notification *b) { - if (a->urgency != b->urgency) { + if (settings.sort && a->urgency != b->urgency) { return b->urgency - a->urgency; } else { return a->id - b->id; @@ -205,8 +205,6 @@ int notification_cmp_data(const void *va, const void *vb, void *data) struct notification *a = (struct notification *) va; struct notification *b = (struct notification *) vb; - ASSERT_OR_RET(settings.sort, 1); - return notification_cmp(a, b); } diff --git a/test/queues.c b/test/queues.c index b1c39b2..461a934 100644 --- a/test/queues.c +++ b/test/queues.c @@ -763,6 +763,68 @@ TEST test_queue_find_by_id(void) PASS(); } + +void print_queues() { + printf("\nQueues:\n"); + for (GList *iter = g_queue_peek_head_link(QUEUE_WAIT); iter; + iter = iter->next) { + struct notification *notif = iter->data; + printf("waiting %s\n", notif->summary); + } +} + +// Test if notifications are correctly sorted, even if dunst is paused in +// between. See #838 for the issue. +TEST test_queue_no_sort_and_pause(void) +{ + // Setting sort to false, this means that notifications will only be + // sorted based on time + settings.sort = false; + settings.geometry.h = 0; + struct notification *n; + queues_init(); + + n = test_notification("n0", 0); + queues_notification_insert(n); + queues_update(STATUS_NORMAL); + + n = test_notification("n1", 0); + queues_notification_insert(n); + queues_update(STATUS_NORMAL); + + n = test_notification("n2", 0); + queues_notification_insert(n); + queues_update(STATUS_PAUSE); + + n = test_notification("n3", 0); + queues_notification_insert(n); + queues_update(STATUS_PAUSE); + /* queues_update(STATUS_NORMAL); */ + + n = test_notification("n4", 0); + queues_notification_insert(n); + queues_update(STATUS_NORMAL); + + QUEUE_LEN_ALL(0, 5, 0); + + const char* order[] = { + "n0", + "n1", + "n2", + "n3", + "n4", + }; + + for (int i = 0; i < g_queue_get_length(QUEUE_DISP); i++) { + struct notification *notif = g_queue_peek_nth(QUEUE_DISP, i); + ASSERTm("Notifications are not in the right order", + STR_EQ(notif->summary, order[i])); + } + + queues_teardown(); + PASS(); +} + SUITE(suite_queues) { settings.icon_path = ""; @@ -794,6 +856,7 @@ SUITE(suite_queues) RUN_TEST(test_queues_update_xmore); RUN_TEST(test_queues_timeout_before_paused); RUN_TEST(test_queue_find_by_id); + RUN_TEST(test_queue_no_sort_and_pause); settings.icon_path = NULL; } From d65f69b4db9c396e3ccdcd2c643359acd3031a87 Mon Sep 17 00:00:00 2001 From: fwsmit Date: Tue, 16 Mar 2021 16:09:09 +0100 Subject: [PATCH 2/8] Work around glib bug for better test output --- test/dbus.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/dbus.c b/test/dbus.c index 5db9a7b..ffbe504 100644 --- a/test/dbus.c +++ b/test/dbus.c @@ -856,6 +856,10 @@ SUITE(suite_dbus) loop = g_main_loop_new(NULL, false); dbus_bus = g_test_dbus_new(G_TEST_DBUS_NONE); + + // workaround bug in glib where stdout output is duplicated + // See https://gitlab.gnome.org/GNOME/glib/-/issues/2322 + fflush(stdout); g_test_dbus_up(dbus_bus); thread_tests = g_thread_new("testexecutor", run_threaded_tests, loop); From 176aad4f3c04619019b967f232fdaf37d3de3656 Mon Sep 17 00:00:00 2001 From: fwsmit Date: Tue, 6 Apr 2021 19:01:18 +0200 Subject: [PATCH 3/8] input: Wake on action close_all This makes sure the window also gets updated after closing all notifications. Otherwise this actions seems to do nothing until dunst wakes up from something else. --- src/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/input.c b/src/input.c index 1495e4d..3683a63 100644 --- a/src/input.c +++ b/src/input.c @@ -38,7 +38,7 @@ void input_handle_click(unsigned int button, bool button_down, int mouse_x, int enum mouse_action act = acts[i]; if (act == MOUSE_CLOSE_ALL) { queues_history_push_all(); - return; + break; } if (act == MOUSE_DO_ACTION || act == MOUSE_CLOSE_CURRENT) { From 5c0d7ea66286aa6e613fc2a97246fe7cb2df7a85 Mon Sep 17 00:00:00 2001 From: fwsmit Date: Thu, 8 Apr 2021 17:44:13 +0200 Subject: [PATCH 4/8] docs: Update dependencies in README The Gtk3 dependencie was dropped #376, so we better remove it from the list --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 323a54f..a5a1ec5 100644 --- a/README.md +++ b/README.md @@ -78,13 +78,12 @@ distro's repositories, don't worry, it's not hard to build it yourself. ### Dependencies -- dbus +- dbus (runtime) - libxinerama - libxrandr - libxss - glib - pango/cairo -- libgtk-3-dev - libnotify (optional, for dunstify) - wayland-client (can build without, see [make parameters](#make-parameters)) - wayland-protocols (optional, for recompiling protocols) From c4e428e9d532447d86e5ab5c2b3a4141a613f072 Mon Sep 17 00:00:00 2001 From: fwsmit Date: Fri, 9 Apr 2021 16:25:06 +0200 Subject: [PATCH 5/8] build: Clean up docs/dunst.5 on make clean --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 6c1b0ff..21e1087 100644 --- a/Makefile +++ b/Makefile @@ -178,6 +178,7 @@ clean-dunstify: clean-doc: rm -f docs/dunst.1 + rm -f docs/dunst.5 rm -f docs/dunstctl.1 rm -fr docs/internal/html rm -fr docs/internal/coverage From 75af42c83a35ac632e440c88877712d20693611c Mon Sep 17 00:00:00 2001 From: fwsmit Date: Thu, 15 Apr 2021 18:35:37 +0200 Subject: [PATCH 6/8] doc: internal: Add note about the way tests are being compiled --- HACKING.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/HACKING.md b/HACKING.md index 68beb27..fa03638 100644 --- a/HACKING.md +++ b/HACKING.md @@ -15,6 +15,10 @@ - Add the comments to the prototype. Doxygen will merge the protoype and implementation documentation anyways. Except for **static** methods, add the documentation header to the implementation and *not to the prototype*. - Member documentation should happen with `/**<` and should span to the right side of the member +- Test files that have the same name as a file in src/\* can include the + associated .c file. This is because they are being compiled INSTEAD of the src + file. + ## Log messages From 7c6620c92d0d745c9dd2203d4475e0374aaa790b Mon Sep 17 00:00:00 2001 From: fwsmit Date: Tue, 20 Apr 2021 21:54:16 +0200 Subject: [PATCH 7/8] wayland: Remove accidental if statement --- src/wayland/wl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/wayland/wl.c b/src/wayland/wl.c index 4fae2f4..48f9e62 100644 --- a/src/wayland/wl.c +++ b/src/wayland/wl.c @@ -665,7 +665,6 @@ static void send_frame() { ctx.surface = wl_compositor_create_surface(ctx.compositor); wl_surface_add_listener(ctx.surface, &surface_listener, NULL); - if (settings.frame_color) ctx.layer_surface = zwlr_layer_shell_v1_get_layer_surface( ctx.layer_shell, ctx.surface, wl_output, settings.layer, "notifications"); From 1d3822ee8b2263be472e13ea685e7beb69071fb1 Mon Sep 17 00:00:00 2001 From: fwsmit Date: Tue, 6 Apr 2021 19:48:25 +0200 Subject: [PATCH 8/8] icon: Replace deprecated g_memdup with g_memdup2 where possible This avoids a potential conversion from gsize to guint and silences a warning. --- src/icon.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/icon.c b/src/icon.c index fdca559..d3d067d 100644 --- a/src/icon.c +++ b/src/icon.c @@ -347,7 +347,13 @@ GdkPixbuf *icon_get_for_data(GVariant *data, char **id) return NULL; } + // g_memdup is deprecated in glib 2.67.4 and higher. + // g_memdup2 is a safer alternative +#if GLIB_CHECK_VERSION(2,67,3) + data_pb = (guchar *) g_memdup2(g_variant_get_data(data_variant), len_actual); +#else data_pb = (guchar *) g_memdup(g_variant_get_data(data_variant), len_actual); +#endif pixbuf = gdk_pixbuf_new_from_data(data_pb, GDK_COLORSPACE_RGB,