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