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.

89 lines
2.0 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. c->proto = win_proto(c->win);
  49. XGetTransientForHint(dpy, c->win, &c->trans);
  50. if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags)
  51. c->size.flags = PSize;
  52. c->fixedsize =
  53. (c->size.flags & PMinSize && c->size.flags & PMaxSize
  54. && c->size.min_width == c->size.max_width
  55. && c->size.min_height == c->size.max_height);
  56. XAddToSaveSet(dpy, c->win);
  57. update_client_name(c);
  58. twa.override_redirect = 1;
  59. twa.background_pixmap = ParentRelative;
  60. twa.event_mask = ExposureMask;
  61. c->title = XCreateWindow(dpy, root, c->r[RFloat].x, c->r[RFloat].y,
  62. c->r[RFloat].width, barrect.height, 0,
  63. DefaultDepth(dpy, screen), CopyFromParent,
  64. DefaultVisual(dpy, screen),
  65. CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
  66. XFlush(dpy);
  67. #if 0
  68. for(t=&client, i=0; *t; t=&(*t)->next, i++);
  69. c->next = *t; /* *t == nil */
  70. *t = c;
  71. #endif
  72. return c;
  73. }
  74. void
  75. manage(Client *c)
  76. {
  77. XMapRaised(dpy, c->win);
  78. XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
  79. XFlush(dpy);
  80. }