Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.3 KiB

  1. #include <X11/extensions/shape.h>
  2. void drawroundedcorners(Client *c)
  3. {
  4. if (corner_radius <= 0 || !c || c->isfullscreen)
  5. return;
  6. Window win;
  7. win = c->win;
  8. if (!win)
  9. return;
  10. XWindowAttributes win_attr;
  11. if (!XGetWindowAttributes(dpy, win, &win_attr))
  12. return;
  13. int dia = 2 * corner_radius;
  14. int w = c->w;
  15. int h = c->h;
  16. if (w < dia || h < dia)
  17. return;
  18. Pixmap mask;
  19. mask = XCreatePixmap(dpy, win, w, h, 1);
  20. if (!mask)
  21. return;
  22. XGCValues xgcv;
  23. GC shape_gc;
  24. shape_gc = XCreateGC(dpy, mask, 0, &xgcv);
  25. if (!shape_gc) {
  26. XFreePixmap(dpy, mask);
  27. free(shape_gc);
  28. return;
  29. }
  30. XSetForeground(dpy, shape_gc, 0);
  31. XFillRectangle(dpy, mask, shape_gc, 0, 0, w, h);
  32. XSetForeground(dpy, shape_gc, 1);
  33. XFillArc(dpy, mask, shape_gc, 0, 0, dia, dia, 0, 23040);
  34. XFillArc(dpy, mask, shape_gc, w-dia-1, 0, dia, dia, 0, 23040);
  35. XFillArc(dpy, mask, shape_gc, 0, h-dia-1, dia, dia, 0, 23040);
  36. XFillArc(dpy, mask, shape_gc, w-dia-1, h-dia-1, dia, dia, 0, 23040);
  37. XFillRectangle(dpy, mask, shape_gc, corner_radius, 0, w-dia, h);
  38. XFillRectangle(dpy, mask, shape_gc, 0, corner_radius, w, h-dia);
  39. XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, mask, ShapeSet);
  40. XFreePixmap(dpy, mask);
  41. XFreeGC(dpy, shape_gc);
  42. }