Configuration of dwm for Mac Computers
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.

115 lines
2.1 KiB

  1. /* See LICENSE file for copyright and license details. */
  2. #include <stdlib.h>
  3. #include <X11/Xlib.h>
  4. #include "draw.h"
  5. Draw *
  6. draw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h) {
  7. Draw *draw = (Draw *)calloc(1, sizeof(Draw));
  8. draw->dpy = dpy;
  9. draw->screen = screen;
  10. draw->win = win;
  11. draw->w = w;
  12. draw->h = h;
  13. draw->drawable = XCreatePixmap(dpy, win, w, h, DefaultDepth(dpy, screen));
  14. draw->gc = XCreateGC(dpy, win, 0, NULL);
  15. XSetLineAttributes(dpy, draw->gc, 1, LineSolid, CapButt, JoinMiter);
  16. return draw;
  17. }
  18. void
  19. draw_resize(Draw *draw, unsigned int w, unsigned int h) {
  20. if(!draw)
  21. return;
  22. draw->w = w;
  23. draw->h = h;
  24. XFreePixmap(draw->dpy, draw->drawable);
  25. draw->drawable = XCreatePixmap(draw->dpy, draw->win, w, h, DefaultDepth(draw->dpy, draw->screen));
  26. }
  27. void
  28. draw_free(Draw *draw) {
  29. XFreePixmap(draw->dpy, draw->drawable);
  30. XFreeGC(draw->dpy, draw->gc);
  31. free(draw);
  32. }
  33. Fnt *
  34. font_create(const char *fontname) {
  35. Fnt *font = (Fnt *)calloc(1, sizeof(Fnt));
  36. /* TODO: allocate actual font */
  37. return font;
  38. }
  39. void
  40. font_free(Fnt *font) {
  41. if(!font)
  42. return;
  43. /* TODO: deallocate any font resources */
  44. free(font);
  45. }
  46. Col *
  47. col_create(const char *colname) {
  48. Col *col = (Col *)calloc(1, sizeof(Col));
  49. /* TODO: allocate color */
  50. return col;
  51. }
  52. void
  53. col_free(Col *col) {
  54. if(!col)
  55. return;
  56. /* TODO: deallocate any color resource */
  57. free(col);
  58. }
  59. void
  60. draw_setfont(Draw *draw, Fnt *font) {
  61. if(!draw || !font)
  62. return;
  63. draw->font = font;
  64. }
  65. void
  66. draw_setfg(Draw *draw, Col *col) {
  67. if(!draw || !col)
  68. return;
  69. draw->fg = col;
  70. }
  71. void
  72. draw_setbg(Draw *draw, Col *col) {
  73. if(!draw || !col)
  74. return;
  75. draw->bg = col;
  76. }
  77. void
  78. draw_rect(Draw *draw, int x, int y, unsigned int w, unsigned int h) {
  79. if(!draw)
  80. return;
  81. /* TODO: draw the rectangle */
  82. }
  83. void
  84. draw_text(Draw *draw, int x, int y, const char *text) {
  85. if(!draw)
  86. return;
  87. /* TODO: draw the text */
  88. }
  89. void
  90. draw_map(Draw *draw, int x, int y, unsigned int w, unsigned int h) {
  91. if(!draw)
  92. return;
  93. /* TODO: map the draw contents in the region */
  94. }
  95. void
  96. draw_getextents(Draw *draw, const char *text, TextExtents *extents) {
  97. if(!draw || !extents)
  98. return;
  99. /* TODO: get extents */
  100. }