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 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 diff --git a/README.md b/README.md index b165386..92d5d6d 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) 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, diff --git a/src/input.c b/src/input.c index dd2a796..d338c47 100644 --- a/src/input.c +++ b/src/input.c @@ -39,7 +39,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_CONTEXT_ALL) { diff --git a/src/notification.c b/src/notification.c index 86f97ce..2b132b1 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/src/wayland/wl.c b/src/wayland/wl.c index c6cd89a..cf12cca 100644 --- a/src/wayland/wl.c +++ b/src/wayland/wl.c @@ -667,7 +667,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"); diff --git a/test/dbus.c b/test/dbus.c index 70fa12d..086fe36 100644 --- a/test/dbus.c +++ b/test/dbus.c @@ -857,6 +857,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); 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; }