Last active
April 20, 2021 05:35
-
-
Save ahauser31/ab71acbaec049561981cb075633fd7c6 to your computer and use it in GitHub Desktop.
Diff to strip out keyboard, mouse and bar from vanilla dwm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/config.def.h b/config.def.h | |
index 1c0b587..0947189 100644 | |
--- a/config.def.h | |
+++ b/config.def.h | |
@@ -3,10 +3,6 @@ | |
/* appearance */ | |
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 char *fonts[] = { "monospace:size=10" }; | |
-static const char dmenufont[] = "monospace:size=10"; | |
static const char col_gray1[] = "#222222"; | |
static const char col_gray2[] = "#444444"; | |
static const char col_gray3[] = "#bbbbbb"; | |
@@ -19,7 +15,7 @@ static const char *colors[][3] = { | |
}; | |
/* tagging */ | |
-static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; | |
+#define NUMTAGS 9 | |
static const Rule rules[] = { | |
/* xprop(1): | |
@@ -43,73 +39,3 @@ static const Layout layouts[] = { | |
{ "[M]", monocle }, | |
}; | |
-/* key definitions */ | |
-#define MODKEY Mod1Mask | |
-#define TAGKEYS(KEY,TAG) \ | |
- { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ | |
- { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ | |
- { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ | |
- { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, | |
- | |
-/* helper for spawning shell commands in the pre dwm-5.0 fashion */ | |
-#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } | |
- | |
-/* commands */ | |
-static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ | |
-static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; | |
-static const char *termcmd[] = { "st", NULL }; | |
- | |
-static Key keys[] = { | |
- /* modifier key function argument */ | |
- { MODKEY, XK_p, spawn, {.v = dmenucmd } }, | |
- { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, | |
- { MODKEY, XK_b, togglebar, {0} }, | |
- { MODKEY, XK_j, focusstack, {.i = +1 } }, | |
- { MODKEY, XK_k, focusstack, {.i = -1 } }, | |
- { MODKEY, XK_i, incnmaster, {.i = +1 } }, | |
- { MODKEY, XK_d, incnmaster, {.i = -1 } }, | |
- { MODKEY, XK_h, setmfact, {.f = -0.05} }, | |
- { MODKEY, XK_l, setmfact, {.f = +0.05} }, | |
- { MODKEY, XK_Return, zoom, {0} }, | |
- { MODKEY, XK_Tab, view, {0} }, | |
- { MODKEY|ShiftMask, XK_c, killclient, {0} }, | |
- { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, | |
- { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, | |
- { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, | |
- { MODKEY, XK_space, setlayout, {0} }, | |
- { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, | |
- { MODKEY, XK_0, view, {.ui = ~0 } }, | |
- { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, | |
- { MODKEY, XK_comma, focusmon, {.i = -1 } }, | |
- { MODKEY, XK_period, focusmon, {.i = +1 } }, | |
- { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, | |
- { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, | |
- TAGKEYS( XK_1, 0) | |
- TAGKEYS( XK_2, 1) | |
- TAGKEYS( XK_3, 2) | |
- TAGKEYS( XK_4, 3) | |
- TAGKEYS( XK_5, 4) | |
- TAGKEYS( XK_6, 5) | |
- TAGKEYS( XK_7, 6) | |
- TAGKEYS( XK_8, 7) | |
- TAGKEYS( XK_9, 8) | |
- { MODKEY|ShiftMask, XK_q, quit, {0} }, | |
-}; | |
- | |
-/* button definitions */ | |
-/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ | |
-static Button buttons[] = { | |
- /* click event mask button function argument */ | |
- { ClkLtSymbol, 0, Button1, setlayout, {0} }, | |
- { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, | |
- { ClkWinTitle, 0, Button2, zoom, {0} }, | |
- { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, | |
- { ClkClientWin, MODKEY, Button1, movemouse, {0} }, | |
- { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, | |
- { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, | |
- { ClkTagBar, 0, Button1, view, {0} }, | |
- { ClkTagBar, 0, Button3, toggleview, {0} }, | |
- { ClkTagBar, MODKEY, Button1, tag, {0} }, | |
- { ClkTagBar, MODKEY, Button3, toggletag, {0} }, | |
-}; | |
- | |
diff --git a/dwm.c b/dwm.c | |
index 664c527..1312c42 100644 | |
--- a/dwm.c | |
+++ b/dwm.c | |
@@ -31,7 +31,6 @@ | |
#include <sys/types.h> | |
#include <sys/wait.h> | |
#include <X11/cursorfont.h> | |
-#include <X11/keysym.h> | |
#include <X11/Xatom.h> | |
#include <X11/Xlib.h> | |
#include <X11/Xproto.h> | |
@@ -46,16 +45,15 @@ | |
/* macros */ | |
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) | |
-#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) | |
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \ | |
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy))) | |
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) | |
#define LENGTH(X) (sizeof X / sizeof X[0]) | |
-#define MOUSEMASK (BUTTONMASK|PointerMotionMask) | |
#define WIDTH(X) ((X)->w + 2 * (X)->bw) | |
#define HEIGHT(X) ((X)->h + 2 * (X)->bw) | |
-#define TAGMASK ((1 << LENGTH(tags)) - 1) | |
-#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) | |
+#define TAGMASK ((1 << NUMTAGS) - 1) | |
+ | |
+#define MINHEIGHT 10 | |
/* enums */ | |
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ | |
@@ -74,14 +72,6 @@ typedef union { | |
const void *v; | |
} Arg; | |
-typedef struct { | |
- unsigned int click; | |
- unsigned int mask; | |
- unsigned int button; | |
- void (*func)(const Arg *arg); | |
- const Arg arg; | |
-} Button; | |
- | |
typedef struct Monitor Monitor; | |
typedef struct Client Client; | |
struct Client { | |
@@ -99,13 +89,6 @@ struct Client { | |
Window win; | |
}; | |
-typedef struct { | |
- unsigned int mod; | |
- KeySym keysym; | |
- void (*func)(const Arg *); | |
- const Arg arg; | |
-} Key; | |
- | |
typedef struct { | |
const char *symbol; | |
void (*arrange)(Monitor *); | |
@@ -116,19 +99,16 @@ struct Monitor { | |
float mfact; | |
int nmaster; | |
int num; | |
- int by; /* bar geometry */ | |
int mx, my, mw, mh; /* screen size */ | |
int wx, wy, ww, wh; /* window area */ | |
unsigned int seltags; | |
unsigned int sellt; | |
unsigned int tagset[2]; | |
- int showbar; | |
- int topbar; | |
Client *clients; | |
Client *sel; | |
Client *stack; | |
Monitor *next; | |
- Window barwin; | |
const Layout *lt[2]; | |
}; | |
@@ -161,10 +141,6 @@ static void destroynotify(XEvent *e); | |
static void detach(Client *c); | |
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); | |
static void focusmon(const Arg *arg); | |
@@ -173,17 +149,11 @@ static Atom getatomprop(Client *c, Atom prop); | |
static int getrootptr(int *x, int *y); | |
static long getstate(Window w); | |
static int gettextprop(Window w, Atom atom, char *text, unsigned int size); | |
-static void grabbuttons(Client *c, int focused); | |
-static void grabkeys(void); | |
static void incnmaster(const Arg *arg); | |
-static void keypress(XEvent *e); | |
static void killclient(const Arg *arg); | |
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 *); | |
static void propertynotify(XEvent *e); | |
@@ -191,7 +161,6 @@ static void quit(const Arg *arg); | |
static Monitor *recttomon(int x, int y, int w, int h); | |
static void resize(Client *c, int x, int y, int w, int h, int interact); | |
static void resizeclient(Client *c, int x, int y, int w, int h); | |
-static void resizemouse(const Arg *arg); | |
static void restack(Monitor *m); | |
static void run(void); | |
static void scan(void); | |
@@ -210,20 +179,15 @@ static void spawn(const Arg *arg); | |
static void tag(const Arg *arg); | |
static void tagmon(const Arg *arg); | |
static void tile(Monitor *); | |
-static void togglebar(const Arg *arg); | |
static void togglefloating(const Arg *arg); | |
static void toggletag(const Arg *arg); | |
static void toggleview(const Arg *arg); | |
static void unfocus(Client *c, int setfocus); | |
static void unmanage(Client *c, int destroyed); | |
static void unmapnotify(XEvent *e); | |
-static void updatebarpos(Monitor *m); | |
-static void updatebars(void); | |
static void updateclientlist(void); | |
static int updategeom(void); | |
-static void updatenumlockmask(void); | |
static void updatesizehints(Client *c); | |
-static void updatestatus(void); | |
static void updatetitle(Client *c); | |
static void updatewindowtype(Client *c); | |
static void updatewmhints(Client *c); | |
@@ -237,26 +201,17 @@ static void zoom(const Arg *arg); | |
/* variables */ | |
static const char broken[] = "broken"; | |
-static char stext[256]; | |
static int screen; | |
static int sw, sh; /* X display screen geometry width, height */ | |
-static int bh, blw = 0; /* bar geometry */ | |
-static int lrpad; /* sum of left and right padding for text */ | |
static int (*xerrorxlib)(Display *, XErrorEvent *); | |
-static unsigned int numlockmask = 0; | |
static void (*handler[LASTEvent]) (XEvent *) = { | |
[ButtonPress] = buttonpress, | |
[ClientMessage] = clientmessage, | |
[ConfigureRequest] = configurerequest, | |
[ConfigureNotify] = configurenotify, | |
[DestroyNotify] = destroynotify, | |
- [EnterNotify] = enternotify, | |
- [Expose] = expose, | |
[FocusIn] = focusin, | |
- [KeyPress] = keypress, | |
- [MappingNotify] = mappingnotify, | |
[MapRequest] = maprequest, | |
- [MotionNotify] = motionnotify, | |
[PropertyNotify] = propertynotify, | |
[UnmapNotify] = unmapnotify | |
}; | |
@@ -273,7 +228,7 @@ static Window root, wmcheckwin; | |
#include "config.h" | |
/* compile-time check if all tags fit into an unsigned int bit array. */ | |
-struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; | |
+struct NumTags { char limitexceeded[NUMTAGS > 31 ? -1 : 1]; }; | |
/* function implementations */ | |
void | |
@@ -340,10 +295,10 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact) | |
if (*y + *h + 2 * c->bw <= m->wy) | |
*y = m->wy; | |
} | |
- if (*h < bh) | |
- *h = bh; | |
- if (*w < bh) | |
- *w = bh; | |
+ if (*h < MINHEIGHT) | |
+ *h = MINHEIGHT; | |
+ if (*w < MINHEIGHT) | |
+ *w = MINHEIGHT; | |
if (resizehints || c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) { | |
/* see last two sentences in ICCCM 4.1.2.3 */ | |
baseismin = c->basew == c->minw && c->baseh == c->minh; | |
@@ -417,43 +372,22 @@ attachstack(Client *c) | |
void | |
buttonpress(XEvent *e) | |
{ | |
- unsigned int i, x, click; | |
- Arg arg = {0}; | |
Client *c; | |
Monitor *m; | |
XButtonPressedEvent *ev = &e->xbutton; | |
- click = ClkRootWin; | |
/* focus monitor if necessary */ | |
if ((m = wintomon(ev->window)) && m != selmon) { | |
unfocus(selmon->sel, 1); | |
selmon = m; | |
focus(NULL); | |
} | |
- if (ev->window == selmon->barwin) { | |
- i = x = 0; | |
- do | |
- x += TEXTW(tags[i]); | |
- while (ev->x >= x && ++i < LENGTH(tags)); | |
- if (i < LENGTH(tags)) { | |
- click = ClkTagBar; | |
- arg.ui = 1 << i; | |
- } else if (ev->x < x + blw) | |
- click = ClkLtSymbol; | |
- else if (ev->x > selmon->ww - (int)TEXTW(stext)) | |
- click = ClkStatusText; | |
- else | |
- click = ClkWinTitle; | |
- } else if ((c = wintoclient(ev->window))) { | |
+ /* focus on window if clicked */ | |
+ if ((c = wintoclient(ev->window))) { | |
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 | |
- && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) | |
- buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg); | |
} | |
void | |
@@ -505,8 +439,6 @@ cleanupmon(Monitor *mon) | |
for (m = mons; m && m->next != mon; m = m->next); | |
m->next = mon->next; | |
} | |
- XUnmapWindow(dpy, mon->barwin); | |
- XDestroyWindow(dpy, mon->barwin); | |
free(mon); | |
} | |
@@ -562,13 +494,10 @@ configurenotify(XEvent *e) | |
sw = ev->width; | |
sh = ev->height; | |
if (updategeom() || dirty) { | |
- drw_resize(drw, sw, bh); | |
- updatebars(); | |
for (m = mons; m; m = m->next) { | |
for (c = m->clients; c; c = c->next) | |
if (c->isfullscreen) | |
resizeclient(c, m->mx, m->my, m->mw, m->mh); | |
- XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); | |
} | |
focus(NULL); | |
arrange(NULL); | |
@@ -637,8 +566,7 @@ createmon(void) | |
m->tagset[0] = m->tagset[1] = 1; | |
m->mfact = mfact; | |
m->nmaster = nmaster; | |
- m->showbar = showbar; | |
- m->topbar = topbar; | |
m->lt[0] = &layouts[0]; | |
m->lt[1] = &layouts[1 % LENGTH(layouts)]; | |
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); | |
@@ -693,94 +621,6 @@ dirtomon(int dir) | |
return m; | |
} | |
-void | |
-drawbar(Monitor *m) | |
-{ | |
- int x, w, tw = 0; | |
- int boxs = drw->fonts->h / 9; | |
- int boxw = drw->fonts->h / 6 + 2; | |
- unsigned int i, occ = 0, urg = 0; | |
- Client *c; | |
- | |
- /* draw status first so it can be overdrawn by tags later */ | |
- if (m == selmon) { /* status is only drawn on selected monitor */ | |
- drw_setscheme(drw, scheme[SchemeNorm]); | |
- tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ | |
- drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); | |
- } | |
- | |
- for (c = m->clients; c; c = c->next) { | |
- occ |= c->tags; | |
- if (c->isurgent) | |
- urg |= c->tags; | |
- } | |
- x = 0; | |
- for (i = 0; i < LENGTH(tags); i++) { | |
- w = TEXTW(tags[i]); | |
- 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 + boxs, boxs, boxw, boxw, | |
- m == selmon && selmon->sel && selmon->sel->tags & 1 << i, | |
- urg & 1 << i); | |
- x += w; | |
- } | |
- w = blw = TEXTW(m->ltsymbol); | |
- drw_setscheme(drw, scheme[SchemeNorm]); | |
- x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); | |
- | |
- if ((w = m->ww - tw - x) > bh) { | |
- if (m->sel) { | |
- drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); | |
- drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); | |
- if (m->sel->isfloating) | |
- drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); | |
- } else { | |
- drw_setscheme(drw, scheme[SchemeNorm]); | |
- drw_rect(drw, x, 0, w, bh, 1, 1); | |
- } | |
- } | |
- drw_map(drw, m->barwin, 0, 0, m->ww, bh); | |
-} | |
- | |
-void | |
-drawbars(void) | |
-{ | |
- Monitor *m; | |
- | |
- for (m = mons; m; m = m->next) | |
- 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) | |
-{ | |
- Monitor *m; | |
- XExposeEvent *ev = &e->xexpose; | |
- | |
- if (ev->count == 0 && (m = wintomon(ev->window))) | |
- drawbar(m); | |
-} | |
- | |
void | |
focus(Client *c) | |
{ | |
@@ -795,7 +635,7 @@ focus(Client *c) | |
seturgent(c, 0); | |
detachstack(c); | |
attachstack(c); | |
- grabbuttons(c, 1); | |
+ XUngrabButton(dpy, AnyButton, AnyModifier, c->win); | |
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); | |
setfocus(c); | |
} else { | |
@@ -803,7 +643,6 @@ focus(Client *c) | |
XDeleteProperty(dpy, root, netatom[NetActiveWindow]); | |
} | |
selmon->sel = c; | |
- drawbars(); | |
} | |
/* there are some broken focus acquiring clients needing extra handling */ | |
@@ -925,45 +764,6 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size) | |
return 1; | |
} | |
-void | |
-grabbuttons(Client *c, int focused) | |
-{ | |
- updatenumlockmask(); | |
- { | |
- unsigned int i, j; | |
- unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask }; | |
- XUngrabButton(dpy, AnyButton, AnyModifier, c->win); | |
- if (!focused) | |
- XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, | |
- BUTTONMASK, GrabModeSync, GrabModeSync, None, None); | |
- for (i = 0; i < LENGTH(buttons); i++) | |
- if (buttons[i].click == ClkClientWin) | |
- for (j = 0; j < LENGTH(modifiers); j++) | |
- XGrabButton(dpy, buttons[i].button, | |
- buttons[i].mask | modifiers[j], | |
- c->win, False, BUTTONMASK, | |
- GrabModeAsync, GrabModeSync, None, None); | |
- } | |
-} | |
- | |
-void | |
-grabkeys(void) | |
-{ | |
- updatenumlockmask(); | |
- { | |
- unsigned int i, j; | |
- unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask }; | |
- KeyCode code; | |
- | |
- XUngrabKey(dpy, AnyKey, AnyModifier, root); | |
- for (i = 0; i < LENGTH(keys); i++) | |
- if ((code = XKeysymToKeycode(dpy, keys[i].keysym))) | |
- for (j = 0; j < LENGTH(modifiers); j++) | |
- XGrabKey(dpy, code, keys[i].mod | modifiers[j], root, | |
- True, GrabModeAsync, GrabModeAsync); | |
- } | |
-} | |
- | |
void | |
incnmaster(const Arg *arg) | |
{ | |
@@ -983,22 +783,6 @@ isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info) | |
} | |
#endif /* XINERAMA */ | |
-void | |
-keypress(XEvent *e) | |
-{ | |
- unsigned int i; | |
- KeySym keysym; | |
- XKeyEvent *ev; | |
- | |
- ev = &e->xkey; | |
- keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); | |
- for (i = 0; i < LENGTH(keys); i++) | |
- if (keysym == keys[i].keysym | |
- && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state) | |
- && keys[i].func) | |
- keys[i].func(&(keys[i].arg)); | |
-} | |
- | |
void | |
killclient(const Arg *arg) | |
{ | |
@@ -1045,9 +829,7 @@ manage(Window w, XWindowAttributes *wa) | |
if (c->y + HEIGHT(c) > c->mon->my + c->mon->mh) | |
c->y = c->mon->my + c->mon->mh - HEIGHT(c); | |
c->x = MAX(c->x, c->mon->mx); | |
- /* only fix client y-offset, if the client center might cover the bar */ | |
- c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx) | |
- && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); | |
+ c->y = c->mon->my; | |
c->bw = borderpx; | |
wc.border_width = c->bw; | |
@@ -1058,7 +840,8 @@ manage(Window w, XWindowAttributes *wa) | |
updatesizehints(c); | |
updatewmhints(c); | |
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); | |
- grabbuttons(c, 0); | |
+ XUngrabButton(dpy, AnyButton, AnyModifier, c->win); | |
+ XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK, GrabModeSync, GrabModeSync, None, None); | |
if (!c->isfloating) | |
c->isfloating = c->oldstate = trans != None || c->isfixed; | |
if (c->isfloating) | |
@@ -1077,16 +860,6 @@ manage(Window w, XWindowAttributes *wa) | |
focus(NULL); | |
} | |
-void | |
-mappingnotify(XEvent *e) | |
-{ | |
- XMappingEvent *ev = &e->xmapping; | |
- | |
- XRefreshKeyboardMapping(ev); | |
- if (ev->request == MappingKeyboard) | |
- grabkeys(); | |
-} | |
- | |
void | |
maprequest(XEvent *e) | |
{ | |
@@ -1116,83 +889,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) | |
-{ | |
- int x, y, ocx, ocy, nx, ny; | |
- Client *c; | |
- Monitor *m; | |
- XEvent ev; | |
- Time lasttime = 0; | |
- | |
- if (!(c = selmon->sel)) | |
- return; | |
- if (c->isfullscreen) /* no support moving fullscreen windows by mouse */ | |
- return; | |
- restack(selmon); | |
- ocx = c->x; | |
- ocy = c->y; | |
- if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, | |
- None, cursor[CurMove]->cursor, CurrentTime) != GrabSuccess) | |
- return; | |
- if (!getrootptr(&x, &y)) | |
- return; | |
- do { | |
- XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); | |
- switch(ev.type) { | |
- case ConfigureRequest: | |
- case Expose: | |
- case MapRequest: | |
- handler[ev.type](&ev); | |
- break; | |
- case MotionNotify: | |
- if ((ev.xmotion.time - lasttime) <= (1000 / 60)) | |
- continue; | |
- lasttime = ev.xmotion.time; | |
- | |
- nx = ocx + (ev.xmotion.x - x); | |
- ny = ocy + (ev.xmotion.y - y); | |
- if (abs(selmon->wx - nx) < snap) | |
- nx = selmon->wx; | |
- else if (abs((selmon->wx + selmon->ww) - (nx + WIDTH(c))) < snap) | |
- nx = selmon->wx + selmon->ww - WIDTH(c); | |
- if (abs(selmon->wy - ny) < snap) | |
- ny = selmon->wy; | |
- else if (abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap) | |
- ny = selmon->wy + selmon->wh - HEIGHT(c); | |
- if (!c->isfloating && selmon->lt[selmon->sellt]->arrange | |
- && (abs(nx - c->x) > snap || abs(ny - c->y) > snap)) | |
- togglefloating(NULL); | |
- if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) | |
- resize(c, nx, ny, c->w, c->h, 1); | |
- break; | |
- } | |
- } while (ev.type != ButtonRelease); | |
- XUngrabPointer(dpy, CurrentTime); | |
- if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { | |
- sendmon(c, m); | |
- selmon = m; | |
- focus(NULL); | |
- } | |
-} | |
- | |
Client * | |
nexttiled(Client *c) | |
{ | |
@@ -1216,9 +912,7 @@ propertynotify(XEvent *e) | |
Window trans; | |
XPropertyEvent *ev = &e->xproperty; | |
- if ((ev->window == root) && (ev->atom == XA_WM_NAME)) | |
- updatestatus(); | |
- else if (ev->state == PropertyDelete) | |
+ if (ev->state == PropertyDelete) | |
return; /* ignore */ | |
else if ((c = wintoclient(ev->window))) { | |
switch(ev->atom) { | |
@@ -1233,13 +927,10 @@ propertynotify(XEvent *e) | |
break; | |
case XA_WM_HINTS: | |
updatewmhints(c); | |
- drawbars(); | |
break; | |
} | |
if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { | |
updatetitle(c); | |
- if (c == c->mon->sel) | |
- drawbar(c->mon); | |
} | |
if (ev->atom == netatom[NetWMWindowType]) | |
updatewindowtype(c); | |
@@ -1288,63 +979,6 @@ resizeclient(Client *c, int x, int y, int w, int h) | |
XSync(dpy, False); | |
} | |
-void | |
-resizemouse(const Arg *arg) | |
-{ | |
- int ocx, ocy, nw, nh; | |
- Client *c; | |
- Monitor *m; | |
- XEvent ev; | |
- Time lasttime = 0; | |
- | |
- if (!(c = selmon->sel)) | |
- return; | |
- if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */ | |
- return; | |
- restack(selmon); | |
- ocx = c->x; | |
- ocy = c->y; | |
- if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, | |
- None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess) | |
- return; | |
- XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); | |
- do { | |
- XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); | |
- switch(ev.type) { | |
- case ConfigureRequest: | |
- case Expose: | |
- case MapRequest: | |
- handler[ev.type](&ev); | |
- break; | |
- case MotionNotify: | |
- if ((ev.xmotion.time - lasttime) <= (1000 / 60)) | |
- continue; | |
- lasttime = ev.xmotion.time; | |
- | |
- nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); | |
- nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); | |
- if (c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww | |
- && c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh) | |
- { | |
- if (!c->isfloating && selmon->lt[selmon->sellt]->arrange | |
- && (abs(nw - c->w) > snap || abs(nh - c->h) > snap)) | |
- togglefloating(NULL); | |
- } | |
- if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) | |
- resize(c, c->x, c->y, nw, nh, 1); | |
- break; | |
- } | |
- } while (ev.type != ButtonRelease); | |
- XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); | |
- XUngrabPointer(dpy, CurrentTime); | |
- while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)); | |
- if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { | |
- sendmon(c, m); | |
- selmon = m; | |
- focus(NULL); | |
- } | |
-} | |
- | |
void | |
restack(Monitor *m) | |
{ | |
@@ -1352,14 +986,12 @@ restack(Monitor *m) | |
XEvent ev; | |
XWindowChanges wc; | |
- drawbar(m); | |
if (!m->sel) | |
return; | |
if (m->sel->isfloating || !m->lt[m->sellt]->arrange) | |
XRaiseWindow(dpy, m->sel->win); | |
if (m->lt[m->sellt]->arrange) { | |
wc.stack_mode = Below; | |
- wc.sibling = m->barwin; | |
for (c = m->stack; c; c = c->snext) | |
if (!c->isfloating && ISVISIBLE(c)) { | |
XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc); | |
@@ -1508,8 +1140,6 @@ setlayout(const Arg *arg) | |
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol); | |
if (selmon->sel) | |
arrange(selmon); | |
- else | |
- drawbar(selmon); | |
} | |
/* arg > 1.0 will set mfact absolutely */ | |
@@ -1543,10 +1173,6 @@ setup(void) | |
sh = DisplayHeight(dpy, screen); | |
root = RootWindow(dpy, screen); | |
drw = drw_create(dpy, screen, root, sw, sh); | |
- if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) | |
- die("no fonts could be loaded."); | |
- lrpad = drw->fonts->h; | |
- bh = drw->fonts->h + 2; | |
updategeom(); | |
/* init atoms */ | |
utf8string = XInternAtom(dpy, "UTF8_STRING", False); | |
@@ -1571,9 +1197,6 @@ setup(void) | |
scheme = ecalloc(LENGTH(colors), sizeof(Clr *)); | |
for (i = 0; i < LENGTH(colors); i++) | |
scheme[i] = drw_scm_create(drw, colors[i], 3); | |
- /* init bars */ | |
- updatebars(); | |
- updatestatus(); | |
/* supporting window for NetWMCheck */ | |
wmcheckwin = XCreateSimpleWindow(dpy, root, 0, 0, 1, 1, 0, 0, 0); | |
XChangeProperty(dpy, wmcheckwin, netatom[NetWMCheck], XA_WINDOW, 32, | |
@@ -1593,7 +1216,6 @@ setup(void) | |
|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask; | |
XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa); | |
XSelectInput(dpy, root, wa.event_mask); | |
- grabkeys(); | |
focus(NULL); | |
} | |
@@ -1640,8 +1262,6 @@ sigchld(int unused) | |
void | |
spawn(const Arg *arg) | |
{ | |
- if (arg->v == dmenucmd) | |
- dmenumon[0] = '0' + selmon->num; | |
if (fork() == 0) { | |
if (dpy) | |
close(ConnectionNumber(dpy)); | |
@@ -1699,15 +1319,6 @@ tile(Monitor *m) | |
} | |
} | |
-void | |
-togglebar(const Arg *arg) | |
-{ | |
- selmon->showbar = !selmon->showbar; | |
- updatebarpos(selmon); | |
- XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); | |
- arrange(selmon); | |
-} | |
- | |
void | |
togglefloating(const Arg *arg) | |
{ | |
@@ -1754,8 +1365,11 @@ unfocus(Client *c, int setfocus) | |
{ | |
if (!c) | |
return; | |
- grabbuttons(c, 0); | |
+ | |
+ XUngrabButton(dpy, AnyButton, AnyModifier, c->win); | |
+ XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK, GrabModeSync, GrabModeSync, None, None); | |
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel); | |
+ | |
if (setfocus) { | |
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); | |
XDeleteProperty(dpy, root, netatom[NetActiveWindow]); | |
@@ -1801,41 +1415,6 @@ unmapnotify(XEvent *e) | |
} | |
} | |
-void | |
-updatebars(void) | |
-{ | |
- Monitor *m; | |
- XSetWindowAttributes wa = { | |
- .override_redirect = True, | |
- .background_pixmap = ParentRelative, | |
- .event_mask = ButtonPressMask|ExposureMask | |
- }; | |
- XClassHint ch = {"dwm", "dwm"}; | |
- for (m = mons; m; m = m->next) { | |
- if (m->barwin) | |
- continue; | |
- m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen), | |
- CopyFromParent, DefaultVisual(dpy, screen), | |
- CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); | |
- XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); | |
- XMapRaised(dpy, m->barwin); | |
- XSetClassHint(dpy, m->barwin, &ch); | |
- } | |
-} | |
- | |
-void | |
-updatebarpos(Monitor *m) | |
-{ | |
- m->wy = m->my; | |
- m->wh = m->mh; | |
- if (m->showbar) { | |
- m->wh -= bh; | |
- m->by = m->topbar ? m->wy : m->wy + m->wh; | |
- m->wy = m->topbar ? m->wy + bh : m->wy; | |
- } else | |
- m->by = -bh; | |
-} | |
- | |
void | |
updateclientlist() | |
{ | |
@@ -1890,7 +1469,6 @@ updategeom(void) | |
m->my = m->wy = unique[i].y_org; | |
m->mw = m->ww = unique[i].width; | |
m->mh = m->wh = unique[i].height; | |
- updatebarpos(m); | |
} | |
} else { /* less monitors available nn < n */ | |
for (i = nn; i < n; i++) { | |
@@ -1918,7 +1496,6 @@ updategeom(void) | |
dirty = 1; | |
mons->mw = mons->ww = sw; | |
mons->mh = mons->wh = sh; | |
- updatebarpos(mons); | |
} | |
} | |
if (dirty) { | |
@@ -1928,22 +1505,6 @@ updategeom(void) | |
return dirty; | |
} | |
-void | |
-updatenumlockmask(void) | |
-{ | |
- unsigned int i, j; | |
- XModifierKeymap *modmap; | |
- | |
- numlockmask = 0; | |
- modmap = XGetModifierMapping(dpy); | |
- for (i = 0; i < 8; i++) | |
- for (j = 0; j < modmap->max_keypermod; j++) | |
- if (modmap->modifiermap[i * modmap->max_keypermod + j] | |
- == XKeysymToKeycode(dpy, XK_Num_Lock)) | |
- numlockmask = (1 << i); | |
- XFreeModifiermap(modmap); | |
-} | |
- | |
void | |
updatesizehints(Client *c) | |
{ | |
@@ -1987,14 +1548,6 @@ updatesizehints(Client *c) | |
c->isfixed = (c->maxw && c->maxh && c->maxw == c->minw && c->maxh == c->minh); | |
} | |
-void | |
-updatestatus(void) | |
-{ | |
- if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) | |
- strcpy(stext, "dwm-"VERSION); | |
- drawbar(selmon); | |
-} | |
- | |
void | |
updatetitle(Client *c) | |
{ | |
@@ -2065,13 +1618,9 @@ wintomon(Window w) | |
{ | |
int x, y; | |
Client *c; | |
- Monitor *m; | |
if (w == root && getrootptr(&x, &y)) | |
return recttomon(x, y, 1, 1); | |
- for (m = mons; m; m = m->next) | |
- if (w == m->barwin) | |
- return m; | |
if ((c = wintoclient(w))) | |
return c->mon; | |
return selmon; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment