Move win-agnostic parts of draw/drawregion to st.c

Introduces three functions to encapsulate X-specific behavior:
 * xdrawline: draws a portion of a single line (used by drawregion)
 * xbegindraw: called to prepare for drawing (will be useful for e.g.
   Wayland) and returns true if drawing should happen
 * xfinishdraw: called to finish drawing (used by draw)

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
This commit is contained in:
Devin J. Pohly
2018-02-24 14:53:23 -06:00
parent 05c66cb37d
commit 88d8293fb4
4 changed files with 69 additions and 51 deletions

25
st.c
View File

@ -166,6 +166,8 @@ static int32_t tdefcolor(int *, int *, int);
static void tdeftran(char);
static void tstrsequence(uchar);
static void drawregion(int, int, int, int);
static void selscroll(int, int);
static void selsnap(int *, int *, int);
@ -2526,6 +2528,29 @@ resettitle(void)
xsettitle(NULL);
}
void
drawregion(int x1, int y1, int x2, int y2)
{
int y;
for (y = y1; y < y2; y++) {
if (!term.dirty[y])
continue;
term.dirty[y] = 0;
xdrawline(term.line[y], x1, y, x2);
}
}
void
draw(void)
{
if (!xstartdraw())
return;
drawregion(0, 0, term.col, term.row);
xdrawcursor();
xfinishdraw();
}
void
redraw(void)
{