mirror of
https://github.com/tiyn/dwm.git
synced 2025-10-15 20:31:18 +02:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
2d962ae3fd | |||
3f4743c9d0 | |||
61088a7795 |
@@ -41,7 +41,6 @@ static const Layout layouts[] = {
|
|||||||
{ "[]=", tile }, /* first entry is default */
|
{ "[]=", tile }, /* first entry is default */
|
||||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||||
{ "[M]", monocle },
|
{ "[M]", monocle },
|
||||||
{ "[D]", deck },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* key definitions */
|
/* key definitions */
|
||||||
@@ -77,7 +76,6 @@ static Key keys[] = {
|
|||||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||||
{ MODKEY, XK_c, setlayout, {.v = &layouts[3]} },
|
|
||||||
{ MODKEY, XK_space, setlayout, {0} },
|
{ MODKEY, XK_space, setlayout, {0} },
|
||||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||||
|
@@ -1,115 +0,0 @@
|
|||||||
/* See LICENSE file for copyright and license details. */
|
|
||||||
|
|
||||||
/* 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";
|
|
||||||
static const char col_gray4[] = "#eeeeee";
|
|
||||||
static const char col_cyan[] = "#005577";
|
|
||||||
static const char *colors[][3] = {
|
|
||||||
/* fg bg border */
|
|
||||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
|
||||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* tagging */
|
|
||||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
|
||||||
|
|
||||||
static const Rule rules[] = {
|
|
||||||
/* xprop(1):
|
|
||||||
* WM_CLASS(STRING) = instance, class
|
|
||||||
* WM_NAME(STRING) = title
|
|
||||||
*/
|
|
||||||
/* class instance title tags mask isfloating monitor */
|
|
||||||
{ "Gimp", NULL, NULL, 0, 1, -1 },
|
|
||||||
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* layout(s) */
|
|
||||||
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
|
||||||
static const int nmaster = 1; /* number of clients in master area */
|
|
||||||
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
|
||||||
|
|
||||||
static const Layout layouts[] = {
|
|
||||||
/* symbol arrange function */
|
|
||||||
{ "[]=", tile }, /* first entry is default */
|
|
||||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
|
||||||
{ "[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} },
|
|
||||||
};
|
|
||||||
|
|
@@ -1,90 +0,0 @@
|
|||||||
From cb3cac91db32403bb581aecbc2957b00bb49c898 Mon Sep 17 00:00:00 2001
|
|
||||||
From: aleks <aleks.stier@icloud.com>
|
|
||||||
Date: Mon, 6 May 2019 16:34:58 +0200
|
|
||||||
Subject: [PATCH] Add deck-layout
|
|
||||||
|
|
||||||
deck is a dwm-layout which is inspired by the TTWM window manager.
|
|
||||||
It applies the monocle-layout to the clients in the stack.
|
|
||||||
The master-client is still visible. The stacked clients are like
|
|
||||||
a deck of cards, hence the name.
|
|
||||||
|
|
||||||
The vanilla patch doesn't work properly with patches which add gaps.
|
|
||||||
This means that when the deck-layout is activated gaps are omitted.
|
|
||||||
To make it work with the tilegap-patch apply the dwm-deck-tilegap patch
|
|
||||||
on top of the dwm-deck patch.
|
|
||||||
|
|
||||||
The vanilla patch doesn't respect the master-area which is defined by
|
|
||||||
the rmaster-patch. To make it work with the rmaster-patch apply the
|
|
||||||
dwm-deck-rmaster patch on top of the dwm-deck patch.
|
|
||||||
---
|
|
||||||
config.def.h | 2 ++
|
|
||||||
dwm.c | 26 ++++++++++++++++++++++++++
|
|
||||||
2 files changed, 28 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/config.def.h b/config.def.h
|
|
||||||
index 77ff358..55d8a07 100644
|
|
||||||
--- a/config.def.h
|
|
||||||
+++ b/config.def.h
|
|
||||||
@@ -32,6 +32,7 @@ static const Layout layouts[] = {
|
|
||||||
{ "[]=", tile }, /* first entry is default */
|
|
||||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
|
||||||
{ "[M]", monocle },
|
|
||||||
+ { "[D]", deck },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* key definitions */
|
|
||||||
@@ -66,6 +67,7 @@ static Key keys[] = {
|
|
||||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
|
||||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
|
||||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
|
||||||
+ { MODKEY, XK_c, setlayout, {.v = &layouts[3]} },
|
|
||||||
{ MODKEY, XK_space, setlayout, {0} },
|
|
||||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
|
||||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
|
||||||
diff --git a/dwm.c b/dwm.c
|
|
||||||
index 1d78655..356ab44 100644
|
|
||||||
--- a/dwm.c
|
|
||||||
+++ b/dwm.c
|
|
||||||
@@ -171,6 +171,7 @@ static void configure(Client *c);
|
|
||||||
static void configurenotify(XEvent *e);
|
|
||||||
static void configurerequest(XEvent *e);
|
|
||||||
static Monitor *createmon(void);
|
|
||||||
+static void deck(Monitor *m);
|
|
||||||
static void destroynotify(XEvent *e);
|
|
||||||
static void detach(Client *c);
|
|
||||||
static void detachstack(Client *c);
|
|
||||||
@@ -669,6 +670,31 @@ destroynotify(XEvent *e) {
|
|
||||||
unmanage(c, True);
|
|
||||||
}
|
|
||||||
|
|
||||||
+void
|
|
||||||
+deck(Monitor *m) {
|
|
||||||
+ unsigned int i, n, h, mw, my;
|
|
||||||
+ Client *c;
|
|
||||||
+
|
|
||||||
+ for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
|
||||||
+ if(n == 0)
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ if(n > m->nmaster) {
|
|
||||||
+ mw = m->nmaster ? m->ww * m->mfact : 0;
|
|
||||||
+ snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster);
|
|
||||||
+ }
|
|
||||||
+ else
|
|
||||||
+ mw = m->ww;
|
|
||||||
+ for(i = my = 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), False);
|
|
||||||
+ my += HEIGHT(c);
|
|
||||||
+ }
|
|
||||||
+ else
|
|
||||||
+ resize(c, m->wx + mw, m->wy, m->ww - mw - (2*c->bw), m->wh - (2*c->bw), False);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
void
|
|
||||||
detach(Client *c) {
|
|
||||||
Client **tc;
|
|
||||||
--
|
|
||||||
2.21.0
|
|
||||||
|
|
166
dwm-status2d-6.2.diff
Normal file
166
dwm-status2d-6.2.diff
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index d27cb67..464c9d6 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -163,6 +163,7 @@ static void detach(Client *c);
|
||||||
|
static Monitor *dirtomon(int dir);
|
||||||
|
static void drawbar(Monitor *m);
|
||||||
|
static void drawbars(void);
|
||||||
|
+static int drawstatusbar(Monitor *m, int bh, char* text);
|
||||||
|
static void enternotify(XEvent *e);
|
||||||
|
static void expose(XEvent *e);
|
||||||
|
static void focus(Client *c);
|
||||||
|
@@ -237,7 +238,7 @@ static void zoom(const Arg *arg);
|
||||||
|
|
||||||
|
/* variables */
|
||||||
|
static const char broken[] = "broken";
|
||||||
|
-static char stext[256];
|
||||||
|
+static char stext[1024];
|
||||||
|
static int screen;
|
||||||
|
static int sw, sh; /* X display screen geometry width, height */
|
||||||
|
static int bh, blw = 0; /* bar geometry */
|
||||||
|
@@ -483,7 +484,7 @@ cleanup(void)
|
||||||
|
cleanupmon(mons);
|
||||||
|
for (i = 0; i < CurLast; i++)
|
||||||
|
drw_cur_free(drw, cursor[i]);
|
||||||
|
- for (i = 0; i < LENGTH(colors); i++)
|
||||||
|
+ for (i = 0; i < LENGTH(colors) + 1; i++)
|
||||||
|
free(scheme[i]);
|
||||||
|
XDestroyWindow(dpy, wmcheckwin);
|
||||||
|
drw_free(drw);
|
||||||
|
@@ -690,6 +691,114 @@ dirtomon(int dir)
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
+int
|
||||||
|
+drawstatusbar(Monitor *m, int bh, char* stext) {
|
||||||
|
+ int ret, i, w, x, len;
|
||||||
|
+ short isCode = 0;
|
||||||
|
+ char *text;
|
||||||
|
+ char *p;
|
||||||
|
+
|
||||||
|
+ len = strlen(stext) + 1 ;
|
||||||
|
+ if (!(text = (char*) malloc(sizeof(char)*len)))
|
||||||
|
+ die("malloc");
|
||||||
|
+ p = text;
|
||||||
|
+ memcpy(text, stext, len);
|
||||||
|
+
|
||||||
|
+ /* compute width of the status text */
|
||||||
|
+ w = 0;
|
||||||
|
+ i = -1;
|
||||||
|
+ while (text[++i]) {
|
||||||
|
+ if (text[i] == '^') {
|
||||||
|
+ if (!isCode) {
|
||||||
|
+ isCode = 1;
|
||||||
|
+ text[i] = '\0';
|
||||||
|
+ w += TEXTW(text) - lrpad;
|
||||||
|
+ text[i] = '^';
|
||||||
|
+ if (text[++i] == 'f')
|
||||||
|
+ w += atoi(text + ++i);
|
||||||
|
+ } else {
|
||||||
|
+ isCode = 0;
|
||||||
|
+ text = text + i + 1;
|
||||||
|
+ i = -1;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ if (!isCode)
|
||||||
|
+ w += TEXTW(text) - lrpad;
|
||||||
|
+ else
|
||||||
|
+ isCode = 0;
|
||||||
|
+ text = p;
|
||||||
|
+
|
||||||
|
+ w += 2; /* 1px padding on both sides */
|
||||||
|
+ ret = x = m->ww - w;
|
||||||
|
+
|
||||||
|
+ drw_setscheme(drw, scheme[LENGTH(colors)]);
|
||||||
|
+ drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
||||||
|
+ drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
|
||||||
|
+ drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||||
|
+ x++;
|
||||||
|
+
|
||||||
|
+ /* process status text */
|
||||||
|
+ i = -1;
|
||||||
|
+ while (text[++i]) {
|
||||||
|
+ if (text[i] == '^' && !isCode) {
|
||||||
|
+ isCode = 1;
|
||||||
|
+
|
||||||
|
+ text[i] = '\0';
|
||||||
|
+ w = TEXTW(text) - lrpad;
|
||||||
|
+ drw_text(drw, x, 0, w, bh, 0, text, 0);
|
||||||
|
+
|
||||||
|
+ x += w;
|
||||||
|
+
|
||||||
|
+ /* process code */
|
||||||
|
+ while (text[++i] != '^') {
|
||||||
|
+ if (text[i] == 'c') {
|
||||||
|
+ char buf[8];
|
||||||
|
+ memcpy(buf, (char*)text+i+1, 7);
|
||||||
|
+ buf[7] = '\0';
|
||||||
|
+ drw_clr_create(drw, &drw->scheme[ColFg], buf);
|
||||||
|
+ i += 7;
|
||||||
|
+ } else if (text[i] == 'b') {
|
||||||
|
+ char buf[8];
|
||||||
|
+ memcpy(buf, (char*)text+i+1, 7);
|
||||||
|
+ buf[7] = '\0';
|
||||||
|
+ drw_clr_create(drw, &drw->scheme[ColBg], buf);
|
||||||
|
+ i += 7;
|
||||||
|
+ } else if (text[i] == 'd') {
|
||||||
|
+ drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
||||||
|
+ drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
|
||||||
|
+ } else if (text[i] == 'r') {
|
||||||
|
+ int rx = atoi(text + ++i);
|
||||||
|
+ while (text[++i] != ',');
|
||||||
|
+ int ry = atoi(text + ++i);
|
||||||
|
+ while (text[++i] != ',');
|
||||||
|
+ int rw = atoi(text + ++i);
|
||||||
|
+ while (text[++i] != ',');
|
||||||
|
+ int rh = atoi(text + ++i);
|
||||||
|
+
|
||||||
|
+ drw_rect(drw, rx + x, ry, rw, rh, 1, 0);
|
||||||
|
+ } else if (text[i] == 'f') {
|
||||||
|
+ x += atoi(text + ++i);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ text = text + i + 1;
|
||||||
|
+ i=-1;
|
||||||
|
+ isCode = 0;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (!isCode) {
|
||||||
|
+ w = TEXTW(text) - lrpad;
|
||||||
|
+ drw_text(drw, x, 0, w, bh, 0, text, 0);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
+ free(p);
|
||||||
|
+
|
||||||
|
+ return ret;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
drawbar(Monitor *m)
|
||||||
|
{
|
||||||
|
@@ -701,9 +802,7 @@ drawbar(Monitor *m)
|
||||||
|
|
||||||
|
/* 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]);
|
||||||
|
- sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
|
||||||
|
- drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0);
|
||||||
|
+ sw = m->ww - drawstatusbar(m, bh, stext);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (c = m->clients; c; c = c->next) {
|
||||||
|
@@ -1572,7 +1671,8 @@ setup(void)
|
||||||
|
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
||||||
|
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
||||||
|
/* init appearance */
|
||||||
|
- scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
|
||||||
|
+ scheme = ecalloc(LENGTH(colors) + 1, sizeof(Clr *));
|
||||||
|
+ scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], 3);
|
||||||
|
for (i = 0; i < LENGTH(colors); i++)
|
||||||
|
scheme[i] = drw_scm_create(drw, colors[i], 3);
|
||||||
|
/* init bars */
|
146
dwm.c
146
dwm.c
@@ -157,13 +157,13 @@ static void configure(Client *c);
|
|||||||
static void configurenotify(XEvent *e);
|
static void configurenotify(XEvent *e);
|
||||||
static void configurerequest(XEvent *e);
|
static void configurerequest(XEvent *e);
|
||||||
static Monitor *createmon(void);
|
static Monitor *createmon(void);
|
||||||
static void deck(Monitor *m);
|
|
||||||
static void destroynotify(XEvent *e);
|
static void destroynotify(XEvent *e);
|
||||||
static void detach(Client *c);
|
static void detach(Client *c);
|
||||||
static void detachstack(Client *c);
|
static void detachstack(Client *c);
|
||||||
static Monitor *dirtomon(int dir);
|
static Monitor *dirtomon(int dir);
|
||||||
static void drawbar(Monitor *m);
|
static void drawbar(Monitor *m);
|
||||||
static void drawbars(void);
|
static void drawbars(void);
|
||||||
|
static int drawstatusbar(Monitor *m, int bh, char* text);
|
||||||
static void enternotify(XEvent *e);
|
static void enternotify(XEvent *e);
|
||||||
static void expose(XEvent *e);
|
static void expose(XEvent *e);
|
||||||
static void focus(Client *c);
|
static void focus(Client *c);
|
||||||
@@ -237,7 +237,7 @@ static void zoom(const Arg *arg);
|
|||||||
|
|
||||||
/* variables */
|
/* variables */
|
||||||
static const char broken[] = "broken";
|
static const char broken[] = "broken";
|
||||||
static char stext[256];
|
static char stext[1024];
|
||||||
static int screen;
|
static int screen;
|
||||||
static int sw, sh; /* X display screen geometry width, height */
|
static int sw, sh; /* X display screen geometry width, height */
|
||||||
static int bh, blw = 0; /* bar geometry */
|
static int bh, blw = 0; /* bar geometry */
|
||||||
@@ -485,7 +485,7 @@ cleanup(void)
|
|||||||
cleanupmon(mons);
|
cleanupmon(mons);
|
||||||
for (i = 0; i < CurLast; i++)
|
for (i = 0; i < CurLast; i++)
|
||||||
drw_cur_free(drw, cursor[i]);
|
drw_cur_free(drw, cursor[i]);
|
||||||
for (i = 0; i < LENGTH(colors); i++)
|
for (i = 0; i < LENGTH(colors) + 1; i++)
|
||||||
free(scheme[i]);
|
free(scheme[i]);
|
||||||
XDestroyWindow(dpy, wmcheckwin);
|
XDestroyWindow(dpy, wmcheckwin);
|
||||||
drw_free(drw);
|
drw_free(drw);
|
||||||
@@ -655,31 +655,6 @@ destroynotify(XEvent *e)
|
|||||||
unmanage(c, 1);
|
unmanage(c, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
deck(Monitor *m) {
|
|
||||||
unsigned int i, n, h, mw, my;
|
|
||||||
Client *c;
|
|
||||||
|
|
||||||
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
|
||||||
if(n == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(n > m->nmaster) {
|
|
||||||
mw = m->nmaster ? m->ww * m->mfact : 0;
|
|
||||||
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
mw = m->ww;
|
|
||||||
for(i = my = 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), False);
|
|
||||||
my += HEIGHT(c);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
resize(c, m->wx + mw, m->wy, m->ww - mw - (2*c->bw), m->wh - (2*c->bw), False);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
detach(Client *c)
|
detach(Client *c)
|
||||||
{
|
{
|
||||||
@@ -718,6 +693,114 @@ dirtomon(int dir)
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
drawstatusbar(Monitor *m, int bh, char* stext) {
|
||||||
|
int ret, i, w, x, len;
|
||||||
|
short isCode = 0;
|
||||||
|
char *text;
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
len = strlen(stext) + 1 ;
|
||||||
|
if (!(text = (char*) malloc(sizeof(char)*len)))
|
||||||
|
die("malloc");
|
||||||
|
p = text;
|
||||||
|
memcpy(text, stext, len);
|
||||||
|
|
||||||
|
/* compute width of the status text */
|
||||||
|
w = 0;
|
||||||
|
i = -1;
|
||||||
|
while (text[++i]) {
|
||||||
|
if (text[i] == '^') {
|
||||||
|
if (!isCode) {
|
||||||
|
isCode = 1;
|
||||||
|
text[i] = '\0';
|
||||||
|
w += TEXTW(text) - lrpad;
|
||||||
|
text[i] = '^';
|
||||||
|
if (text[++i] == 'f')
|
||||||
|
w += atoi(text + ++i);
|
||||||
|
} else {
|
||||||
|
isCode = 0;
|
||||||
|
text = text + i + 1;
|
||||||
|
i = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isCode)
|
||||||
|
w += TEXTW(text) - lrpad;
|
||||||
|
else
|
||||||
|
isCode = 0;
|
||||||
|
text = p;
|
||||||
|
|
||||||
|
w += 2; /* 1px padding on both sides */
|
||||||
|
ret = x = m->ww - w;
|
||||||
|
|
||||||
|
drw_setscheme(drw, scheme[LENGTH(colors)]);
|
||||||
|
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
||||||
|
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
|
||||||
|
drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||||
|
x++;
|
||||||
|
|
||||||
|
/* process status text */
|
||||||
|
i = -1;
|
||||||
|
while (text[++i]) {
|
||||||
|
if (text[i] == '^' && !isCode) {
|
||||||
|
isCode = 1;
|
||||||
|
|
||||||
|
text[i] = '\0';
|
||||||
|
w = TEXTW(text) - lrpad;
|
||||||
|
drw_text(drw, x, 0, w, bh, 0, text, 0);
|
||||||
|
|
||||||
|
x += w;
|
||||||
|
|
||||||
|
/* process code */
|
||||||
|
while (text[++i] != '^') {
|
||||||
|
if (text[i] == 'c') {
|
||||||
|
char buf[8];
|
||||||
|
memcpy(buf, (char*)text+i+1, 7);
|
||||||
|
buf[7] = '\0';
|
||||||
|
drw_clr_create(drw, &drw->scheme[ColFg], buf);
|
||||||
|
i += 7;
|
||||||
|
} else if (text[i] == 'b') {
|
||||||
|
char buf[8];
|
||||||
|
memcpy(buf, (char*)text+i+1, 7);
|
||||||
|
buf[7] = '\0';
|
||||||
|
drw_clr_create(drw, &drw->scheme[ColBg], buf);
|
||||||
|
i += 7;
|
||||||
|
} else if (text[i] == 'd') {
|
||||||
|
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
||||||
|
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
|
||||||
|
} else if (text[i] == 'r') {
|
||||||
|
int rx = atoi(text + ++i);
|
||||||
|
while (text[++i] != ',');
|
||||||
|
int ry = atoi(text + ++i);
|
||||||
|
while (text[++i] != ',');
|
||||||
|
int rw = atoi(text + ++i);
|
||||||
|
while (text[++i] != ',');
|
||||||
|
int rh = atoi(text + ++i);
|
||||||
|
|
||||||
|
drw_rect(drw, rx + x, ry, rw, rh, 1, 0);
|
||||||
|
} else if (text[i] == 'f') {
|
||||||
|
x += atoi(text + ++i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
text = text + i + 1;
|
||||||
|
i=-1;
|
||||||
|
isCode = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isCode) {
|
||||||
|
w = TEXTW(text) - lrpad;
|
||||||
|
drw_text(drw, x, 0, w, bh, 0, text, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
free(p);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drawbar(Monitor *m)
|
drawbar(Monitor *m)
|
||||||
{
|
{
|
||||||
@@ -729,9 +812,7 @@ drawbar(Monitor *m)
|
|||||||
|
|
||||||
/* draw status first so it can be overdrawn by tags later */
|
/* draw status first so it can be overdrawn by tags later */
|
||||||
if (m == selmon) { /* status is only drawn on selected monitor */
|
if (m == selmon) { /* status is only drawn on selected monitor */
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
sw = m->ww - drawstatusbar(m, bh, stext);
|
||||||
sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
|
|
||||||
drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (c = m->clients; c; c = c->next) {
|
for (c = m->clients; c; c = c->next) {
|
||||||
@@ -1593,7 +1674,8 @@ setup(void)
|
|||||||
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
||||||
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
||||||
/* init appearance */
|
/* init appearance */
|
||||||
scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
|
scheme = ecalloc(LENGTH(colors) + 1, sizeof(Clr *));
|
||||||
|
scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], 3);
|
||||||
for (i = 0; i < LENGTH(colors); i++)
|
for (i = 0; i < LENGTH(colors); i++)
|
||||||
scheme[i] = drw_scm_create(drw, colors[i], 3);
|
scheme[i] = drw_scm_create(drw, colors[i], 3);
|
||||||
/* init bars */
|
/* init bars */
|
||||||
|
2149
dwm.c.orig
2149
dwm.c.orig
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user