summaryrefslogtreecommitdiff
path: root/src/wins.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-11-23 18:46:38 +0100
committerLukas Fleischer <calcurse@cryptocrack.de>2012-11-23 19:03:57 +0100
commit1f0f05ecc1aae138b700df9ff2200abf4fd110f2 (patch)
tree1430bfcd2f79c47b2329c40320e67ecf3fa783c2 /src/wins.c
parent7733d52f3249fee2a1d875d6923b8d2506dea5e4 (diff)
parent0ea23c24bf06e153bb075804e195e1733fd67d3f (diff)
downloadcalcurse-1f0f05ecc1aae138b700df9ff2200abf4fd110f2.zip
Merge branch 'maint'
Conflicts: src/day.c src/recur.c
Diffstat (limited to 'src/wins.c')
-rw-r--r--src/wins.c66
1 files changed, 58 insertions, 8 deletions
diff --git a/src/wins.c b/src/wins.c
index 85666df..65b2d96 100644
--- a/src/wins.c
+++ b/src/wins.c
@@ -40,6 +40,14 @@
#include "calcurse.h"
+#define SCREEN_ACQUIRE \
+ pthread_cleanup_push(screen_cleanup, (void *)NULL); \
+ screen_acquire();
+
+#define SCREEN_RELEASE \
+ screen_release(); \
+ pthread_cleanup_pop(0);
+
/* Variables to handle calcurse windows. */
struct window win[NBWINS];
@@ -76,14 +84,54 @@ static void screen_release(void)
pthread_mutex_unlock(&screen_mutex);
}
+static void screen_cleanup(void *arg)
+{
+ screen_release();
+}
+
+/*
+ * FIXME: The following functions currently lock the whole screen. Use both
+ * window-level and screen-level mutexes (or use use_screen() and use_window(),
+ * see curs_threads(3)) to avoid locking too much.
+ */
+
+unsigned wins_nbar_lock(void)
+{
+ return screen_acquire();
+}
+
+void wins_nbar_unlock(void)
+{
+ screen_release();
+}
+
+void wins_nbar_cleanup(void *arg)
+{
+ wins_nbar_unlock();
+}
+
+unsigned wins_calendar_lock(void)
+{
+ return screen_acquire();
+}
+
+void wins_calendar_unlock(void)
+{
+ screen_release();
+}
+
+void wins_calendar_cleanup(void *arg)
+{
+ wins_calendar_unlock();
+}
+
int wins_refresh(void)
{
int rc;
- if (!screen_acquire())
- return ERR;
+ SCREEN_ACQUIRE;
rc = refresh();
- screen_release();
+ SCREEN_RELEASE;
return rc;
}
@@ -92,10 +140,11 @@ int wins_wrefresh(WINDOW * win)
{
int rc;
- if (!win || !screen_acquire())
+ if (!win)
return ERR;
+ SCREEN_ACQUIRE;
rc = wrefresh(win);
- screen_release();
+ SCREEN_RELEASE;
return rc;
}
@@ -104,10 +153,9 @@ int wins_doupdate(void)
{
int rc;
- if (!screen_acquire())
- return ERR;
+ SCREEN_ACQUIRE;
rc = doupdate();
- screen_release();
+ SCREEN_RELEASE;
return rc;
}
@@ -475,10 +523,12 @@ static void border_nocolor(WINDOW * window)
void wins_update_border(int flags)
{
if (flags & FLAG_CAL) {
+ WINS_CALENDAR_LOCK;
if (slctd_win == CAL)
border_color(win[CAL].p);
else
border_nocolor(win[CAL].p);
+ WINS_CALENDAR_UNLOCK;
}
if (flags & FLAG_APP) {
if (slctd_win == APP)