st-anysize-0.8.4.diff - sites - public wiki contents of suckless.org | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
st-anysize-0.8.4.diff (5056B) | |
--- | |
1 diff --git a/x.c b/x.c | |
2 index 8bf998e..e2cda07 100644 | |
3 --- a/x.c | |
4 +++ b/x.c | |
5 @@ -81,6 +81,7 @@ typedef XftGlyphFontSpec GlyphFontSpec; | |
6 typedef struct { | |
7 int tw, th; /* tty width and height */ | |
8 int w, h; /* window width and height */ | |
9 + int hborderpx, vborderpx; | |
10 int ch; /* char height */ | |
11 int cw; /* char width */ | |
12 int mode; /* window state/mode flags */ | |
13 @@ -331,7 +332,7 @@ ttysend(const Arg *arg) | |
14 int | |
15 evcol(XEvent *e) | |
16 { | |
17 - int x = e->xbutton.x - borderpx; | |
18 + int x = e->xbutton.x - win.hborderpx; | |
19 LIMIT(x, 0, win.tw - 1); | |
20 return x / win.cw; | |
21 } | |
22 @@ -339,7 +340,7 @@ evcol(XEvent *e) | |
23 int | |
24 evrow(XEvent *e) | |
25 { | |
26 - int y = e->xbutton.y - borderpx; | |
27 + int y = e->xbutton.y - win.vborderpx; | |
28 LIMIT(y, 0, win.th - 1); | |
29 return y / win.ch; | |
30 } | |
31 @@ -723,6 +724,9 @@ cresize(int width, int height) | |
32 col = MAX(1, col); | |
33 row = MAX(1, row); | |
34 | |
35 + win.hborderpx = (win.w - col * win.cw) / 2; | |
36 + win.vborderpx = (win.h - row * win.ch) / 2; | |
37 + | |
38 tresize(col, row); | |
39 xresize(col, row); | |
40 ttyresize(win.tw, win.th); | |
41 @@ -840,8 +844,8 @@ xhints(void) | |
42 sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize; | |
43 sizeh->height = win.h; | |
44 sizeh->width = win.w; | |
45 - sizeh->height_inc = win.ch; | |
46 - sizeh->width_inc = win.cw; | |
47 + sizeh->height_inc = 1; | |
48 + sizeh->width_inc = 1; | |
49 sizeh->base_height = 2 * borderpx; | |
50 sizeh->base_width = 2 * borderpx; | |
51 sizeh->min_height = win.ch + 2 * borderpx; | |
52 @@ -1123,8 +1127,8 @@ xinit(int cols, int rows) | |
53 xloadcols(); | |
54 | |
55 /* adjust fixed window geometry */ | |
56 - win.w = 2 * borderpx + cols * win.cw; | |
57 - win.h = 2 * borderpx + rows * win.ch; | |
58 + win.w = 2 * win.hborderpx + 2 * borderpx + cols * win.cw; | |
59 + win.h = 2 * win.vborderpx + 2 * borderpx + rows * win.ch; | |
60 if (xw.gm & XNegative) | |
61 xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2; | |
62 if (xw.gm & YNegative) | |
63 @@ -1213,7 +1217,7 @@ xinit(int cols, int rows) | |
64 int | |
65 xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int l… | |
66 { | |
67 - float winx = borderpx + x * win.cw, winy = borderpx + y * win.c… | |
68 + float winx = win.hborderpx + x * win.cw, winy = win.vborderpx +… | |
69 ushort mode, prevmode = USHRT_MAX; | |
70 Font *font = &dc.font; | |
71 int frcflags = FRC_NORMAL; | |
72 @@ -1346,7 +1350,7 @@ void | |
73 xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len,… | |
74 { | |
75 int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1); | |
76 - int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, | |
77 + int winx = win.hborderpx + x * win.cw, winy = win.vborderpx + y… | |
78 width = charlen * win.cw; | |
79 Color *fg, *bg, *temp, revfg, revbg, truefg, truebg; | |
80 XRenderColor colfg, colbg; | |
81 @@ -1436,17 +1440,17 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *spec… | |
82 | |
83 /* Intelligent cleaning up of the borders. */ | |
84 if (x == 0) { | |
85 - xclear(0, (y == 0)? 0 : winy, borderpx, | |
86 + xclear(0, (y == 0)? 0 : winy, win.vborderpx, | |
87 winy + win.ch + | |
88 - ((winy + win.ch >= borderpx + win.th)? win.h : … | |
89 + ((winy + win.ch >= win.vborderpx + win.th)? win… | |
90 } | |
91 - if (winx + width >= borderpx + win.tw) { | |
92 + if (winx + width >= win.hborderpx + win.tw) { | |
93 xclear(winx + width, (y == 0)? 0 : winy, win.w, | |
94 - ((winy + win.ch >= borderpx + win.th)? win.h : … | |
95 + ((winy + win.ch >= win.vborderpx + win.th)? win… | |
96 } | |
97 if (y == 0) | |
98 - xclear(winx, 0, winx + width, borderpx); | |
99 - if (winy + win.ch >= borderpx + win.th) | |
100 + xclear(winx, 0, winx + width, win.vborderpx); | |
101 + if (winy + win.ch >= win.vborderpx + win.th) | |
102 xclear(winx, winy + win.ch, winx + width, win.h); | |
103 | |
104 /* Clean up the region we want to draw to. */ | |
105 @@ -1540,35 +1544,35 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int… | |
106 case 3: /* Blinking Underline */ | |
107 case 4: /* Steady Underline */ | |
108 XftDrawRect(xw.draw, &drawcol, | |
109 - borderpx + cx * win.cw, | |
110 - borderpx + (cy + 1) * win.ch - \ | |
111 + win.hborderpx + cx * win.cw, | |
112 + win.vborderpx + (cy + 1) * win.… | |
113 cursorthickness, | |
114 win.cw, cursorthickness); | |
115 break; | |
116 case 5: /* Blinking bar */ | |
117 case 6: /* Steady bar */ | |
118 XftDrawRect(xw.draw, &drawcol, | |
119 - borderpx + cx * win.cw, | |
120 - borderpx + cy * win.ch, | |
121 + win.hborderpx + cx * win.cw, | |
122 + win.vborderpx + cy * win.ch, | |
123 cursorthickness, win.ch); | |
124 break; | |
125 } | |
126 } else { | |
127 XftDrawRect(xw.draw, &drawcol, | |
128 - borderpx + cx * win.cw, | |
129 - borderpx + cy * win.ch, | |
130 + win.hborderpx + cx * win.cw, | |
131 + win.vborderpx + cy * win.ch, | |
132 win.cw - 1, 1); | |
133 XftDrawRect(xw.draw, &drawcol, | |
134 - borderpx + cx * win.cw, | |
135 - borderpx + cy * win.ch, | |
136 + win.hborderpx + cx * win.cw, | |
137 + win.vborderpx + cy * win.ch, | |
138 1, win.ch - 1); | |
139 XftDrawRect(xw.draw, &drawcol, | |
140 - borderpx + (cx + 1) * win.cw - 1, | |
141 - borderpx + cy * win.ch, | |
142 + win.hborderpx + (cx + 1) * win.cw - 1, | |
143 + win.vborderpx + cy * win.ch, | |
144 1, win.ch - 1); | |
145 XftDrawRect(xw.draw, &drawcol, | |
146 - borderpx + cx * win.cw, | |
147 - borderpx + (cy + 1) * win.ch - 1, | |
148 + win.hborderpx + cx * win.cw, | |
149 + win.vborderpx + (cy + 1) * win.ch - 1, | |
150 win.cw, 1); | |
151 } | |
152 } |