diff options
| author | Warrick Lo <warrick.s.z.lo@gmail.com> | 2021-11-24 03:16:17 -0800 |
|---|---|---|
| committer | Warrick Lo <warrick.s.z.lo@gmail.com> | 2021-11-24 03:16:17 -0800 |
| commit | 680c307f0c74f8fd96e0ca2683c750c402d675ec (patch) | |
| tree | f570b9c6182469f8652862385ed2e6d0ef98ce33 | |
| parent | Add window swallowing support (diff) | |
Window focus now only switches on click
| -rw-r--r-- | config.def.h | 2 | ||||
| -rw-r--r-- | dwm.c | 49 |
2 files changed, 6 insertions, 45 deletions
diff --git a/config.def.h b/config.def.h index 4195692..d40c2c6 100644 --- a/config.def.h +++ b/config.def.h @@ -8,6 +8,7 @@ static const unsigned int snap = 32; /* snap pixel */ static const int swallowfloating = 0; /* 1 means swallow floating windows by default */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ +static const int focusonwheel = 0; /* 1 means scrolling will switch focus */ static const char *fonts[] = { "monospace:size=10" }; static const char dmenufont[] = "monospace:size=10"; static const char col_gray1[] = "#222222"; @@ -129,4 +130,3 @@ static Button buttons[] = { { ClkTagBar, MODKEY, Button1, tag, {0} }, { ClkTagBar, MODKEY, Button3, toggletag, {0} }, }; - @@ -141,7 +141,7 @@ struct Monitor { int num; int by; /* bar geometry */ int mx, my, mw, mh; /* screen size */ - int wx, wy, ww, wh; /* window area */ + int wx, wy, ww, wh; /* window area */ unsigned int seltags; unsigned int sellt; unsigned int tagset[2]; @@ -191,7 +191,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); @@ -212,7 +211,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 void movestack(const Arg *arg); static Client *nexttagged(Client *c); @@ -294,13 +292,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 }; @@ -523,7 +519,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); @@ -543,8 +540,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; } @@ -875,25 +872,6 @@ drawbars(void) } 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) { Monitor *m; @@ -1295,23 +1273,6 @@ monocle(Monitor *m) } 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) { int x, y, ocx, ocy, nx, ny; |