aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/term/x.c
diff options
context:
space:
mode:
authorNicholas Noll <nnoll523@gmail.com>2020-06-26 16:11:15 +0200
committerNicholas Noll <nnoll523@gmail.com>2020-06-26 16:11:15 +0200
commit63424e9709751108c564f884cb4fdffab77c933d (patch)
tree6d9eb9e94e2fc553852ffce39f43201c005151c1 /sys/cmd/term/x.c
parent641ea1557ccc0099ef5471a16503938bd00924af (diff)
patched term to allow for arbitrary sizes
Diffstat (limited to 'sys/cmd/term/x.c')
-rw-r--r--sys/cmd/term/x.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/sys/cmd/term/x.c b/sys/cmd/term/x.c
index d6ec1bb..cdf82d7 100644
--- a/sys/cmd/term/x.c
+++ b/sys/cmd/term/x.c
@@ -315,7 +315,7 @@ ttysend(Arg *arg)
int
evcol(XEvent *e)
{
- int x = e->xbutton.x - borderpx;
+ int x = e->xbutton.x - win.hb;
LIMIT(x, 0, win.tw - 1);
return x / win.cw;
}
@@ -323,7 +323,7 @@ evcol(XEvent *e)
int
evrow(XEvent *e)
{
- int y = e->xbutton.y - borderpx;
+ int y = e->xbutton.y - win.vb;
LIMIT(y, 0, win.th - 1);
return y / win.ch;
}
@@ -705,6 +705,9 @@ cresize(int width, int height)
col = MAX(1, col);
row = MAX(1, row);
+ win.hb = (win.w - col*win.cw)/2;
+ win.vb = (win.h - col*win.ch)/2;
+
tresize(col, row);
xresize(col, row);
ttyresize(win.tw, win.th);
@@ -824,14 +827,13 @@ xhints(void)
sizeh = XAllocSizeHints();
sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize;
- sizeh->height = win.h;
- sizeh->width = win.w;
- sizeh->height_inc = win.ch;
- sizeh->width_inc = win.cw;
+ sizeh->height = win.h, sizeh->width = win.w;
+ sizeh->height_inc = 1;
+ sizeh->width_inc = 1;
sizeh->base_height = 2 * borderpx;
- sizeh->base_width = 2 * borderpx;
+ sizeh->base_width = 2 * borderpx;
sizeh->min_height = win.ch + 2 * borderpx;
- sizeh->min_width = win.cw + 2 * borderpx;
+ sizeh->min_width = win.cw + 2 * borderpx;
if (xw.isfixed) {
sizeh->flags |= PMaxSize;
sizeh->min_width = sizeh->max_width = win.w;
@@ -1121,8 +1123,8 @@ xinit(int cols, int rows)
xloadcols();
/* adjust fixed window geometry */
- win.w = 2 * borderpx + cols * win.cw;
- win.h = 2 * borderpx + rows * win.ch;
+ win.w = 2 * win.hb + cols * win.cw;
+ win.h = 2 * win.vb + rows * win.ch;
if (xw.gm & XNegative)
xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2;
if (xw.gm & YNegative)
@@ -1207,7 +1209,7 @@ xinit(int cols, int rows)
int
xmakeglyphfontspecs(XftGlyphFontSpec *specs, Letter *glyphs, int len, int x, int y)
{
- float winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, xp, yp;
+ float winx = win.hb + x * win.cw, winy = win.vb + y * win.ch, xp, yp;
ushort mode, prevmode = USHRT_MAX;
Font *font = &dc.font;
int frcflags = FRC_NORMAL;
@@ -1340,8 +1342,7 @@ void
xdrawglyphfontspecs(XftGlyphFontSpec *specs, Letter base, int len, int x, int y)
{
int charlen = len * ((base.mode & Gwide) ? 2 : 1);
- int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch,
- width = charlen * win.cw;
+ int winx = win.hb + x * win.cw, winy = win.vb + y * win.ch, width = charlen * win.cw;
Color *fg, *bg, *temp, revfg, revbg, truefg, truebg;
XRenderColor colfg, colbg;
XRectangle r;
@@ -1425,17 +1426,17 @@ xdrawglyphfontspecs(XftGlyphFontSpec *specs, Letter base, int len, int x, int y)
/* Intelligent cleaning up of the borders. */
if (x == 0) {
- xclear(0, (y == 0)? 0 : winy, borderpx,
+ xclear(0, (y == 0)? 0 : winy, win.vb,
winy + win.ch +
- ((winy + win.ch >= borderpx + win.th)? win.h : 0));
+ ((winy + win.ch >= win.vb + win.th)? win.h : 0));
}
- if (winx + width >= borderpx + win.tw) {
+ if (winx + width >= win.hb + win.tw) {
xclear(winx + width, (y == 0)? 0 : winy, win.w,
- ((winy + win.ch >= borderpx + win.th)? win.h : (winy + win.ch)));
+ ((winy + win.ch >= win.vb + win.th)? win.h : (winy + win.ch)));
}
if (y == 0)
- xclear(winx, 0, winx + width, borderpx);
- if (winy + win.ch >= borderpx + win.th)
+ xclear(winx, 0, winx + width, win.hb);
+ if (winy + win.ch >= win.hb + win.th)
xclear(winx, winy + win.ch, winx + width, win.h);
/* Clean up the region we want to draw to. */
@@ -1530,35 +1531,35 @@ drawnew:
break;
case 3: /* Blinking Underline */
case 4: /* Steady Underline */
- XftDrawRect(xw.draw, &drawcol,
- borderpx + cx * win.cw,
- borderpx + (cy + 1) * win.ch - cursorthickness,
+ XftDrawRect(xw.draw, &drawcol,
+ win.hb + cx * win.cw,
+ win.vb + (cy + 1) * win.ch - cursorthickness,
win.cw, cursorthickness);
break;
case 5: /* Blinking bar */
case 6: /* Steady bar */
XftDrawRect(xw.draw, &drawcol,
- borderpx + cx * win.cw,
- borderpx + cy * win.ch,
+ win.hb + cx * win.cw,
+ win.vb + cy * win.ch,
cursorthickness, win.ch);
break;
}
} else {
XftDrawRect(xw.draw, &drawcol,
- borderpx + cx * win.cw,
- borderpx + cy * win.ch,
+ win.hb + cx * win.cw,
+ win.vb + cy * win.ch,
win.cw - 1, 1);
XftDrawRect(xw.draw, &drawcol,
- borderpx + cx * win.cw,
- borderpx + cy * win.ch,
+ win.hb + cx * win.cw,
+ win.vb + cy * win.ch,
1, win.ch - 1);
XftDrawRect(xw.draw, &drawcol,
- borderpx + (cx + 1) * win.cw - 1,
- borderpx + cy * win.ch,
+ win.hb + (cx + 1) * win.cw - 1,
+ win.vb + cy * win.ch,
1, win.ch - 1);
XftDrawRect(xw.draw, &drawcol,
- borderpx + cx * win.cw,
- borderpx + (cy + 1) * win.ch - 1,
+ win.hb + cx * win.cw,
+ win.vb + (cy + 1) * win.ch - 1,
win.cw, 1);
}
}