mirror of
https://codeberg.org/frosty/dwm.git
synced 2024-09-19 11:46:53 -04:00
Compare commits
15 commits
238c72de12
...
6efec60c11
Author | SHA1 | Date | |
---|---|---|---|
frosty | 6efec60c11 | ||
frosty | 231de1647f | ||
frosty | 353c2eca14 | ||
frosty | ebbf1fd497 | ||
frosty | a2f0eb1934 | ||
frosty | bd82e7b2ff | ||
frosty | c44d77b241 | ||
frosty | c2117b2f1e | ||
frosty | c6d1a98575 | ||
frosty | 06d3b77b37 | ||
frosty | 4a953773f2 | ||
frosty | f75e0d0304 | ||
frosty | 61ddad5596 | ||
frosty | f2d69c0cd0 | ||
frosty | 819322eed9 |
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -6,6 +6,6 @@ config.h
|
||||||
# Patches
|
# Patches
|
||||||
*.diff
|
*.diff
|
||||||
*.patch
|
*.patch
|
||||||
|
*.rej
|
||||||
# Copies
|
# Copies
|
||||||
*.orig
|
*.orig
|
||||||
*.rej
|
|
||||||
|
|
109
config.def.h
109
config.def.h
|
@ -1,16 +1,8 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
|
||||||
#define TERMINAL "st"
|
|
||||||
#define BROWSER "firefox"
|
|
||||||
|
|
||||||
/* appearance */
|
/* appearance */
|
||||||
static unsigned int borderpx = 1; /* border pixel of windows */
|
static unsigned int borderpx = 1; /* border pixel of windows */
|
||||||
static unsigned int snap = 32; /* snap pixel */
|
static unsigned int snap = 32; /* snap pixel */
|
||||||
static unsigned int gappih = 16; /* horiz inner gap between windows */
|
|
||||||
static unsigned int gappiv = 16; /* vert inner gap between windows */
|
|
||||||
static unsigned int gappoh = 8; /* horiz outer gap between windows and screen edge */
|
|
||||||
static unsigned int gappov = 8; /* vert outer gap between windows and screen edge */
|
|
||||||
static int smartgaps = 0; /* 1 means no outer gap when there is only one window */
|
|
||||||
static int showbar = 1; /* 0 means no bar */
|
static int showbar = 1; /* 0 means no bar */
|
||||||
static int topbar = 1; /* 0 means bottom bar */
|
static int topbar = 1; /* 0 means bottom bar */
|
||||||
static char font[] = "monospace:size=10";
|
static char font[] = "monospace:size=10";
|
||||||
|
@ -36,10 +28,7 @@ static const Rule rules[] = {
|
||||||
* WM_NAME(STRING) = title
|
* WM_NAME(STRING) = title
|
||||||
*/
|
*/
|
||||||
/* class instance title tags mask isfloating monitor */
|
/* class instance title tags mask isfloating monitor */
|
||||||
{ "firefox", NULL, NULL, 1 << 1, 0, -1 },
|
{ NULL, NULL, NULL, 0, 0, -1 },
|
||||||
{ "firefox", NULL, "Picture-in-Picture", 0, 1, -1 },
|
|
||||||
{ "Signal", NULL, NULL, 1 << 3, 0, -1 },
|
|
||||||
{ "vesktop", NULL, NULL, 1 << 3, 0, -1 },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* layout(s) */
|
/* layout(s) */
|
||||||
|
@ -53,6 +42,7 @@ 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 },
|
||||||
|
{ "TTT", bstack },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* key definitions */
|
/* key definitions */
|
||||||
|
@ -66,12 +56,9 @@ static const Layout layouts[] = {
|
||||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||||
|
|
||||||
#define TERMCMD(cmd) { .v = (const char*[]){ TERMINAL, "-e", cmd, NULL } }
|
|
||||||
|
|
||||||
/* commands */
|
/* commands */
|
||||||
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
|
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
|
||||||
static const char *dmenucmd[] = { "ezrun", NULL };
|
static const char *dmenucmd[] = { "dmenu_run", "-g", "8", "-l", "4", "-m", dmenumon, "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
|
||||||
static const char *termcmd[] = { "st", NULL };
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Xresources preferences to load at startup
|
* Xresources preferences to load at startup
|
||||||
|
@ -91,58 +78,48 @@ ResourcePref resources[] = {
|
||||||
{ "nmaster", INTEGER, &nmaster },
|
{ "nmaster", INTEGER, &nmaster },
|
||||||
{ "resizehints", INTEGER, &resizehints },
|
{ "resizehints", INTEGER, &resizehints },
|
||||||
{ "mfact", FLOAT, &mfact },
|
{ "mfact", FLOAT, &mfact },
|
||||||
{ "gappih", INTEGER, &gappih },
|
|
||||||
{ "gappiv", INTEGER, &gappiv },
|
|
||||||
{ "gappoh", INTEGER, &gappoh },
|
|
||||||
{ "gappov", INTEGER, &gappov },
|
|
||||||
{ "smartgaps", INTEGER, &smartgaps },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "shiftview.c"
|
#include <X11/XF86keysym.h>
|
||||||
|
|
||||||
static const Key keys[] = {
|
static const Key keys[] = {
|
||||||
/* modifier key function argument */
|
/* modifier key function argument */
|
||||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
/* stack control */
|
||||||
{ MODKEY, XK_Return, spawn, {.v = termcmd } },
|
|
||||||
{ MODKEY, XK_w, spawn, SHCMD(BROWSER) },
|
|
||||||
{ MODKEY, XK_v, spawn, TERMCMD("pulsemixer") },
|
|
||||||
{ MODKEY, XK_e, spawn, SHCMD("thunar") },
|
|
||||||
{ ControlMask|Mod1Mask, XK_u, spawn, TERMCMD("htop") },
|
|
||||||
{ ControlMask|Mod1Mask, XK_p, spawn, SHCMD("screenshot select") },
|
|
||||||
{ ControlMask|Mod1Mask, XK_o, spawn, SHCMD("screenshot full") },
|
|
||||||
{ MODKEY, XK_b, togglebar, {0} },
|
|
||||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||||
{ MODKEY|ShiftMask, XK_j, pushdown, {0} },
|
{ MODKEY|ShiftMask, XK_j, pushdown, {0} },
|
||||||
{ MODKEY|ShiftMask, XK_k, pushup, {0} },
|
{ MODKEY|ShiftMask, XK_k, pushup, {0} },
|
||||||
|
{ MODKEY|ShiftMask, XK_Return, zoom, {0} },
|
||||||
|
|
||||||
|
/* master control */
|
||||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||||
{ MODKEY, XK_h, setmfact, {.f = -0.0125} },
|
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||||
{ MODKEY, XK_l, setmfact, {.f = +0.0125} },
|
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||||
{ MODKEY|ShiftMask, XK_h, setmfact, {.f = -0.05} },
|
|
||||||
{ MODKEY|ShiftMask, XK_l, setmfact, {.f = +0.05} },
|
/* layouts */
|
||||||
{ MODKEY, XK_bracketright, incrgaps, {.i = +4 } },
|
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||||
{ MODKEY, XK_bracketleft, incrgaps, {.i = -4 } },
|
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||||
{ MODKEY, XK_equal, togglegaps, {0} },
|
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||||
{ MODKEY|ShiftMask, XK_equal, defaultgaps, {0} },
|
{ MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
|
||||||
{ MODKEY|ShiftMask, XK_Return, zoom, {0} },
|
|
||||||
{ MODKEY, XK_Tab, view, {0} },
|
/* client actions */
|
||||||
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, /* tile */
|
|
||||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, /* floating */
|
|
||||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, /* monocle */
|
|
||||||
{ MODKEY, XK_space, setlayout, {0} },
|
|
||||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||||
{ MODKEY|ShiftMask, XK_f, togglefullscr, {0} },
|
{ MODKEY|ShiftMask, XK_f, togglefullscr, {0} },
|
||||||
{ MODKEY|ShiftMask, XK_s, togglesticky, {0} },
|
{ MODKEY|ShiftMask, XK_s, togglesticky, {0} },
|
||||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
|
||||||
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
/* monitors */
|
||||||
{ MODKEY, XK_y, shiftview, {.i = +1 } },
|
|
||||||
{ MODKEY|ShiftMask, XK_y, shiftview, {.i = -1 } },
|
|
||||||
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
|
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
|
||||||
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||||
|
|
||||||
|
/* tags */
|
||||||
|
{ MODKEY, XK_y, shiftview, {.i = +1 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_y, shiftview, {.i = -1 } },
|
||||||
|
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
||||||
TAGKEYS( XK_1, 0)
|
TAGKEYS( XK_1, 0)
|
||||||
TAGKEYS( XK_2, 1)
|
TAGKEYS( XK_2, 1)
|
||||||
TAGKEYS( XK_3, 2)
|
TAGKEYS( XK_3, 2)
|
||||||
|
@ -152,22 +129,36 @@ static const Key keys[] = {
|
||||||
TAGKEYS( XK_7, 6)
|
TAGKEYS( XK_7, 6)
|
||||||
TAGKEYS( XK_8, 7)
|
TAGKEYS( XK_8, 7)
|
||||||
TAGKEYS( XK_9, 8)
|
TAGKEYS( XK_9, 8)
|
||||||
{ ControlMask|Mod1Mask, XK_r, quit, {0} },
|
{ MODKEY, XK_Tab, view, {0} },
|
||||||
{ ControlMask|Mod1Mask, XK_Delete, spawn, SHCMD("pkill xinit") },
|
|
||||||
{ MODKEY, XK_F9, spawn, SHCMD("sys-volume toggle") },
|
/* session */
|
||||||
{ MODKEY, XK_F10, spawn, SHCMD("sys-volume 5%-") },
|
{ Mod1Mask|ControlMask, XK_r, quit, {0} },
|
||||||
{ MODKEY, XK_F11, spawn, SHCMD("sys-volume 5%+") },
|
{ Mod1Mask|ControlMask, XK_Delete, spawn, SHCMD("pkill xinit") },
|
||||||
{ MODKEY, XK_F12, spawn, SHCMD("sys-lock") },
|
|
||||||
|
/* programs/ui */
|
||||||
|
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||||
|
{ MODKEY, XK_Return, spawn, SHCMD("st") },
|
||||||
|
{ MODKEY, XK_w, spawn, SHCMD("firefox") },
|
||||||
|
{ MODKEY, XK_v, spawn, SHCMD("st -e pulsemixer") },
|
||||||
|
{ MODKEY|ControlMask, XK_l, spawn, SHCMD("xidlehook-client --socket $XIDLEHOOK_SOCK control --action trigger --timer 0") },
|
||||||
|
{ MODKEY|ControlMask, XK_t, spawn, SHCMD("screenshot -cs full") },
|
||||||
|
{ MODKEY|ControlMask, XK_r, spawn, SHCMD("screenshot -cs select") },
|
||||||
|
{ MODKEY, XK_b, togglebar, {0} },
|
||||||
|
|
||||||
|
/* etc. */
|
||||||
|
{ 0, XF86XK_MonBrightnessDown, spawn, SHCMD("lightctrl acpi_video0 5%- Display") },
|
||||||
|
{ 0, XF86XK_MonBrightnessUp, spawn, SHCMD("lightctrl acpi_video0 5%+ Display") },
|
||||||
|
{ 0, XF86XK_KbdBrightnessDown, spawn, SHCMD("lightctrl smc::kbd_backlight 5%- Keyboard") },
|
||||||
|
{ 0, XF86XK_KbdBrightnessUp, spawn, SHCMD("lightctrl smc::kbd_backlight 5%+ Keyboard") },
|
||||||
|
{ 0, XF86XK_AudioMute, spawn, SHCMD("volumectrl toggle") },
|
||||||
|
{ 0, XF86XK_AudioLowerVolume, spawn, SHCMD("volumectrl 5%-") },
|
||||||
|
{ 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("volumectrl 5%+") },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* button definitions */
|
/* button definitions */
|
||||||
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
||||||
static const Button buttons[] = {
|
static const Button buttons[] = {
|
||||||
/* click event mask button function argument */
|
/* 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, Button1, movemouse, {0} },
|
||||||
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||||
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||||
|
|
314
dwm.c
314
dwm.c
|
@ -121,10 +121,6 @@ struct Monitor {
|
||||||
int by; /* bar geometry */
|
int by; /* bar geometry */
|
||||||
int mx, my, mw, mh; /* screen size */
|
int mx, my, mw, mh; /* screen size */
|
||||||
int wx, wy, ww, wh; /* window area */
|
int wx, wy, ww, wh; /* window area */
|
||||||
int gappih; /* horizontal gap between windows */
|
|
||||||
int gappiv; /* vertical gap between windows */
|
|
||||||
int gappoh; /* horizontal outer gaps */
|
|
||||||
int gappov; /* vertical outer gaps */
|
|
||||||
unsigned int seltags;
|
unsigned int seltags;
|
||||||
unsigned int sellt;
|
unsigned int sellt;
|
||||||
unsigned int tagset[2];
|
unsigned int tagset[2];
|
||||||
|
@ -184,6 +180,7 @@ 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);
|
||||||
|
@ -224,15 +221,12 @@ static void sendmon(Client *c, Monitor *m);
|
||||||
static void setclientstate(Client *c, long state);
|
static void setclientstate(Client *c, long state);
|
||||||
static void setfocus(Client *c);
|
static void setfocus(Client *c);
|
||||||
static void setfullscreen(Client *c, int fullscreen);
|
static void setfullscreen(Client *c, int fullscreen);
|
||||||
static void setgaps(int oh, int ov, int ih, int iv);
|
|
||||||
static void incrgaps(const Arg *arg);
|
|
||||||
static void togglegaps(const Arg *arg);
|
|
||||||
static void defaultgaps(const Arg *arg);
|
|
||||||
static void setsticky(Client *c, int sticky);
|
static void setsticky(Client *c, int sticky);
|
||||||
static void setlayout(const Arg *arg);
|
static void setlayout(const Arg *arg);
|
||||||
static void setmfact(const Arg *arg);
|
static void setmfact(const Arg *arg);
|
||||||
static void setup(void);
|
static void setup(void);
|
||||||
static void seturgent(Client *c, int urg);
|
static void seturgent(Client *c, int urg);
|
||||||
|
static void shiftview(const Arg *arg);
|
||||||
static void showhide(Client *c);
|
static void showhide(Client *c);
|
||||||
static void spawn(const Arg *arg);
|
static void spawn(const Arg *arg);
|
||||||
static void tag(const Arg *arg);
|
static void tag(const Arg *arg);
|
||||||
|
@ -266,14 +260,14 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||||
static void zoom(const Arg *arg);
|
static void zoom(const Arg *arg);
|
||||||
static void load_xresources(void);
|
static void load_xresources(void);
|
||||||
static void resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst);
|
static void resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst);
|
||||||
|
static void bstack(Monitor *m);
|
||||||
|
|
||||||
/* 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; /* bar height */
|
static int bh; /* bar height */
|
||||||
static int enablegaps = 1; /* enables gaps, used by togglegaps */
|
|
||||||
static int lrpad; /* sum of left and right padding for text */
|
static int lrpad; /* sum of left and right padding for text */
|
||||||
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
||||||
static unsigned int numlockmask = 0;
|
static unsigned int numlockmask = 0;
|
||||||
|
@ -543,7 +537,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]);
|
||||||
free(scheme);
|
free(scheme);
|
||||||
XDestroyWindow(dpy, wmcheckwin);
|
XDestroyWindow(dpy, wmcheckwin);
|
||||||
|
@ -703,10 +697,6 @@ createmon(void)
|
||||||
m->nmaster = nmaster;
|
m->nmaster = nmaster;
|
||||||
m->showbar = showbar;
|
m->showbar = showbar;
|
||||||
m->topbar = topbar;
|
m->topbar = topbar;
|
||||||
m->gappih = gappih;
|
|
||||||
m->gappiv = gappiv;
|
|
||||||
m->gappoh = gappoh;
|
|
||||||
m->gappov = gappov;
|
|
||||||
m->lt[0] = &layouts[0];
|
m->lt[0] = &layouts[0];
|
||||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||||
|
@ -776,6 +766,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)
|
||||||
{
|
{
|
||||||
|
@ -790,9 +888,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]);
|
tw = m->ww - drawstatusbar(m, bh, stext);
|
||||||
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) {
|
for (c = m->clients; c; c = c->next) {
|
||||||
|
@ -1195,49 +1291,16 @@ maprequest(XEvent *e)
|
||||||
void
|
void
|
||||||
monocle(Monitor *m)
|
monocle(Monitor *m)
|
||||||
{
|
{
|
||||||
unsigned int n = 0, oe = enablegaps;
|
unsigned int n = 0;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
|
||||||
if (n == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (smartgaps == n) {
|
|
||||||
oe = 0; // outer gaps disabled
|
|
||||||
}
|
|
||||||
|
|
||||||
n = 0;
|
|
||||||
|
|
||||||
for (c = m->clients; c; c = c->next)
|
for (c = m->clients; c; c = c->next)
|
||||||
if (ISVISIBLE(c))
|
if (ISVISIBLE(c))
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
if (n > 0) /* override layout symbol */
|
if (n > 0) /* override layout symbol */
|
||||||
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
|
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
|
||||||
|
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
|
||||||
int newx, newy, neww, newh;
|
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
|
||||||
for (c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
|
|
||||||
if (m->gappoh == 0) {
|
|
||||||
newx = m->wx - c->bw;
|
|
||||||
newy = m->wy - c->bw;
|
|
||||||
neww = m->ww;
|
|
||||||
newh = m->wh;
|
|
||||||
} else {
|
|
||||||
newx = m->wx + m->gappoh*oe - c->bw;
|
|
||||||
newy = m->wy + m->gappoh*oe - c->bw;
|
|
||||||
neww = m->ww - 2 * (m->gappoh*oe + c->bw);
|
|
||||||
newh = m->wh - 2 * (m->gappoh*oe + c->bw);
|
|
||||||
}
|
|
||||||
applysizehints(c, &newx, &newy, &neww, &newh, 0);
|
|
||||||
if (neww < m->ww) {
|
|
||||||
newx = m->wx + (m->ww - (neww + 2 * c->bw)) / 2;
|
|
||||||
}
|
|
||||||
if (newh < m->wh) {
|
|
||||||
newy = m->wy + (m->wh - (newh + 2 * c->bw)) / 2;
|
|
||||||
resize(c, newx, newy, neww, newh, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1264,6 +1327,7 @@ movemouse(const Arg *arg)
|
||||||
Client *c;
|
Client *c;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
Time lasttime = 0;
|
||||||
|
|
||||||
if (!(c = selmon->sel))
|
if (!(c = selmon->sel))
|
||||||
return;
|
return;
|
||||||
|
@ -1286,6 +1350,10 @@ movemouse(const Arg *arg)
|
||||||
handler[ev.type](&ev);
|
handler[ev.type](&ev);
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
|
if ((ev.xmotion.time - lasttime) <= (1000 / 120))
|
||||||
|
continue;
|
||||||
|
lasttime = ev.xmotion.time;
|
||||||
|
|
||||||
nx = ocx + (ev.xmotion.x - x);
|
nx = ocx + (ev.xmotion.x - x);
|
||||||
ny = ocy + (ev.xmotion.y - y);
|
ny = ocy + (ev.xmotion.y - y);
|
||||||
if (abs(selmon->wx - nx) < snap)
|
if (abs(selmon->wx - nx) < snap)
|
||||||
|
@ -1463,23 +1531,23 @@ resizeclient(Client *c, int x, int y, int w, int h)
|
||||||
void
|
void
|
||||||
resizemouse(const Arg *arg)
|
resizemouse(const Arg *arg)
|
||||||
{
|
{
|
||||||
int x, y, ocw, och, nw, nh;
|
int ocx, ocy, nw, nh;
|
||||||
Client *c;
|
Client *c;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
Time lasttime = 0;
|
||||||
|
|
||||||
if (!(c = selmon->sel))
|
if (!(c = selmon->sel))
|
||||||
return;
|
return;
|
||||||
if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */
|
if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */
|
||||||
return;
|
return;
|
||||||
restack(selmon);
|
restack(selmon);
|
||||||
ocw = c->w;
|
ocx = c->x;
|
||||||
och = c->h;
|
ocy = c->y;
|
||||||
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
||||||
None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
|
None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
|
||||||
return;
|
return;
|
||||||
if(!getrootptr(&x, &y))
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
|
||||||
return;
|
|
||||||
do {
|
do {
|
||||||
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
|
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
|
||||||
switch(ev.type) {
|
switch(ev.type) {
|
||||||
|
@ -1489,8 +1557,12 @@ resizemouse(const Arg *arg)
|
||||||
handler[ev.type](&ev);
|
handler[ev.type](&ev);
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
nw = MAX(ocw + (ev.xmotion.x - x), 1);
|
if ((ev.xmotion.time - lasttime) <= (1000 / 60))
|
||||||
nh = MAX(och + (ev.xmotion.y - y), 1);
|
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
|
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)
|
&& c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh)
|
||||||
{
|
{
|
||||||
|
@ -1503,6 +1575,7 @@ resizemouse(const Arg *arg)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (ev.type != ButtonRelease);
|
} 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);
|
XUngrabPointer(dpy, CurrentTime);
|
||||||
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||||
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
|
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
|
||||||
|
@ -1512,45 +1585,6 @@ resizemouse(const Arg *arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
setgaps(int oh, int ov, int ih, int iv)
|
|
||||||
{
|
|
||||||
if (oh < 0) oh = 0;
|
|
||||||
if (ov < 0) ov = 0;
|
|
||||||
if (ih < 0) ih = 0;
|
|
||||||
if (iv < 0) iv = 0;
|
|
||||||
|
|
||||||
selmon->gappoh = oh;
|
|
||||||
selmon->gappov = ov;
|
|
||||||
selmon->gappih = ih;
|
|
||||||
selmon->gappiv = iv;
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
togglegaps(const Arg *arg)
|
|
||||||
{
|
|
||||||
enablegaps = !enablegaps;
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
defaultgaps(const Arg *arg)
|
|
||||||
{
|
|
||||||
setgaps(gappoh, gappov, gappih, gappiv);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
incrgaps(const Arg *arg)
|
|
||||||
{
|
|
||||||
setgaps(
|
|
||||||
selmon->gappoh + arg->i,
|
|
||||||
selmon->gappov + arg->i,
|
|
||||||
selmon->gappih + arg->i,
|
|
||||||
selmon->gappiv + arg->i
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
restack(Monitor *m)
|
restack(Monitor *m)
|
||||||
{
|
{
|
||||||
|
@ -1802,7 +1836,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 */
|
||||||
|
@ -1844,6 +1879,21 @@ seturgent(Client *c, int urg)
|
||||||
XFree(wmh);
|
XFree(wmh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
shiftview(const Arg *arg) {
|
||||||
|
Arg shifted;
|
||||||
|
|
||||||
|
if(arg->i > 0) // left circular shift
|
||||||
|
shifted.ui = (selmon->tagset[selmon->seltags] << arg->i)
|
||||||
|
| (selmon->tagset[selmon->seltags] >> (LENGTH(tags) - arg->i));
|
||||||
|
|
||||||
|
else // right circular shift
|
||||||
|
shifted.ui = selmon->tagset[selmon->seltags] >> (- arg->i)
|
||||||
|
| selmon->tagset[selmon->seltags] << (LENGTH(tags) + arg->i);
|
||||||
|
|
||||||
|
view(&shifted);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
showhide(Client *c)
|
showhide(Client *c)
|
||||||
{
|
{
|
||||||
|
@ -1905,34 +1955,28 @@ tagmon(const Arg *arg)
|
||||||
void
|
void
|
||||||
tile(Monitor *m)
|
tile(Monitor *m)
|
||||||
{
|
{
|
||||||
unsigned int i, n, h, r, oe = enablegaps, ie = enablegaps, mw, my, ty;
|
unsigned int i, n, h, mw, my, ty;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (smartgaps == n) {
|
|
||||||
oe = 0; // outer gaps disabled
|
|
||||||
}
|
|
||||||
|
|
||||||
if (n > m->nmaster)
|
if (n > m->nmaster)
|
||||||
mw = m->nmaster ? (m->ww + m->gappiv*ie) * m->mfact : 0;
|
mw = m->nmaster ? m->ww * m->mfact : 0;
|
||||||
else
|
else
|
||||||
mw = m->ww - 2*m->gappov*oe + m->gappiv*ie;
|
mw = m->ww;
|
||||||
for (i = 0, my = ty = m->gappoh*oe, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||||
if (i < m->nmaster) {
|
if (i < m->nmaster) {
|
||||||
r = MIN(n, m->nmaster) - i;
|
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
||||||
h = (m->wh - my - m->gappoh*oe - m->gappih*ie * (r - 1)) / r;
|
resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
|
||||||
resize(c, m->wx + m->gappov*oe, m->wy + my, mw - (2*c->bw) - m->gappiv*ie, h - (2*c->bw), 0);
|
if (my + HEIGHT(c) < m->wh)
|
||||||
if (my + HEIGHT(c) + m->gappih*ie < m->wh)
|
my += HEIGHT(c);
|
||||||
my += HEIGHT(c) + m->gappih*ie;
|
|
||||||
} else {
|
} else {
|
||||||
r = n - i;
|
h = (m->wh - ty) / (n - i);
|
||||||
h = (m->wh - ty - m->gappoh*oe - m->gappih*ie * (r - 1)) / r;
|
resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
|
||||||
resize(c, m->wx + mw + m->gappov*oe, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappov*oe, h - (2*c->bw), 0);
|
if (ty + HEIGHT(c) < m->wh)
|
||||||
if (ty + HEIGHT(c) + m->gappih*ie < m->wh)
|
ty += HEIGHT(c);
|
||||||
ty += HEIGHT(c) + m->gappih*ie;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2501,3 +2545,35 @@ main(int argc, char *argv[])
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bstack(Monitor *m) {
|
||||||
|
int w, h, mh, mx, tx, ty, tw;
|
||||||
|
unsigned int i, n;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
if (n == 0)
|
||||||
|
return;
|
||||||
|
if (n > m->nmaster) {
|
||||||
|
mh = m->nmaster ? m->mfact * m->wh : 0;
|
||||||
|
tw = m->ww / (n - m->nmaster);
|
||||||
|
ty = m->wy + mh;
|
||||||
|
} else {
|
||||||
|
mh = m->wh;
|
||||||
|
tw = m->ww;
|
||||||
|
ty = m->wy;
|
||||||
|
}
|
||||||
|
for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||||
|
if (i < m->nmaster) {
|
||||||
|
w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
|
||||||
|
resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
|
||||||
|
mx += WIDTH(c);
|
||||||
|
} else {
|
||||||
|
h = m->wh - mh;
|
||||||
|
resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0);
|
||||||
|
if (tw != m->ww)
|
||||||
|
tx += WIDTH(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
19
shiftview.c
19
shiftview.c
|
@ -1,19 +0,0 @@
|
||||||
/** Function to shift the current view to the left/right
|
|
||||||
*
|
|
||||||
* @param: "arg->i" stores the number of tags to shift right (positive value)
|
|
||||||
* or left (negative value)
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
shiftview(const Arg *arg) {
|
|
||||||
Arg shifted;
|
|
||||||
|
|
||||||
if(arg->i > 0) // left circular shift
|
|
||||||
shifted.ui = (selmon->tagset[selmon->seltags] << arg->i)
|
|
||||||
| (selmon->tagset[selmon->seltags] >> (LENGTH(tags) - arg->i));
|
|
||||||
|
|
||||||
else // right circular shift
|
|
||||||
shifted.ui = selmon->tagset[selmon->seltags] >> (- arg->i)
|
|
||||||
| selmon->tagset[selmon->seltags] << (LENGTH(tags) + arg->i);
|
|
||||||
|
|
||||||
view(&shifted);
|
|
||||||
}
|
|
Loading…
Reference in a new issue