diff options
| author | Devin J. Pohly <djpohly@gmail.com> | 2018-02-24 14:53:23 -0600 |
|---|---|---|
| committer | Devin J. Pohly <djpohly@gmail.com> | 2018-02-25 21:56:26 -0600 |
| commit | 88d8293fb4ba150a5f19d58d133b5db93d9dcfa5 (patch) | |
| tree | f9e3cce2feda5565049c5d99012e8bd84144b8a2 /x.c | |
| parent | Split mode bits between Term and TermWindow (diff) | |
| download | st-88d8293fb4ba150a5f19d58d133b5db93d9dcfa5.tar.gz st-88d8293fb4ba150a5f19d58d133b5db93d9dcfa5.zip | |
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>
Diffstat (limited to 'x.c')
| -rw-r--r-- | x.c | 79 |
1 files changed, 35 insertions, 44 deletions
| @@ -129,7 +129,6 @@ static int xmakeglyphfontspecs(XftGlyphFontSpec *, const Glyph *, int, int, int) | |||
| 129 | static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int); | 129 | static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int); |
| 130 | static void xdrawglyph(Glyph, int, int); | 130 | static void xdrawglyph(Glyph, int, int); |
| 131 | static void xclear(int, int, int, int); | 131 | static void xclear(int, int, int, int); |
| 132 | static void xdrawcursor(void); | ||
| 133 | static int xgeommasktogravity(int); | 132 | static int xgeommasktogravity(int); |
| 134 | static void xinit(void); | 133 | static void xinit(void); |
| 135 | static void cresize(int, int); | 134 | static void cresize(int, int); |
| @@ -1512,59 +1511,51 @@ xsettitle(char *p) | |||
| 1512 | XFree(prop.value); | 1511 | XFree(prop.value); |
| 1513 | } | 1512 | } |
| 1514 | 1513 | ||
| 1515 | void | 1514 | int |
| 1516 | draw(void) | 1515 | xstartdraw(void) |
| 1517 | { | 1516 | { |
| 1518 | drawregion(0, 0, term.col, term.row); | 1517 | return IS_SET(MODE_VISIBLE); |
| 1519 | XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, win.w, | ||
| 1520 | win.h, 0, 0); | ||
| 1521 | XSetForeground(xw.dpy, dc.gc, | ||
| 1522 | dc.col[IS_SET(MODE_REVERSE)? | ||
| 1523 | defaultfg : defaultbg].pixel); | ||
| 1524 | } | 1518 | } |
| 1525 | 1519 | ||
| 1526 | void | 1520 | void |
| 1527 | drawregion(int x1, int y1, int x2, int y2) | 1521 | xdrawline(Line line, int x1, int y1, int x2) |
| 1528 | { | 1522 | { |
| 1529 | int i, x, y, ox, numspecs; | 1523 | int i, x, ox, numspecs; |
| 1530 | Glyph base, new; | 1524 | Glyph base, new; |
| 1531 | XftGlyphFontSpec *specs; | 1525 | XftGlyphFontSpec *specs = xw.specbuf; |
| 1532 | 1526 | ||
| 1533 | if (!(IS_SET(MODE_VISIBLE))) | 1527 | numspecs = xmakeglyphfontspecs(specs, &line[x1], x2 - x1, x1, y1); |
| 1534 | return; | 1528 | i = ox = 0; |
| 1535 | 1529 | for (x = x1; x < x2 && i < numspecs; x++) { | |
| 1536 | for (y = y1; y < y2; y++) { | 1530 | new = line[x]; |
| 1537 | if (!term.dirty[y]) | 1531 | if (new.mode == ATTR_WDUMMY) |
| 1538 | continue; | 1532 | continue; |
| 1539 | 1533 | if (selected(x, y1)) | |
| 1540 | term.dirty[y] = 0; | 1534 | new.mode ^= ATTR_REVERSE; |
| 1541 | 1535 | if (i > 0 && ATTRCMP(base, new)) { | |
| 1542 | specs = xw.specbuf; | 1536 | xdrawglyphfontspecs(specs, base, i, ox, y1); |
| 1543 | numspecs = xmakeglyphfontspecs(specs, &term.line[y][x1], x2 - x1, x1, y); | 1537 | specs += i; |
| 1544 | 1538 | numspecs -= i; | |
| 1545 | i = ox = 0; | 1539 | i = 0; |
| 1546 | for (x = x1; x < x2 && i < numspecs; x++) { | 1540 | } |
| 1547 | new = term.line[y][x]; | 1541 | if (i == 0) { |
| 1548 | if (new.mode == ATTR_WDUMMY) | 1542 | ox = x; |
| 1549 | continue; | 1543 | base = new; |
| 1550 | if (selected(x, y)) | ||
| 1551 | new.mode ^= ATTR_REVERSE; | ||
| 1552 | if (i > 0 && ATTRCMP(base, new)) { | ||
| 1553 | xdrawglyphfontspecs(specs, base, i, ox, y); | ||
| 1554 | specs += i; | ||
| 1555 | numspecs -= i; | ||
| 1556 | i = 0; | ||
| 1557 | } | ||
| 1558 | if (i == 0) { | ||
| 1559 | ox = x; | ||
| 1560 | base = new; | ||
| 1561 | } | ||
| 1562 | i++; | ||
| 1563 | } | 1544 | } |
| 1564 | if (i > 0) | 1545 | i++; |
| 1565 | xdrawglyphfontspecs(specs, base, i, ox, y); | ||
| 1566 | } | 1546 | } |
| 1567 | xdrawcursor(); | 1547 | if (i > 0) |
| 1548 | xdrawglyphfontspecs(specs, base, i, ox, y1); | ||
| 1549 | } | ||
| 1550 | |||
| 1551 | void | ||
| 1552 | xfinishdraw(void) | ||
| 1553 | { | ||
| 1554 | XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, win.w, | ||
| 1555 | win.h, 0, 0); | ||
| 1556 | XSetForeground(xw.dpy, dc.gc, | ||
| 1557 | dc.col[IS_SET(MODE_REVERSE)? | ||
| 1558 | defaultfg : defaultbg].pixel); | ||
| 1568 | } | 1559 | } |
| 1569 | 1560 | ||
| 1570 | void | 1561 | void |
