summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Carbonneaux2018-02-27 15:48:27 -0500
committerQuentin Carbonneaux2018-02-27 15:48:36 -0500
commitfce56d363145777daba0fc035d6f648e5e8b0e91 (patch)
treed90e7a41a7be23eac64c0aa24bb62a6309885873
parent323d49b68c5e804ed3b8cada0e2274f1589b3484 (diff)
add some debugging stubs
The nasty bug that only shows up on certain machines can be made very much worse by changing RedrawDelay to something like 1 second. Machines that are not subject to the bug will simply exhibit a slow behavior; machines subject to the bug will be turned unusable by this change.
-rw-r--r--evnt.c30
-rw-r--r--evnt.h2
-rw-r--r--main.c5
-rw-r--r--x11.c6
4 files changed, 41 insertions, 2 deletions
diff --git a/evnt.c b/evnt.c
index d207832..5ffc352 100644
--- a/evnt.c
+++ b/evnt.c
@@ -1,6 +1,10 @@
#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
+#include <unistd.h>
#include <errno.h>
#include <sys/select.h>
#include <sys/time.h>
@@ -42,6 +46,32 @@ static struct timeval curtime;
void
+ev_log(char *fmt, ...)
+{
+ va_list va;
+ struct timeval t;
+ struct tm *tm;
+ size_t n;
+ static char buf[512];
+
+ gettimeofday(&t, 0);
+ tm = localtime(&t.tv_sec);
+ n = strftime(buf, sizeof buf, "[%T.", tm);
+ n += sprintf(&buf[n], "%03d] ", (int)(t.tv_usec/1000));
+ va_start(va, fmt);
+ n += vsprintf(&buf[n], fmt, va);
+ va_end(va);
+
+ write(2, buf, n);
+}
+
+void
+ev_msleep(int millis)
+{
+ select(0, 0, 0, 0, &(struct timeval){0, millis * 1000});
+}
+
+void
ev_time(struct timeval *t)
{
if (!curtime.tv_sec)
diff --git a/evnt.h b/evnt.h
index 3ebcad2..c9ddc80 100644
--- a/evnt.h
+++ b/evnt.h
@@ -8,6 +8,8 @@ enum {
};
int ev_alarm(int, void (*)(void));
+void ev_msleep(int);
+void ev_log(char *, ...);
void ev_register(int, int, void (*)(int, int, void *), void *);
void ev_cancel(int);
void ev_loop(void);
diff --git a/main.c b/main.c
index 43e4bf8..6e91996 100644
--- a/main.c
+++ b/main.c
@@ -21,7 +21,7 @@ int scrolling;
int needsredraw;
enum {
- RedrawDelay = 16, /* in milliseconds */
+ RedrawDelay = 1000, /* in milliseconds */
DoubleClick = 600,
};
static struct gui *g;
@@ -55,7 +55,9 @@ redraw()
assert(needsredraw);
if (old != curwin && old)
old->dirty = 1;
+ //ev_log("redrawing!\n");
win_redraw_frame(curwin, mode == 'i');
+ //ev_msleep(150);
old = curwin;
needsredraw = 0;
}
@@ -87,6 +89,7 @@ gev(int fd, int flag, void *unused)
win_resize_frame(e.resize.width, e.resize.height);
break;
case GKey:
+ //ev_log("key event %d\n", (int)e.key);
cmd_parse(e.key);
Update:
win_update(curwin);
diff --git a/x11.c b/x11.c
index 4c5291d..87b2837 100644
--- a/x11.c
+++ b/x11.c
@@ -7,12 +7,14 @@
#include <X11/Xft/Xft.h>
#include <X11/cursorfont.h>
+#include "evnt.h"
#include "unicode.h"
#include "gui.h"
void die(char *);
-#define FONTNAME "Monaco:pixelsize=10"
+//#define FONTNAME "Monaco:pixelsize=10"
+#define FONTNAME "leon:pixelsize=10"
enum {
HMargin = 16,
@@ -113,6 +115,7 @@ getfont(GFont *ret)
ret->ascent = font->ascent;
ret->descent = font->descent;
ret->height = font->height;
+ printf("ascent %d, descent %d, heigth %d\n", font->ascent, font->descent, font->height);
}
static void
@@ -358,6 +361,7 @@ nextevent(GEvent *gev)
default:
continue;
}
+ //ev_log("new event (ty=%d, ky=%d)\n", gev->type, gev->key);
return 1;
}
return 0;