My build of the simple terminal from suckless.org.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

164 lignes
4.7 KiB

  1. diff --git a/config.def.h b/config.def.h
  2. index 0e01717..e116631 100644
  3. --- a/config.def.h
  4. +++ b/config.def.h
  5. @@ -82,6 +82,9 @@ char *termname = "st-256color";
  6. */
  7. unsigned int tabspaces = 8;
  8. +/* bg opacity */
  9. +float alpha = 0.8;
  10. +
  11. /* Terminal colors (16 first used in escape sequence) */
  12. static const char *colorname[] = {
  13. /* 8 normal colors */
  14. @@ -109,6 +112,7 @@ static const char *colorname[] = {
  15. /* more colors can be added after 255 to use with DefaultXX */
  16. "#cccccc",
  17. "#555555",
  18. + "black",
  19. };
  20. @@ -117,7 +121,7 @@ static const char *colorname[] = {
  21. * foreground, background, cursor, reverse cursor
  22. */
  23. unsigned int defaultfg = 7;
  24. -unsigned int defaultbg = 0;
  25. +unsigned int defaultbg = 258;
  26. static unsigned int defaultcs = 256;
  27. static unsigned int defaultrcs = 257;
  28. diff --git a/config.mk b/config.mk
  29. index 0cbb002..1d2f0e2 100644
  30. --- a/config.mk
  31. +++ b/config.mk
  32. @@ -16,7 +16,7 @@ PKG_CONFIG = pkg-config
  33. INCS = -I$(X11INC) \
  34. `$(PKG_CONFIG) --cflags fontconfig` \
  35. `$(PKG_CONFIG) --cflags freetype2`
  36. -LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
  37. +LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft -lXrender\
  38. `$(PKG_CONFIG) --libs fontconfig` \
  39. `$(PKG_CONFIG) --libs freetype2`
  40. diff --git a/st.h b/st.h
  41. index 38c61c4..b7634ab 100644
  42. --- a/st.h
  43. +++ b/st.h
  44. @@ -120,3 +120,4 @@ extern char *termname;
  45. extern unsigned int tabspaces;
  46. extern unsigned int defaultfg;
  47. extern unsigned int defaultbg;
  48. +extern float alpha;
  49. diff --git a/x.c b/x.c
  50. index 0422421..588dec3 100644
  51. --- a/x.c
  52. +++ b/x.c
  53. @@ -98,6 +98,7 @@ typedef struct {
  54. XSetWindowAttributes attrs;
  55. int scr;
  56. int isfixed; /* is fixed geometry? */
  57. + int depth; /* bit depth */
  58. int l, t; /* left and top offset */
  59. int gm; /* geometry mask */
  60. } XWindow;
  61. @@ -229,6 +230,7 @@ static char *usedfont = NULL;
  62. static double usedfontsize = 0;
  63. static double defaultfontsize = 0;
  64. +static char *opt_alpha = NULL;
  65. static char *opt_class = NULL;
  66. static char **opt_cmd = NULL;
  67. static char *opt_embed = NULL;
  68. @@ -688,7 +690,7 @@ xresize(int col, int row)
  69. XFreePixmap(xw.dpy, xw.buf);
  70. xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
  71. - DefaultDepth(xw.dpy, xw.scr));
  72. + xw.depth);
  73. XftDrawChange(xw.draw, xw.buf);
  74. xclear(0, 0, win.w, win.h);
  75. @@ -748,6 +750,13 @@ xloadcols(void)
  76. else
  77. die("could not allocate color %d\n", i);
  78. }
  79. +
  80. + /* set alpha value of bg color */
  81. + if (opt_alpha)
  82. + alpha = strtof(opt_alpha, NULL);
  83. + dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha);
  84. + dc.col[defaultbg].pixel &= 0x00FFFFFF;
  85. + dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24;
  86. loaded = 1;
  87. }
  88. @@ -1004,11 +1013,23 @@ xinit(int cols, int rows)
  89. Window parent;
  90. pid_t thispid = getpid();
  91. XColor xmousefg, xmousebg;
  92. + XWindowAttributes attr;
  93. + XVisualInfo vis;
  94. if (!(xw.dpy = XOpenDisplay(NULL)))
  95. die("can't open display\n");
  96. xw.scr = XDefaultScreen(xw.dpy);
  97. - xw.vis = XDefaultVisual(xw.dpy, xw.scr);
  98. +
  99. + if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) {
  100. + parent = XRootWindow(xw.dpy, xw.scr);
  101. + xw.depth = 32;
  102. + } else {
  103. + XGetWindowAttributes(xw.dpy, parent, &attr);
  104. + xw.depth = attr.depth;
  105. + }
  106. +
  107. + XMatchVisualInfo(xw.dpy, xw.scr, xw.depth, TrueColor, &vis);
  108. + xw.vis = vis.visual;
  109. /* font */
  110. if (!FcInit())
  111. @@ -1018,7 +1039,7 @@ xinit(int cols, int rows)
  112. xloadfonts(usedfont, 0);
  113. /* colors */
  114. - xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
  115. + xw.cmap = XCreateColormap(xw.dpy, parent, xw.vis, None);
  116. xloadcols();
  117. /* adjust fixed window geometry */
  118. @@ -1038,19 +1059,15 @@ xinit(int cols, int rows)
  119. | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
  120. xw.attrs.colormap = xw.cmap;
  121. - if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0))))
  122. - parent = XRootWindow(xw.dpy, xw.scr);
  123. xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t,
  124. - win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput,
  125. + win.w, win.h, 0, xw.depth, InputOutput,
  126. xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity
  127. | CWEventMask | CWColormap, &xw.attrs);
  128. memset(&gcvalues, 0, sizeof(gcvalues));
  129. gcvalues.graphics_exposures = False;
  130. - dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures,
  131. - &gcvalues);
  132. - xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
  133. - DefaultDepth(xw.dpy, xw.scr));
  134. + xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, xw.depth);
  135. + dc.gc = XCreateGC(xw.dpy, xw.buf, GCGraphicsExposures, &gcvalues);
  136. XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
  137. XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
  138. @@ -1894,6 +1911,9 @@ main(int argc, char *argv[])
  139. case 'a':
  140. allowaltscreen = 0;
  141. break;
  142. + case 'A':
  143. + opt_alpha = EARGF(usage());
  144. + break;
  145. case 'c':
  146. opt_class = EARGF(usage());
  147. break;