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.

81 lines
1.6 KiB

  1. void
  2. managealtbar(Window win, XWindowAttributes *wa)
  3. {
  4. Monitor *m;
  5. Bar *bar;
  6. int i;
  7. if (!(m = recttomon(wa->x, wa->y, wa->width, wa->height)))
  8. return;
  9. for (i = 0, bar = m->bar; bar && bar->win && bar->next; bar = bar->next, ++i); // find last bar
  10. if (!bar) {
  11. bar = m->bar = ecalloc(1, sizeof(Bar));
  12. bar->topbar = topbar;
  13. } else if (bar && bar->win) {
  14. bar->next = ecalloc(1, sizeof(Bar));
  15. bar->next->topbar = !bar->topbar;
  16. bar = bar->next;
  17. }
  18. bar->external = 1;
  19. bar->showbar = 1;
  20. bar->mon = m;
  21. bar->idx = i;
  22. bar->borderpx = 0;
  23. bar->win = win;
  24. bar->bh = wa->height;
  25. updatebarpos(m);
  26. arrange(m);
  27. XSelectInput(dpy, win, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
  28. XMapWindow(dpy, win);
  29. XMoveResizeWindow(dpy, bar->win, bar->bx, -bar->by, wa->width, bar->bh);
  30. arrange(selmon);
  31. XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
  32. (unsigned char *) &win, 1);
  33. }
  34. void
  35. spawnbar()
  36. {
  37. if (*altbarcmd)
  38. system(altbarcmd);
  39. }
  40. void
  41. unmanagealtbar(Window w)
  42. {
  43. Monitor *m = wintomon(w);
  44. Bar *bar;
  45. if (!m)
  46. return;
  47. for (bar = m->bar; bar && bar->win; bar = bar->next)
  48. if (bar->win == w) {
  49. bar->win = 0;
  50. bar->by = 0;
  51. bar->bh = 0;
  52. break;
  53. }
  54. updatebarpos(m);
  55. arrange(m);
  56. }
  57. int
  58. wmclasscontains(Window win, const char *class, const char *name)
  59. {
  60. XClassHint ch = { NULL, NULL };
  61. int res = 1;
  62. if (XGetClassHint(dpy, win, &ch)) {
  63. if (ch.res_name && strstr(ch.res_name, name) == NULL)
  64. res = 0;
  65. if (ch.res_class && strstr(ch.res_class, class) == NULL)
  66. res = 0;
  67. } else
  68. res = 0;
  69. if (ch.res_class)
  70. XFree(ch.res_class);
  71. if (ch.res_name)
  72. XFree(ch.res_name);
  73. return res;
  74. }