dwm-attachaside-6.4.diff 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. diff --git a/dwm.c b/dwm.c
  2. index f1d86b2..8b04e0b 100644
  3. --- a/dwm.c
  4. +++ b/dwm.c
  5. @@ -49,7 +49,8 @@
  6. #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
  7. #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
  8. * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
  9. -#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
  10. +#define ISVISIBLEONTAG(C, T) ((C->tags & T))
  11. +#define ISVISIBLE(C) ISVISIBLEONTAG(C, C->mon->tagset[C->mon->seltags])
  12. #define LENGTH(X) (sizeof X / sizeof X[0])
  13. #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
  14. #define WIDTH(X) ((X)->w + 2 * (X)->bw)
  15. @@ -147,6 +148,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
  16. static void arrange(Monitor *m);
  17. static void arrangemon(Monitor *m);
  18. static void attach(Client *c);
  19. +static void attachaside(Client *c);
  20. static void attachstack(Client *c);
  21. static void buttonpress(XEvent *e);
  22. static void checkotherwm(void);
  23. @@ -184,6 +186,7 @@ static void maprequest(XEvent *e);
  24. static void monocle(Monitor *m);
  25. static void motionnotify(XEvent *e);
  26. static void movemouse(const Arg *arg);
  27. +static Client *nexttagged(Client *c);
  28. static Client *nexttiled(Client *c);
  29. static void pop(Client *c);
  30. static void propertynotify(XEvent *e);
  31. @@ -408,6 +411,17 @@ attach(Client *c)
  32. c->mon->clients = c;
  33. }
  34. +void
  35. +attachaside(Client *c) {
  36. + Client *at = nexttagged(c);
  37. + if(!at) {
  38. + attach(c);
  39. + return;
  40. + }
  41. + c->next = at->next;
  42. + at->next = c;
  43. +}
  44. +
  45. void
  46. attachstack(Client *c)
  47. {
  48. @@ -1074,7 +1088,7 @@ manage(Window w, XWindowAttributes *wa)
  49. c->isfloating = c->oldstate = trans != None || c->isfixed;
  50. if (c->isfloating)
  51. XRaiseWindow(dpy, c->win);
  52. - attach(c);
  53. + attachaside(c);
  54. attachstack(c);
  55. XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
  56. (unsigned char *) &(c->win), 1);
  57. @@ -1202,6 +1216,16 @@ movemouse(const Arg *arg)
  58. }
  59. }
  60. +Client *
  61. +nexttagged(Client *c) {
  62. + Client *walked = c->mon->clients;
  63. + for(;
  64. + walked && (walked->isfloating || !ISVISIBLEONTAG(walked, c->tags));
  65. + walked = walked->next
  66. + );
  67. + return walked;
  68. +}
  69. +
  70. Client *
  71. nexttiled(Client *c)
  72. {
  73. @@ -1427,7 +1451,7 @@ sendmon(Client *c, Monitor *m)
  74. detachstack(c);
  75. c->mon = m;
  76. c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
  77. - attach(c);
  78. + attachaside(c);
  79. attachstack(c);
  80. focus(NULL);
  81. arrange(NULL);
  82. @@ -1915,7 +1939,7 @@ updategeom(void)
  83. m->clients = c->next;
  84. detachstack(c);
  85. c->mon = mons;
  86. - attach(c);
  87. + attachaside(c);
  88. attachstack(c);
  89. }
  90. if (m == selmon)