System message queue

The screen and user interaction is managed by the main thread. Other parts of
calcurse (threads) wishing to use the screen or communicate with the user, must
do it via the main thread.

For this purpose the main input loop is extended with a message queue. A thread
may insert a message in the queue. The main thread tests for messages before
listening for user commands. If a message is present, it is displayed (in a popup
window) for the user to acknowledge. Depending on the message other actions may
be performed, e.g. the message could be turned into a "system appointment/event"
and inserted among the usual appointments.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lars Henriksen
2018-09-14 21:32:52 +02:00
committed by Lukas Fleischer
parent 2339d78cbd
commit 2112b1ca2e
4 changed files with 112 additions and 0 deletions

View File

@@ -619,6 +619,9 @@ int main(int argc, char **argv)
io_set_lock();
}
/* System message queue. */
que_init();
/* Begin of interactive mode with ncurses interface. */
sigs_init(); /* signal handling init */
initscr(); /* start the curses mode */
@@ -702,6 +705,14 @@ int main(int argc, char **argv)
for (;;) {
int key;
while (que_ued()) {
que_show();
que_save();
do_storage(0);
wins_update(FLAG_ALL);
que_rem();
}
if (resize) {
resize = 0;
wins_reset();
@@ -712,7 +723,10 @@ int main(int argc, char **argv)
key_generic_reload();
}
/* Check input loop once every minute. */
wtimeout(win[KEY].p, 60000);
key = keys_get(win[KEY].p, &count, &reg);
wtimeout(win[KEY].p, -1);
switch (key) {
HANDLE_KEY(KEY_GENERIC_CHANGE_VIEW, key_generic_change_view);
HANDLE_KEY(KEY_GENERIC_OTHER_CMD, key_generic_other_cmd);