dwm-focusonclick-20200110-61bb8b2.diff 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. From 7ac0b812540e21b470f2f6947c6cc1e30bf24b42 Mon Sep 17 00:00:00 2001
  2. From: iofq <cjriddz@protonmail.com>
  3. Date: Sun, 10 Jan 2021 22:43:16 -0600
  4. Subject: [PATCH] tweak fixes floating window mouse controls
  5. ---
  6. config.def.h | 1 +
  7. dwm.c | 47 ++++-------------------------------------------
  8. 2 files changed, 5 insertions(+), 43 deletions(-)
  9. diff --git a/config.def.h b/config.def.h
  10. index 1c0b587..4f2c946 100644
  11. --- a/config.def.h
  12. +++ b/config.def.h
  13. @@ -5,6 +5,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
  14. static const unsigned int snap = 32; /* snap pixel */
  15. static const int showbar = 1; /* 0 means no bar */
  16. static const int topbar = 1; /* 0 means bottom bar */
  17. +static const int focusonwheel = 0;
  18. static const char *fonts[] = { "monospace:size=10" };
  19. static const char dmenufont[] = "monospace:size=10";
  20. static const char col_gray1[] = "#222222";
  21. diff --git a/dwm.c b/dwm.c
  22. index 664c527..de3e883 100644
  23. --- a/dwm.c
  24. +++ b/dwm.c
  25. @@ -163,7 +163,6 @@ static void detachstack(Client *c);
  26. static Monitor *dirtomon(int dir);
  27. static void drawbar(Monitor *m);
  28. static void drawbars(void);
  29. -static void enternotify(XEvent *e);
  30. static void expose(XEvent *e);
  31. static void focus(Client *c);
  32. static void focusin(XEvent *e);
  33. @@ -182,7 +181,6 @@ static void manage(Window w, XWindowAttributes *wa);
  34. static void mappingnotify(XEvent *e);
  35. static void maprequest(XEvent *e);
  36. static void monocle(Monitor *m);
  37. -static void motionnotify(XEvent *e);
  38. static void movemouse(const Arg *arg);
  39. static Client *nexttiled(Client *c);
  40. static void pop(Client *);
  41. @@ -250,13 +248,11 @@ static void (*handler[LASTEvent]) (XEvent *) = {
  42. [ConfigureRequest] = configurerequest,
  43. [ConfigureNotify] = configurenotify,
  44. [DestroyNotify] = destroynotify,
  45. - [EnterNotify] = enternotify,
  46. [Expose] = expose,
  47. [FocusIn] = focusin,
  48. [KeyPress] = keypress,
  49. [MappingNotify] = mappingnotify,
  50. [MapRequest] = maprequest,
  51. - [MotionNotify] = motionnotify,
  52. [PropertyNotify] = propertynotify,
  53. [UnmapNotify] = unmapnotify
  54. };
  55. @@ -425,7 +421,8 @@ buttonpress(XEvent *e)
  56. click = ClkRootWin;
  57. /* focus monitor if necessary */
  58. - if ((m = wintomon(ev->window)) && m != selmon) {
  59. + if ((m = wintomon(ev->window)) && m != selmon
  60. + && (focusonwheel || (ev->button != Button4 && ev->button != Button5))) {
  61. unfocus(selmon->sel, 1);
  62. selmon = m;
  63. focus(NULL);
  64. @@ -445,8 +442,8 @@ buttonpress(XEvent *e)
  65. else
  66. click = ClkWinTitle;
  67. } else if ((c = wintoclient(ev->window))) {
  68. - focus(c);
  69. - restack(selmon);
  70. + if (focusonwheel || (ev->button != Button4 && ev->button != Button5))
  71. + focus(c);
  72. XAllowEvents(dpy, ReplayPointer, CurrentTime);
  73. click = ClkClientWin;
  74. }
  75. @@ -752,25 +749,6 @@ drawbars(void)
  76. drawbar(m);
  77. }
  78. -void
  79. -enternotify(XEvent *e)
  80. -{
  81. - Client *c;
  82. - Monitor *m;
  83. - XCrossingEvent *ev = &e->xcrossing;
  84. -
  85. - if ((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root)
  86. - return;
  87. - c = wintoclient(ev->window);
  88. - m = c ? c->mon : wintomon(ev->window);
  89. - if (m != selmon) {
  90. - unfocus(selmon->sel, 1);
  91. - selmon = m;
  92. - } else if (!c || c == selmon->sel)
  93. - return;
  94. - focus(c);
  95. -}
  96. -
  97. void
  98. expose(XEvent *e)
  99. {
  100. @@ -1116,23 +1094,6 @@ monocle(Monitor *m)
  101. resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
  102. }
  103. -void
  104. -motionnotify(XEvent *e)
  105. -{
  106. - static Monitor *mon = NULL;
  107. - Monitor *m;
  108. - XMotionEvent *ev = &e->xmotion;
  109. -
  110. - if (ev->window != root)
  111. - return;
  112. - if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
  113. - unfocus(selmon->sel, 1);
  114. - selmon = m;
  115. - focus(NULL);
  116. - }
  117. - mon = m;
  118. -}
  119. -
  120. void
  121. movemouse(const Arg *arg)
  122. {
  123. --
  124. 2.30.0