summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui.h2
-rw-r--r--main.c33
-rw-r--r--win.c1
-rw-r--r--x11.c4
4 files changed, 22 insertions, 18 deletions
diff --git a/gui.h b/gui.h
index e6c83da..e0b62d8 100644
--- a/gui.h
+++ b/gui.h
@@ -94,7 +94,6 @@ enum {
struct gui {
int (*init)(void);
void (*fini)(void);
- void (*sync)(void);
void (*getfont)(GFont *fret);
void (*decorate)(GRect *clip, int dirty, GColor color);
void (*drawtext)(GRect *clip, Rune *str, int len,
@@ -102,6 +101,7 @@ struct gui {
void (*drawrect)(GRect *clip, int x, int y, int w, int h, GColor c);
void (*drawcursor)(GRect *clip, int insert, int x, int y, int w);
void (*setpointer)(GPointer pt);
+ int (*sync)(void);
int (*textwidth)(Rune *str, int len);
int (*nextevent)(GEvent *eret);
int hmargin;
diff --git a/main.c b/main.c
index 43e4bf8..d6f2616 100644
--- a/main.c
+++ b/main.c
@@ -18,14 +18,17 @@
W *curwin;
int scrolling;
-int needsredraw;
enum {
RedrawDelay = 16, /* in milliseconds */
DoubleClick = 600,
};
+
+static void redraw();
+
static struct gui *g;
static int clicks;
+static int needsredraw;
void
@@ -47,19 +50,6 @@ resetclicks()
clicks = 0;
}
-static void
-redraw()
-{
- static W *old;
-
- assert(needsredraw);
- if (old != curwin && old)
- old->dirty = 1;
- win_redraw_frame(curwin, mode == 'i');
- old = curwin;
- needsredraw = 0;
-}
-
void
repaint()
{
@@ -157,6 +147,21 @@ gev(int fd, int flag, void *unused)
}
}
+static void
+redraw()
+{
+ static W *old;
+
+ assert(needsredraw);
+ if (old != curwin && old)
+ old->dirty = 1;
+ old = curwin;
+ needsredraw = 0;
+ win_redraw_frame(curwin, mode == 'i');
+ if (g->sync())
+ gev(0, 0, 0);
+}
+
int
main(int ac, char *av[])
{
diff --git a/win.c b/win.c
index eae4b13..a7cc523 100644
--- a/win.c
+++ b/win.c
@@ -294,7 +294,6 @@ win_redraw_frame(W *focus, int insert)
g->drawrect(&b, 0, 0, b.w, g->border, GGray);
draw(&tag.win, GPaleGreen, focus, insert);
}
- g->sync();
}
/* win_scroll - Scroll the window by [n] lines.
diff --git a/x11.c b/x11.c
index 39961ee..faff022 100644
--- a/x11.c
+++ b/x11.c
@@ -208,11 +208,11 @@ textwidth(Rune *str, int len)
return gi.xOff;
}
-static void
+static int
sync()
{
XCopyArea(d, pbuf, win, gc, 0, 0, w, h, 0, 0);
- XFlush(d);
+ return XPending(d); // calls XFlush()
}
static int