summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonsykkel <jonrevold@gmail.com>2021-01-05 13:47:30 +0100
committerjonsykkel <jonrevold@gmail.com>2021-01-05 18:55:34 +0100
commitaf5256c30c1c5764ae1c7c0d4edb33b4b722e6a6 (patch)
tree66549c01c8c3f68b7ad228bc9401d56dce39a385
parentc6274a229206d66b9fc7815a8f015710ec82c4c3 (diff)
downloaddwm-af5256c30c1c5764ae1c7c0d4edb33b4b722e6a6.tar.gz
oge
-rw-r--r--config.h1
-rw-r--r--dwm.c83
2 files changed, 67 insertions, 17 deletions
diff --git a/config.h b/config.h
index 6b628b0..acdfb4c 100644
--- a/config.h
+++ b/config.h
@@ -5,7 +5,6 @@ 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[] = { "xos4 Terminus:pixelsize=16:antialias=false" };
static const char dmenufont[] = "xos4 Terminus:pixelsize=16:antialias=false";
static const char col_gray1[] = "#222222";
diff --git a/dwm.c b/dwm.c
index 6f87f7f..733653c 100644
--- a/dwm.c
+++ b/dwm.c
@@ -165,6 +165,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);
@@ -183,6 +184,7 @@ 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 *);
@@ -255,11 +257,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
};
@@ -428,8 +432,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);
@@ -449,10 +452,10 @@ buttonpress(XEvent *e)
else
click = ClkWinTitle;
} else if ((c = wintoclient(ev->window))) {
- if (focusonwheel || (ev->button != Button4 && ev->button != Button5))
- focus(c);
- XAllowEvents(dpy, ReplayPointer, CurrentTime);
- click = ClkClientWin;
+ focus(c);
+ restack(selmon);
+ 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
@@ -719,8 +722,8 @@ drawbar(Monitor *m)
if ((unsigned int)*ts > LENGTH(colors)) { ts++; continue ; }
ctmp = *ts;
*ts = '\0';
- drw_text(drw, m->ww - tw + tx, 0, tw - tx, bh, 0, tp, 0);
- tx += TEXTW(tp) -lrpad;
+ tx = drw_text(drw, m->ww - tw + tx, 0, tw - (m->ww-tx), bh, 0, tp, 0);
+ //tx += TEXTW(tp) -lrpad;
if (ctmp == '\0') { break; }
drw_setscheme(drw, scheme[(unsigned int)(ctmp-1)]);
*ts = ctmp;
@@ -772,6 +775,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;
@@ -784,6 +806,7 @@ expose(XEvent *e)
void
focus(Client *c)
{
+ XWindowChanges wc;
if (!c || !ISVISIBLE(c))
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
if (selmon->sel && selmon->sel != c)
@@ -797,6 +820,11 @@ focus(Client *c)
attachstack(c);
grabbuttons(c, 1);
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
+ if (!c->isfloating) {
+ wc.sibling = selmon->barwin;
+ wc.stack_mode = Below;
+ XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
+ }
setfocus(c);
} else {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
@@ -942,7 +970,7 @@ grabbuttons(Client *c, int focused)
XGrabButton(dpy, buttons[i].button,
buttons[i].mask | modifiers[j],
c->win, False, BUTTONMASK,
-+ GrabModeSync, GrabModeSync, None, None);
+ GrabModeAsync, GrabModeSync, None, None);
}
}
@@ -1113,9 +1141,25 @@ monocle(Monitor *m)
if (n > 0) /* override layout symbol */
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
- resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
+ resize(c, m->wx - c->bw, m->wy, m->ww, m->wh, False);
}
+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)
@@ -1749,14 +1793,21 @@ tile(Monitor *m)
for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
- if (my + HEIGHT(c) < m->wh)
- my += HEIGHT(c);
+// resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
+// if (my + HEIGHT(c) < m->wh)
+// my += HEIGHT(c);
+ if (n == 1)
+ resize(c, m->wx - c->bw, m->wy, m->ww, m->wh, False);
+ else
+ resize(c, m->wx - c->bw, m->wy + my, mw - c->bw, h - c->bw, False);
+ my += HEIGHT(c) - c->bw;
} else {
h = (m->wh - ty) / (n - i);
- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
- if (ty + HEIGHT(c) < m->wh)
- ty += HEIGHT(c);
+// resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
+// if (ty + HEIGHT(c) < m->wh)
+// ty += HEIGHT(c);
+ resize(c, m->wx + mw - c->bw, m->wy + ty, m->ww - mw, h - c->bw, False);
+ ty += HEIGHT(c) - c->bw;
}
}