summaryrefslogtreecommitdiffstats
path: root/src/apoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/apoint.c')
-rw-r--r--src/apoint.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/apoint.c b/src/apoint.c
index 1c9aa23..cb23ead 100644
--- a/src/apoint.c
+++ b/src/apoint.c
@@ -84,9 +84,18 @@ void apoint_llist_free(void)
LLIST_TS_FREE(&alist_p);
}
-static int apoint_cmp_start(struct apoint *a, struct apoint *b)
+static int apoint_cmp(struct apoint *a, struct apoint *b)
{
- return a->start < b->start ? -1 : (a->start == b->start ? 0 : 1);
+ if (a->start < b->start)
+ return -1;
+ if (a->start > b->start)
+ return 1;
+ if ((a->state & APOINT_NOTIFY) && !(b->state & APOINT_NOTIFY))
+ return -1;
+ if (!(a->state & APOINT_NOTIFY) && (b->state & APOINT_NOTIFY))
+ return 1;
+
+ return strcmp(a->mesg, b->mesg);
}
struct apoint *apoint_new(char *mesg, char *note, long start, long dur,
@@ -102,7 +111,7 @@ struct apoint *apoint_new(char *mesg, char *note, long start, long dur,
apt->dur = dur;
LLIST_TS_LOCK(&alist_p);
- LLIST_TS_ADD_SORTED(&alist_p, apt, apoint_cmp_start);
+ LLIST_TS_ADD_SORTED(&alist_p, apt, apoint_cmp);
LLIST_TS_UNLOCK(&alist_p);
return apt;
@@ -319,7 +328,7 @@ void apoint_paste_item(struct apoint *apt, long date)
apt->start = date + get_item_time(apt->start);
LLIST_TS_LOCK(&alist_p);
- LLIST_TS_ADD_SORTED(&alist_p, apt, apoint_cmp_start);
+ LLIST_TS_ADD_SORTED(&alist_p, apt, apoint_cmp);
LLIST_TS_UNLOCK(&alist_p);
if (notify_bar())