From 4a14c9b30eb72c973dd4cbafa0c2977910a66394 Mon Sep 17 00:00:00 2001 From: ray Date: Wed, 25 Mar 2020 12:27:42 +0000 Subject: [PATCH 1/2] apply patch: focusonclick --- README | 1 + config.def.h | 1 + config.h | 1 + dwm.c | 53 +++++++--------------------------------------------- 4 files changed, 10 insertions(+), 46 deletions(-) diff --git a/README b/README index 77bff78..6f5716c 100644 --- a/README +++ b/README @@ -61,3 +61,4 @@ Customisations * Merged patch: https://dwm.suckless.org/patches/dwmc/dwm-dwmc-6.2.diff * Merged patch: https: //dwm.suckless.org/patches/cfacts/dwm-cfacts-6.2.diff * Merged patch: https://dwm.suckless.org/patches/fibonacci/dwm-fibonacci-5.8.2.diff +* Merged patch: https://dwm.suckless.org/patches/focusonclick/dwm-focusonclick-20171030-6aa8e37.diff diff --git a/config.def.h b/config.def.h index b17cc80..eef2017 100644 --- a/config.def.h +++ b/config.def.h @@ -5,6 +5,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ +static const int focusonwheel = 0; static const char *fonts[] = { "monospace:size=10" }; static const char dmenufont[] = "monospace:size=10"; static const char col_gray1[] = "#222222"; diff --git a/config.h b/config.h index 08fbd3a..7d0ed54 100644 --- a/config.h +++ b/config.h @@ -5,6 +5,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 0; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ +static const int focusonwheel = 0; static const char *fonts[] = { "xos4 Terminus:size=12" }; static const char dmenufont[] = "xos4 Terminus:size=14"; static const char col_bg[] = "#000000"; diff --git a/dwm.c b/dwm.c index 003e56b..72b2d26 100644 --- a/dwm.c +++ b/dwm.c @@ -170,7 +170,6 @@ static void detachstack(Client *c); static Monitor *dirtomon(int dir); static void drawbar(Monitor *m); static void drawbars(void); -static void enternotify(XEvent *e); static void expose(XEvent *e); static void focus(Client *c); static void focusin(XEvent *e); @@ -188,7 +187,6 @@ static void manage(Window w, XWindowAttributes *wa); static void mappingnotify(XEvent *e); static void maprequest(XEvent *e); static void monocle(Monitor *m); -static void motionnotify(XEvent *e); static void movemouse(const Arg *arg); static Client *nexttiled(Client *c); static void pop(Client *); @@ -260,13 +258,11 @@ static void (*handler[LASTEvent]) (XEvent *) = { [ConfigureRequest] = configurerequest, [ConfigureNotify] = configurenotify, [DestroyNotify] = destroynotify, - [EnterNotify] = enternotify, [Expose] = expose, [FocusIn] = focusin, [KeyPress] = keypress, [MappingNotify] = mappingnotify, [MapRequest] = maprequest, - [MotionNotify] = motionnotify, [PropertyNotify] = propertynotify, [UnmapNotify] = unmapnotify }; @@ -435,7 +431,8 @@ buttonpress(XEvent *e) click = ClkRootWin; /* focus monitor if necessary */ - if ((m = wintomon(ev->window)) && m != selmon) { + if ((m = wintomon(ev->window)) && m != selmon + && (focusonwheel || (ev->button != Button4 && ev->button != Button5))) { unfocus(selmon->sel, 1); selmon = m; focus(NULL); @@ -460,10 +457,10 @@ buttonpress(XEvent *e) else click = ClkWinTitle; } else if ((c = wintoclient(ev->window))) { - focus(c); - restack(selmon); - XAllowEvents(dpy, ReplayPointer, CurrentTime); - click = ClkClientWin; + if (focusonwheel || (ev->button != Button4 && ev->button != Button5)) + focus(c); + XAllowEvents(dpy, ReplayPointer, CurrentTime); + click = ClkClientWin; } for (i = 0; i < LENGTH(buttons); i++) if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button @@ -767,25 +764,6 @@ drawbars(void) drawbar(m); } -void -enternotify(XEvent *e) -{ - Client *c; - Monitor *m; - XCrossingEvent *ev = &e->xcrossing; - - if ((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root) - return; - c = wintoclient(ev->window); - m = c ? c->mon : wintomon(ev->window); - if (m != selmon) { - unfocus(selmon->sel, 1); - selmon = m; - } else if (!c || c == selmon->sel) - return; - focus(c); -} - void expose(XEvent *e) { @@ -958,7 +936,7 @@ grabbuttons(Client *c, int focused) XGrabButton(dpy, buttons[i].button, buttons[i].mask | modifiers[j], c->win, False, BUTTONMASK, - GrabModeAsync, GrabModeSync, None, None); + GrabModeSync, GrabModeSync, None, None); } } @@ -1176,23 +1154,6 @@ monocle(Monitor *m) resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); } -void -motionnotify(XEvent *e) -{ - static Monitor *mon = NULL; - Monitor *m; - XMotionEvent *ev = &e->xmotion; - - if (ev->window != root) - return; - if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) { - unfocus(selmon->sel, 1); - selmon = m; - focus(NULL); - } - mon = m; -} - void movemouse(const Arg *arg) { From 69de0f6d64858be83cf66fcfa4118f0d2c7f9f31 Mon Sep 17 00:00:00 2001 From: ray Date: Wed, 25 Mar 2020 15:55:18 +0000 Subject: [PATCH 2/2] remove warp patch --- README | 1 - dwm.c | 26 -------------------------- 2 files changed, 27 deletions(-) diff --git a/README b/README index 6f5716c..688eba5 100644 --- a/README +++ b/README @@ -57,7 +57,6 @@ Customisations * When moving window to a different tag, focus follows the destination tag. * Merged patch: https://dwm.suckless.org/patches/bottomstack/dwm-bottomstack-6.1.diff * Merged patch: https://dwm.suckless.org/patches/hide_vacant_tags/dwm-hide_vacant_tags-6.2.diff -* Merged patch: https://dwm.suckless.org/patches/warp/dwm-warp-git-20160626-7af4d43.diff * Merged patch: https://dwm.suckless.org/patches/dwmc/dwm-dwmc-6.2.diff * Merged patch: https: //dwm.suckless.org/patches/cfacts/dwm-cfacts-6.2.diff * Merged patch: https://dwm.suckless.org/patches/fibonacci/dwm-fibonacci-5.8.2.diff diff --git a/dwm.c b/dwm.c index 72b2d26..a96e186 100644 --- a/dwm.c +++ b/dwm.c @@ -233,7 +233,6 @@ static void updatetitle(Client *c); static void updatewindowtype(Client *c); static void updatewmhints(Client *c); static void view(const Arg *arg); -static void warp(const Client *c); static Client *wintoclient(Window w); static Monitor *wintomon(Window w); static int xerror(Display *dpy, XErrorEvent *ee); @@ -821,7 +820,6 @@ focusmon(const Arg *arg) unfocus(selmon->sel, 0); selmon = m; focus(NULL); - warp(selmon->sel); } void @@ -1390,8 +1388,6 @@ restack(Monitor *m) } XSync(dpy, False); while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)); - if (m == selmon && (m->tagset[m->seltags] & m->sel->tags) && selmon->lt[selmon->sellt] != &layouts[2]) - warp(m->sel); } void @@ -2095,28 +2091,6 @@ view(const Arg *arg) arrange(selmon); } -void -warp(const Client *c) -{ - int x, y; - - if (!c) { - XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + selmon->ww/2, selmon->wy + selmon->wh/2); - return; - } - - if (!getrootptr(&x, &y) || - (x > c->x - c->bw && - y > c->y - c->bw && - x < c->x + c->w + c->bw*2 && - y < c->y + c->h + c->bw*2) || - (y > c->mon->by && y < c->mon->by + bh) || - (c->mon->topbar && !y)) - return; - - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2); -} - Client * wintoclient(Window w) {