summaryrefslogtreecommitdiff
path: root/dwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c146
1 files changed, 70 insertions, 76 deletions
diff --git a/dwm.c b/dwm.c
index be13dda..603497c 100644
--- a/dwm.c
+++ b/dwm.c
@@ -56,10 +56,10 @@
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx)
#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx)
-#define NUMTAGS (LENGTH(tags) + LENGTH(scratchpads))
-#define TAGMASK ((1 << NUMTAGS) - 1)
-#define SPTAG(i) ((1 << LENGTH(tags) << (i)))
-#define SPTAGMASK (((1 << LENGTH(scratchpads))-1) << LENGTH(tags))
+#define NUMTAGS (LENGTH(tags) + LENGTH(scratchpads))
+#define TAGMASK ((1 << NUMTAGS) - 1)
+#define SPTAG(i) ((1 << LENGTH(tags)) << (i))
+#define SPTAGMASK (((1 << LENGTH(scratchpads))-1) << LENGTH(tags))
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
#define SYSTEM_TRAY_REQUEST_DOCK 0
@@ -213,8 +213,8 @@ static void focus(Client *c);
static void focusin(XEvent *e);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
-static int getdwmblockspid();
static Atom getatomprop(Client *c, Atom prop);
+static int getdwmblockspid();
static int getrootptr(int *x, int *y);
static long getstate(Window w);
static unsigned int getsystraywidth();
@@ -231,7 +231,7 @@ 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 pop(Client *);
static Client *prevtiled(Client *c);
static void propertynotify(XEvent *e);
static void pushdown(const Arg *arg);
@@ -310,10 +310,10 @@ static Client *prevzoom = NULL;
static Systray *systray = NULL;
static const char broken[] = "broken";
static char stext[256];
+static int scanner;
static char rawstext[256];
static int dwmblockssig;
pid_t dwmblockspid = 0;
-static int scanner;
static int screen;
static int sw, sh; /* X display screen geometry width, height */
static int bh, blw = 0; /* bar geometry */
@@ -432,7 +432,7 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact)
*h = bh;
if (*w < bh)
*w = bh;
- if ((resizehints && !c->isterminal) || c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) {
+ 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;
if (!baseismin) { /* temporarily remove base dimensions */
@@ -603,25 +603,26 @@ buttonpress(XEvent *e)
arg.ui = 1 << i;
} else if (ev->x < x + blw)
click = ClkLtSymbol;
- else if (ev->x > (x = selmon->ww - (int)TEXTW(stext) + lrpad - getsystraywidth())) {
+ else if (ev->x > (x = selmon->ww - TEXTW(stext) + lrpad - getsystraywidth())) {
click = ClkStatusText;
- char *text = rawstext;
- int i = -1;
- char ch;
- dwmblockssig = 0;
- while (text[++i]) {
- if ((unsigned char)text[i] < ' ') {
- ch = text[i];
- text[i] = '\0';
- x += TEXTW(text) - lrpad;
- text[i] = ch;
- text += i+1;
- i = -1;
- if (x >= ev->x) break;
- dwmblockssig = ch;
- }
- }
- } else
+
+ char *text = rawstext;
+ int i = -1;
+ char ch;
+ dwmblockssig = 0;
+ while (text[++i]) {
+ if ((unsigned char)text[i] < ' ') {
+ ch = text[i];
+ text[i] = '\0';
+ x += TEXTW(text) - lrpad;
+ text[i] = ch;
+ text += i+1;
+ i = -1;
+ if (x >= ev->x) break;
+ dwmblockssig = ch;
+ }
+ }
+ } else
click = ClkWinTitle;
} else if ((c = wintoclient(ev->window))) {
focus(c);
@@ -898,15 +899,13 @@ destroynotify(XEvent *e)
if ((c = wintoclient(ev->window)))
unmanage(c, 1);
-
- else if ((c = wintosystrayicon(ev->window))) {
- removesystrayicon(c);
- resizebarwin(selmon);
- updatesystray();
- }
-
- else if ((c = swallowingclient(ev->window)))
- unmanage(c->swallowing, 1);
+ else if ((c = swallowingclient(ev->window)))
+ unmanage(c->swallowing, 1);
+ else if ((c = wintosystrayicon(ev->window))) {
+ removesystrayicon(c);
+ resizebarwin(selmon);
+ updatesystray();
+ }
}
void
@@ -951,24 +950,23 @@ void
drawbar(Monitor *m)
{
int indn;
- int x, w, tw = 0, stw = 0;
+ int x, w, sw = 0, stw = 0;
int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0;
Client *c;
- if(showsystray && m == systraytomon(m))
- stw = getsystraywidth();
+ if(showsystray && m == systraytomon(m))
+ stw = getsystraywidth();
/* 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 + 2; /* 2px right padding */
- drw_text(drw, m->ww - tw - stw, 0, tw, bh, lrpad / 2 - 2, stext, 0);
- }
-
- resizebarwin(m);
+ sw = TEXTW(stext) - lrpad / 2 + 2; /* 2px right padding */
+ drw_text(drw, m->ww - sw - stw, 0, sw, bh, lrpad / 2 - 2, stext, 0);
+ }
+ resizebarwin(m);
for (c = m->clients; c; c = c->next) {
occ |= c->tags;
if (c->isurgent)
@@ -976,16 +974,17 @@ drawbar(Monitor *m)
}
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
- indn = 0;
+ indn = 0;
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);
- for (c = m->clients; c; c = c->next) {
- if (c->tags & (1 << i)) {
- drw_rect(drw, x, 1 + (indn * 2), selmon->sel == c ? 6 : 1, 1, 1, urg & 1 << i);
- indn++;
- }
- }
+
+ for (c = m->clients; c; c = c->next) {
+ if (c->tags & (1 << i)) {
+ drw_rect(drw, x, 1 + (indn * 2), selmon->sel == c ? 6 : 1, 1, 1, urg & 1 << i);
+ indn++;
+ }
+ }
x += w;
}
@@ -993,7 +992,7 @@ drawbar(Monitor *m)
drw_setscheme(drw, scheme[SchemeNorm]);
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
- if ((w = m->ww - tw - stw - x) > bh) {
+ if ((w = m->ww - sw - stw - 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);
@@ -1563,7 +1562,6 @@ nexttiled(Client *c)
return c;
}
-/*
void
pop(Client *c)
{
@@ -1572,7 +1570,6 @@ pop(Client *c)
focus(c);
arrange(c->mon);
}
-*/
Client *
prevtiled(Client *c) {
@@ -1593,14 +1590,15 @@ propertynotify(XEvent *e)
if ((c = wintosystrayicon(ev->window))) {
if (ev->atom == XA_WM_NORMAL_HINTS) {
- updatesizehints(c);
- updatesystrayicongeom(c, c->w, c->h);
- } else
- updatesystrayiconstate(c, ev);
+ updatesizehints(c);
+ updatesystrayicongeom(c, c->w, c->h);
+ }
+ else
+ updatesystrayiconstate(c, ev);
resizebarwin(selmon);
updatesystray();
-
}
+
if ((ev->window == root) && (ev->atom == XA_WM_NAME)) {
if (!fake_signal())
updatestatus();
@@ -1861,8 +1859,8 @@ run(void)
void
runAutostart(void) {
- system("cd ~; ./.config/dwm/autostart_blocking.sh");
- system("cd ~; ./.config/dwm/autostart.sh &");
+ system("~/.config/dwm/autostart_blocking.sh");
+ system("~/.config/dwm/autostart.sh &");
}
void
@@ -2261,17 +2259,13 @@ tile(Monitor *m)
if (i < m->nmaster) {
h = (m->wh - my) * (c->cfact / mfacts);
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);
- mfacts -= c->cfact;
- }
+ my += HEIGHT(c);
+ mfacts -= c->cfact;
} else {
h = (m->wh - ty) * (c->cfact / sfacts);
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);
- sfacts -= c->cfact;
- }
+ ty += HEIGHT(c);
+ sfacts -= c->cfact;
}
}
@@ -2310,13 +2304,6 @@ togglefloating(const Arg *arg)
}
void
-togglefullscr(const Arg *arg)
-{
- if(selmon->sel)
- setfullscreen(selmon->sel, !selmon->sel->isfullscreen);
-}
-
-void
togglescratch(const Arg *arg)
{
Client *c;
@@ -2343,6 +2330,13 @@ togglescratch(const Arg *arg)
}
void
+togglefullscr(const Arg *arg)
+{
+ if(selmon->sel)
+ setfullscreen(selmon->sel, !selmon->sel->isfullscreen);
+}
+
+void
toggletag(const Arg *arg)
{
unsigned int newtags;
@@ -3071,7 +3065,7 @@ main(int argc, char *argv[])
#endif /* __OpenBSD__ */
scan();
runAutostart();
-run();
+ run();
if(restart) execvp(argv[0], argv);
cleanup();
XCloseDisplay(dpy);