Configuration file for DWM on MacBook Air
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.

139 lines
2.2 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, Window win, unsigned int w, unsigned int h) {
  7. Draw *draw = (Draw *)calloc(1, sizeof(Draw));
  8. draw->w = w;
  9. draw->h = h;
  10. /* TODO: drawable creation */
  11. /* TODO: gc allocation */
  12. return draw;
  13. }
  14. void
  15. draw_resize(Draw *draw, unsigned int w, unsigned int h) {
  16. if(!draw)
  17. return;
  18. draw->w = w;
  19. draw->h = h;
  20. /* TODO: resize drawable */
  21. }
  22. void
  23. draw_free(Draw *draw) {
  24. /* TODO: deallocate DDCs */
  25. /* TODO: deallocate drawable */
  26. free(draw);
  27. }
  28. DDC *
  29. dc_create(Draw *draw) {
  30. DDC *dc = (DDC *)calloc(1, sizeof(DDC));
  31. dc->draw = draw;
  32. dc->next = draw->dc;
  33. draw->dc = dc;
  34. return dc;
  35. }
  36. void
  37. dc_free(DDC *dc) {
  38. DDC **tdc;
  39. if(!dc)
  40. return;
  41. /* remove from dc list */
  42. for(tdc = &dc->draw->dc; *tdc && *tdc != dc; tdc = &(*tdc)->next);
  43. *tdc = dc->next;
  44. /* TODO: deallocate any resources of this dc, if needed */
  45. free(dc);
  46. }
  47. Fnt *
  48. font_create(const char *fontname) {
  49. Fnt *font = (Fnt *)calloc(1, sizeof(Fnt));
  50. /* TODO: allocate actual font */
  51. return font;
  52. }
  53. void
  54. font_free(Fnt *font) {
  55. if(!font)
  56. return;
  57. /* TODO: deallocate any font resources */
  58. free(font);
  59. }
  60. Col *
  61. col_create(const char *colname) {
  62. Col *col = (Col *)calloc(1, sizeof(Col));
  63. /* TODO: allocate color */
  64. return col;
  65. }
  66. void
  67. col_free(Col *col) {
  68. if(!col)
  69. return;
  70. /* TODO: deallocate any color resource */
  71. free(col);
  72. }
  73. void
  74. dc_setfont(DDC *dc, Fnt *font) {
  75. if(!dc || !font)
  76. return;
  77. dc->font = font;
  78. }
  79. void
  80. dc_setfg(DDC *dc, Col *col) {
  81. if(!dc || !col)
  82. return;
  83. dc->fg = col;
  84. }
  85. void
  86. dc_setbg(DDC *dc, Col *col) {
  87. if(!dc || !col)
  88. return;
  89. dc->bg = col;
  90. }
  91. void
  92. dc_setfill(DDC *dc, Bool fill) {
  93. if(!dc)
  94. return;
  95. dc->fill = fill;
  96. }
  97. void
  98. dc_drawrect(DDC *dc, int x, int y, unsigned int w, unsigned int h) {
  99. if(!dc)
  100. return;
  101. /* TODO: draw the rectangle */
  102. }
  103. void
  104. dc_drawtext(DDC *dc, int x, int y, const char *text) {
  105. if(!dc)
  106. return;
  107. /* TODO: draw the text */
  108. }
  109. void
  110. dc_map(DDC *dc, int x, int y, unsigned int w, unsigned int h) {
  111. if(!dc)
  112. return;
  113. /* TODO: map the dc contents in the region */
  114. }
  115. void
  116. dc_getextents(DDC *dc, const char *text, TextExtents *extents) {
  117. if(!dc || !extents)
  118. return;
  119. /* TODO: get extents */
  120. }