commit: c9f843478056acb4c269ce89840e2649971f9a0a
parent: 19f9d53f2d5b1861e3f0873bf83819038414100c
author: Chris Noxz <chris@noxz.tech>
date: Tue, 4 Feb 2020 22:21:15 +0100
Remove support for mouse focus change on hover
2 files changed, 6 insertions(+), 44 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -6,6 +6,7 @@ static const unsigned int borderpx = 2; /* 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/dwm.c b/dwm.c
@@ -180,7 +180,6 @@ static void drawbar(Monitor *m);
static void drawbars(void);
static void enqueue(Client *c);
static void enqueuestack(Client *c);
-static void enternotify(XEvent *e);
static Bool evpredicate();
static void expose(XEvent *e);
static void focus(Client *c);
@@ -199,7 +198,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 *);
@@ -275,13 +273,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
};
@@ -460,7 +456,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);
@@ -480,8 +477,8 @@ buttonpress(XEvent *e)
else
click = ClkWinTitle;
} else if ((c = wintoclient(ev->window))) {
- focus(c);
- restack(selmon);
+ if (focusonwheel || (ev->button != Button4 && ev->button != Button5))
+ focus(c);
XAllowEvents(dpy, ReplayPointer, CurrentTime);
click = ClkClientWin;
}
@@ -924,25 +921,6 @@ enqueuestack(Client *c)
}
}
-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);
-}
-
Bool
evpredicate()
{
@@ -1123,7 +1101,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);
}
}
@@ -1302,23 +1280,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)
{