Merge pull request #840 from fwSmit/master

Small fixes
This commit is contained in:
Nikos Tsipinakis 2021-05-26 20:09:28 +02:00 committed by GitHub
commit cf091bea37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 81 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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,

View File

@ -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) {

View File

@ -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);
}

View File

@ -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");

View File

@ -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);

View File

@ -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;
}