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.

97 lines
2.1 KiB

18 years ago
  1. /*
  2. * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
  3. * See LICENSE file for license details.
  4. */
  5. #include <string.h>
  6. #include <X11/Xatom.h>
  7. #include "util.h"
  8. #include "wm.h"
  9. static void
  10. update_client_name(Client *c)
  11. {
  12. XTextProperty name;
  13. int n;
  14. char **list = NULL;
  15. name.nitems = 0;
  16. c->name[0] = 0;
  17. XGetTextProperty(dpy, c->win, &name, net_atom[NetWMName]);
  18. if(!name.nitems)
  19. XGetWMName(dpy, c->win, &name);
  20. if(!name.nitems)
  21. return;
  22. if(name.encoding == XA_STRING)
  23. strncpy(c->name, (char *)name.value, sizeof(c->name));
  24. else {
  25. if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
  26. && n > 0 && *list)
  27. {
  28. strncpy(c->name, *list, sizeof(c->name));
  29. XFreeStringList(list);
  30. }
  31. }
  32. XFree(name.value);
  33. }
  34. Client *
  35. create_client(Window w, XWindowAttributes *wa)
  36. {
  37. Client *c;
  38. XSetWindowAttributes twa;
  39. long msize;
  40. c = emallocz(sizeof(Client));
  41. c->win = w;
  42. c->r[RFloat].x = wa->x;
  43. c->r[RFloat].y = wa->y;
  44. c->r[RFloat].width = wa->width;
  45. c->r[RFloat].height = wa->height;
  46. c->border = wa->border_width;
  47. XSetWindowBorderWidth(dpy, c->win, 0);
  48. XGetTransientForHint(dpy, c->win, &c->trans);
  49. if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags)
  50. c->size.flags = PSize;
  51. c->fixedsize =
  52. (c->size.flags & PMinSize && c->size.flags & PMaxSize
  53. && c->size.min_width == c->size.max_width
  54. && c->size.min_height == c->size.max_height);
  55. update_client_name(c);
  56. twa.override_redirect = 1;
  57. twa.background_pixmap = ParentRelative;
  58. twa.event_mask = ExposureMask;
  59. c->title = XCreateWindow(dpy, root, c->r[RFloat].x, c->r[RFloat].y,
  60. c->r[RFloat].width, barrect.height, 0,
  61. DefaultDepth(dpy, screen), CopyFromParent,
  62. DefaultVisual(dpy, screen),
  63. CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
  64. XFlush(dpy);
  65. #if 0
  66. for(t=&client, i=0; *t; t=&(*t)->next, i++);
  67. c->next = *t; /* *t == nil */
  68. *t = c;
  69. #endif
  70. return c;
  71. }
  72. void
  73. manage(Client *c)
  74. {
  75. XMapRaised(dpy, c->win);
  76. XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
  77. XFlush(dpy);
  78. }
  79. Client *
  80. getclient(Window w)
  81. {
  82. Client *c;
  83. for(c = clients; c; c = c->next)
  84. if(c->win == w)
  85. return c;
  86. return NULL;
  87. }