summaryrefslogtreecommitdiff
path: root/dwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c57
1 files changed, 48 insertions, 9 deletions
diff --git a/dwm.c b/dwm.c
index e312ad5..c1e7025 100644
--- a/dwm.c
+++ b/dwm.c
@@ -166,6 +166,7 @@ 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);
@@ -185,6 +186,7 @@ static void managetray(Window win, 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 *);
@@ -259,11 +261,13 @@ 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
};
@@ -432,8 +436,7 @@ buttonpress(XEvent *e)
click = ClkRootWin;
/* focus monitor if necessary */
- if ((m = wintomon(ev->window)) && m != selmon
- && (focusonwheel || (ev->button != Button4 && ev->button != Button5))) {
+ if ((m = wintomon(ev->window)) && m != selmon) {
unfocus(selmon->sel, 1);
selmon = m;
focus(NULL);
@@ -453,8 +456,8 @@ buttonpress(XEvent *e)
else
click = ClkWinTitle;
} else if ((c = wintoclient(ev->window))) {
- if (focusonwheel || (ev->button != Button4 && ev->button != Button5))
- focus(c);
+ focus(c);
+ restack(selmon);
XAllowEvents(dpy, ReplayPointer, CurrentTime);
click = ClkClientWin;
}
@@ -740,10 +743,9 @@ drawbar(Monitor *m)
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
if (occ & 1 << i)
- drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw,
- m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
- urg & 1 << i);
-
+ drw_rect(drw, x + boxs, boxs, boxw, boxw,
+ m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
+ urg & 1 << i);
x += w;
}
w = blw = TEXTW(m->ltsymbol);
@@ -774,6 +776,25 @@ 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;
@@ -1162,6 +1183,23 @@ 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;
@@ -1622,7 +1660,8 @@ setup(void)
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
die("no fonts could be loaded.");
lrpad = drw->fonts->h;
- bh = usealtbar ? 0 : drw->fonts->h + 2;
+ bh = user_bh ? user_bh : drw->fonts->h + 2;
+ //bh = usealtbar ? 0 : drw->fonts->h + 2;
updategeom();
/* init atoms */
utf8string = XInternAtom(dpy, "UTF8_STRING", False);