st-anysize-0.8.4.diff 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. + win.hborderpx = (win.w - col * win.cw) / 2;
  35. + win.vborderpx = (win.h - row * win.ch) / 2;
  36. +
  37. tresize(col, row);
  38. xresize(col, row);
  39. ttyresize(win.tw, win.th);
  40. @@ -840,8 +844,8 @@ xhints(void)
  41. sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize;
  42. sizeh->height = win.h;
  43. sizeh->width = win.w;
  44. - sizeh->height_inc = win.ch;
  45. - sizeh->width_inc = win.cw;
  46. + sizeh->height_inc = 1;
  47. + sizeh->width_inc = 1;
  48. sizeh->base_height = 2 * borderpx;
  49. sizeh->base_width = 2 * borderpx;
  50. sizeh->min_height = win.ch + 2 * borderpx;
  51. @@ -1123,8 +1127,8 @@ xinit(int cols, int rows)
  52. xloadcols();
  53. /* adjust fixed window geometry */
  54. - win.w = 2 * borderpx + cols * win.cw;
  55. - win.h = 2 * borderpx + rows * win.ch;
  56. + win.w = 2 * win.hborderpx + 2 * borderpx + cols * win.cw;
  57. + win.h = 2 * win.vborderpx + 2 * borderpx + rows * win.ch;
  58. if (xw.gm & XNegative)
  59. xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2;
  60. if (xw.gm & YNegative)
  61. @@ -1213,7 +1217,7 @@ xinit(int cols, int rows)
  62. int
  63. xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x, int y)
  64. {
  65. - float winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, xp, yp;
  66. + float winx = win.hborderpx + x * win.cw, winy = win.vborderpx + y * win.ch, xp, yp;
  67. ushort mode, prevmode = USHRT_MAX;
  68. Font *font = &dc.font;
  69. int frcflags = FRC_NORMAL;
  70. @@ -1346,7 +1350,7 @@ void
  71. xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y)
  72. {
  73. int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1);
  74. - int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch,
  75. + int winx = win.hborderpx + x * win.cw, winy = win.vborderpx + y * win.ch,
  76. width = charlen * win.cw;
  77. Color *fg, *bg, *temp, revfg, revbg, truefg, truebg;
  78. XRenderColor colfg, colbg;
  79. @@ -1436,17 +1440,17 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
  80. /* Intelligent cleaning up of the borders. */
  81. if (x == 0) {
  82. - xclear(0, (y == 0)? 0 : winy, borderpx,
  83. + xclear(0, (y == 0)? 0 : winy, win.vborderpx,
  84. winy + win.ch +
  85. - ((winy + win.ch >= borderpx + win.th)? win.h : 0));
  86. + ((winy + win.ch >= win.vborderpx + win.th)? win.h : 0));
  87. }
  88. - if (winx + width >= borderpx + win.tw) {
  89. + if (winx + width >= win.hborderpx + win.tw) {
  90. xclear(winx + width, (y == 0)? 0 : winy, win.w,
  91. - ((winy + win.ch >= borderpx + win.th)? win.h : (winy + win.ch)));
  92. + ((winy + win.ch >= win.vborderpx + win.th)? win.h : (winy + win.ch)));
  93. }
  94. if (y == 0)
  95. - xclear(winx, 0, winx + width, borderpx);
  96. - if (winy + win.ch >= borderpx + win.th)
  97. + xclear(winx, 0, winx + width, win.vborderpx);
  98. + if (winy + win.ch >= win.vborderpx + win.th)
  99. xclear(winx, winy + win.ch, winx + width, win.h);
  100. /* Clean up the region we want to draw to. */
  101. @@ -1540,35 +1544,35 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
  102. case 3: /* Blinking Underline */
  103. case 4: /* Steady Underline */
  104. XftDrawRect(xw.draw, &drawcol,
  105. - borderpx + cx * win.cw,
  106. - borderpx + (cy + 1) * win.ch - \
  107. + win.hborderpx + cx * win.cw,
  108. + win.vborderpx + (cy + 1) * win.ch - \
  109. cursorthickness,
  110. win.cw, cursorthickness);
  111. break;
  112. case 5: /* Blinking bar */
  113. case 6: /* Steady bar */
  114. XftDrawRect(xw.draw, &drawcol,
  115. - borderpx + cx * win.cw,
  116. - borderpx + cy * win.ch,
  117. + win.hborderpx + cx * win.cw,
  118. + win.vborderpx + cy * win.ch,
  119. cursorthickness, win.ch);
  120. break;
  121. }
  122. } else {
  123. XftDrawRect(xw.draw, &drawcol,
  124. - borderpx + cx * win.cw,
  125. - borderpx + cy * win.ch,
  126. + win.hborderpx + cx * win.cw,
  127. + win.vborderpx + cy * win.ch,
  128. win.cw - 1, 1);
  129. XftDrawRect(xw.draw, &drawcol,
  130. - borderpx + cx * win.cw,
  131. - borderpx + cy * win.ch,
  132. + win.hborderpx + cx * win.cw,
  133. + win.vborderpx + cy * win.ch,
  134. 1, win.ch - 1);
  135. XftDrawRect(xw.draw, &drawcol,
  136. - borderpx + (cx + 1) * win.cw - 1,
  137. - borderpx + cy * win.ch,
  138. + win.hborderpx + (cx + 1) * win.cw - 1,
  139. + win.vborderpx + cy * win.ch,
  140. 1, win.ch - 1);
  141. XftDrawRect(xw.draw, &drawcol,
  142. - borderpx + cx * win.cw,
  143. - borderpx + (cy + 1) * win.ch - 1,
  144. + win.hborderpx + cx * win.cw,
  145. + win.vborderpx + (cy + 1) * win.ch - 1,
  146. win.cw, 1);
  147. }
  148. }