diff options
author | Devin J. Pohly <djpohly@gmail.com> | 2017-10-10 12:17:25 -0500 |
---|---|---|
committer | Devin J. Pohly <djpohly@gmail.com> | 2018-02-25 21:53:24 -0600 |
commit | a09138afa57adb4b76dba8ca72dc7ee2642a5c8d (patch) | |
tree | 4d5db9a65174fa159b3bd7be8b67a7d445ed6f2c /x.c | |
parent | 626b0ae40c71b6c1e02ece79bf033432647381a6 (diff) | |
download | st-a09138afa57adb4b76dba8ca72dc7ee2642a5c8d.tar.gz st-a09138afa57adb4b76dba8ca72dc7ee2642a5c8d.zip |
Move font/fontspec variables into x.c and XWindow
Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
Diffstat (limited to 'x.c')
-rw-r--r-- | x.c | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -17,10 +17,6 @@ | |||
17 | 17 | ||
18 | static char *argv0; | 18 | static char *argv0; |
19 | #include "arg.h" | 19 | #include "arg.h" |
20 | |||
21 | #define Glyph Glyph_ | ||
22 | #define Font Font_ | ||
23 | |||
24 | #include "st.h" | 20 | #include "st.h" |
25 | #include "win.h" | 21 | #include "win.h" |
26 | 22 | ||
@@ -35,6 +31,7 @@ static char *argv0; | |||
35 | 31 | ||
36 | typedef XftDraw *Draw; | 32 | typedef XftDraw *Draw; |
37 | typedef XftColor Color; | 33 | typedef XftColor Color; |
34 | typedef XftGlyphFontSpec GlyphFontSpec; | ||
38 | 35 | ||
39 | /* Purely graphic info */ | 36 | /* Purely graphic info */ |
40 | typedef struct { | 37 | typedef struct { |
@@ -42,6 +39,7 @@ typedef struct { | |||
42 | Colormap cmap; | 39 | Colormap cmap; |
43 | Window win; | 40 | Window win; |
44 | Drawable buf; | 41 | Drawable buf; |
42 | GlyphFontSpec *specbuf; /* font spec buffer used for rendering */ | ||
45 | Atom xembed, wmdeletewin, netwmname, netwmpid; | 43 | Atom xembed, wmdeletewin, netwmname, netwmpid; |
46 | XIM xim; | 44 | XIM xim; |
47 | XIC xic; | 45 | XIC xic; |
@@ -59,6 +57,7 @@ typedef struct { | |||
59 | } XSelection; | 57 | } XSelection; |
60 | 58 | ||
61 | /* Font structure */ | 59 | /* Font structure */ |
60 | #define Font Font_ | ||
62 | typedef struct { | 61 | typedef struct { |
63 | int height; | 62 | int height; |
64 | int width; | 63 | int width; |
@@ -166,6 +165,9 @@ typedef struct { | |||
166 | /* Fontcache is an array now. A new font will be appended to the array. */ | 165 | /* Fontcache is an array now. A new font will be appended to the array. */ |
167 | static Fontcache frc[16]; | 166 | static Fontcache frc[16]; |
168 | static int frclen = 0; | 167 | static int frclen = 0; |
168 | static char *usedfont = NULL; | ||
169 | static double usedfontsize = 0; | ||
170 | static double defaultfontsize = 0; | ||
169 | 171 | ||
170 | void | 172 | void |
171 | zoom(const Arg *arg) | 173 | zoom(const Arg *arg) |
@@ -605,6 +607,9 @@ xresize(int col, int row) | |||
605 | DefaultDepth(xw.dpy, xw.scr)); | 607 | DefaultDepth(xw.dpy, xw.scr)); |
606 | XftDrawChange(xw.draw, xw.buf); | 608 | XftDrawChange(xw.draw, xw.buf); |
607 | xclear(0, 0, win.w, win.h); | 609 | xclear(0, 0, win.w, win.h); |
610 | |||
611 | /* resize to new width */ | ||
612 | xw.specbuf = xrealloc(xw.specbuf, col * sizeof(GlyphFontSpec)); | ||
608 | } | 613 | } |
609 | 614 | ||
610 | ushort | 615 | ushort |
@@ -965,6 +970,9 @@ xinit(void) | |||
965 | XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); | 970 | XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); |
966 | XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h); | 971 | XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h); |
967 | 972 | ||
973 | /* font spec buffer */ | ||
974 | xw.specbuf = xmalloc(term.col * sizeof(GlyphFontSpec)); | ||
975 | |||
968 | /* Xft rendering context */ | 976 | /* Xft rendering context */ |
969 | xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap); | 977 | xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap); |
970 | 978 | ||
@@ -1456,7 +1464,7 @@ drawregion(int x1, int y1, int x2, int y2) | |||
1456 | 1464 | ||
1457 | term.dirty[y] = 0; | 1465 | term.dirty[y] = 0; |
1458 | 1466 | ||
1459 | specs = term.specbuf; | 1467 | specs = xw.specbuf; |
1460 | numspecs = xmakeglyphfontspecs(specs, &term.line[y][x1], x2 - x1, x1, y); | 1468 | numspecs = xmakeglyphfontspecs(specs, &term.line[y][x1], x2 - x1, x1, y); |
1461 | 1469 | ||
1462 | i = ox = 0; | 1470 | i = ox = 0; |