Compare commits
3 Commits
18b76b790d
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c3abae4e6 | ||
|
|
93f26863d1 | ||
|
|
74edc27caa |
55
config.def.h
55
config.def.h
@@ -1,8 +1,7 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
/* appearance */
|
||||
static const unsigned int borderpx = 2; /* border pixel of windows */
|
||||
static const unsigned int gappx = 2; /* gaps between windows */
|
||||
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 */
|
||||
@@ -13,19 +12,10 @@ 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 col_border_focus_light[] = "#df8c20"; // hsl(34 75% 50%)
|
||||
static const char col_border_focus_dark[] = "#b25e34"; // hsl(20 55% 45%)
|
||||
static const char *colorsdark[][3] = {
|
||||
static const char *colors[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||
[SchemeSel] = { col_gray4, col_cyan, col_border_focus_dark },
|
||||
[SchemeHid] = { col_cyan, col_gray1, col_cyan },
|
||||
};
|
||||
static const char *colorslight[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { col_gray1, col_gray3, col_gray2 },
|
||||
[SchemeSel] = { col_cyan, col_gray4, col_border_focus_light },
|
||||
[SchemeHid] = { col_cyan, col_gray1, col_cyan },
|
||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||
};
|
||||
|
||||
/* tagging */
|
||||
@@ -46,6 +36,7 @@ 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 int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||
static const int refreshrate = 120; /* refresh rate (per second) for client move/resize */
|
||||
|
||||
static const Layout layouts[] = {
|
||||
/* symbol arrange function */
|
||||
@@ -55,7 +46,7 @@ static const Layout layouts[] = {
|
||||
};
|
||||
|
||||
/* key definitions */
|
||||
#define MODKEY Mod4Mask
|
||||
#define MODKEY Mod1Mask
|
||||
#define TAGKEYS(KEY,TAG) \
|
||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
@@ -66,24 +57,17 @@ static const Layout layouts[] = {
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
|
||||
/* commands */
|
||||
static char dmenumon[2] = "0"; /* component of dmenu{dark,light}, manipulated in spawndmenu() */
|
||||
static const char *dmenudark[] = { "dmenu_run", "-m", dmenumon, "-i", "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||
static const char *dmenulight[] = { "dmenu_run", "-m", dmenumon, "-i", "-fn", dmenufont, "-nb", col_gray3, "-nf", col_gray1, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||
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 const char *lockcmd[] = { "slock", NULL };
|
||||
static const char *suspendcmd[] = { "systemctl", "suspend", NULL };
|
||||
static const char *themecmd[] = { "lupan-set-theme", "toggle", NULL };
|
||||
|
||||
#include "exitdwm.c"
|
||||
static const Key keys[] = {
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XK_p, spawndmenu, {0} },
|
||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||
{ MODKEY, XK_b, togglebar, {0} },
|
||||
{ MODKEY, XK_j, focusstackvis, {.i = +1 } },
|
||||
{ MODKEY, XK_k, focusstackvis, {.i = -1 } },
|
||||
{ MODKEY|ShiftMask, XK_j, focusstackhid, {.i = +1 } },
|
||||
{ MODKEY|ShiftMask, XK_k, focusstackhid, {.i = -1 } },
|
||||
{ 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} },
|
||||
@@ -102,9 +86,6 @@ static const Key keys[] = {
|
||||
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||
{ MODKEY, XK_s, show, {0} },
|
||||
{ MODKEY|ShiftMask, XK_s, showall, {0} },
|
||||
{ MODKEY, XK_h, hide, {0} },
|
||||
TAGKEYS( XK_1, 0)
|
||||
TAGKEYS( XK_2, 1)
|
||||
TAGKEYS( XK_3, 2)
|
||||
@@ -114,22 +95,7 @@ static const Key keys[] = {
|
||||
TAGKEYS( XK_7, 6)
|
||||
TAGKEYS( XK_8, 7)
|
||||
TAGKEYS( XK_9, 8)
|
||||
{ ControlMask, XK_1, focusbynum, {.i = 0} },
|
||||
{ ControlMask, XK_2, focusbynum, {.i = 1} },
|
||||
{ ControlMask, XK_3, focusbynum, {.i = 2} },
|
||||
{ ControlMask, XK_4, focusbynum, {.i = 3} },
|
||||
{ ControlMask, XK_5, focusbynum, {.i = 4} },
|
||||
{ ControlMask, XK_6, focusbynum, {.i = 5} },
|
||||
{ ControlMask, XK_7, focusbynum, {.i = 6} },
|
||||
{ ControlMask, XK_8, focusbynum, {.i = 7} },
|
||||
{ ControlMask, XK_9, focusbynum, {.i = 8} },
|
||||
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} },
|
||||
{ MODKEY|ShiftMask, XK_e, exitdwm, {0} },
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_s, spawn, {.v = suspendcmd } },
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_l, spawn, {.v = lockcmd } },
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_t, spawn, {.v = themecmd } },
|
||||
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
@@ -138,7 +104,6 @@ static const Button buttons[] = {
|
||||
/* click event mask button function argument */
|
||||
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
||||
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
||||
{ ClkWinTitle, 0, Button1, togglewin, {0} },
|
||||
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||
|
||||
29
drw.c
29
drw.c
@@ -178,8 +178,7 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
||||
die("error, cannot allocate color '%s'", clrname);
|
||||
}
|
||||
|
||||
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||
* returned color scheme when done using it. */
|
||||
/* Create color schemes. */
|
||||
Clr *
|
||||
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||
{
|
||||
@@ -187,7 +186,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||
Clr *ret;
|
||||
|
||||
/* need at least two colors for a scheme */
|
||||
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor))))
|
||||
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(Clr))))
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < clrcount; i++)
|
||||
@@ -195,6 +194,30 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
drw_clr_free(Drw *drw, Clr *c)
|
||||
{
|
||||
if (!drw || !c)
|
||||
return;
|
||||
|
||||
/* c is typedef XftColor Clr */
|
||||
XftColorFree(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
||||
DefaultColormap(drw->dpy, drw->screen), c);
|
||||
}
|
||||
|
||||
void
|
||||
drw_scm_free(Drw *drw, Clr *scm, size_t clrcount)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!drw || !scm)
|
||||
return;
|
||||
|
||||
for (i = 0; i < clrcount; i++)
|
||||
drw_clr_free(drw, &scm[i]);
|
||||
free(scm);
|
||||
}
|
||||
|
||||
void
|
||||
drw_setfontset(Drw *drw, Fnt *set)
|
||||
{
|
||||
|
||||
2
drw.h
2
drw.h
@@ -40,7 +40,9 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in
|
||||
|
||||
/* Colorscheme abstraction */
|
||||
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
||||
void drw_clr_free(Drw *drw, Clr *c);
|
||||
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
||||
void drw_scm_free(Drw *drw, Clr *scm, size_t clrcount);
|
||||
|
||||
/* Cursor abstraction */
|
||||
Cur *drw_cur_create(Drw *drw, int shape);
|
||||
|
||||
10
dwm.1
10
dwm.1
@@ -142,9 +142,6 @@ Add/remove all windows with nth tag to/from the view.
|
||||
.TP
|
||||
.B Mod1\-Shift\-q
|
||||
Quit dwm.
|
||||
.TP
|
||||
.B Mod1\-Control\-Shift\-q
|
||||
Restart dwm.
|
||||
.SS Mouse commands
|
||||
.TP
|
||||
.B Mod1\-Button1
|
||||
@@ -158,13 +155,6 @@ Resize focused window while dragging. Tiled windows will be toggled to the float
|
||||
.SH CUSTOMIZATION
|
||||
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||
code. This keeps it fast, secure and simple.
|
||||
.SH SIGNALS
|
||||
.TP
|
||||
.B SIGHUP - 1
|
||||
Restart the dwm process.
|
||||
.TP
|
||||
.B SIGTERM - 15
|
||||
Cleanly terminate the dwm process.
|
||||
.SH SEE ALSO
|
||||
.BR dmenu (1),
|
||||
.BR st (1)
|
||||
|
||||
456
dwm.c
456
dwm.c
@@ -50,20 +50,18 @@
|
||||
#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 HIDDEN(C) ((getstate(C->win) == IconicState))
|
||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||
#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx)
|
||||
#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx)
|
||||
#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)
|
||||
|
||||
/* enums */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
enum { SchemeNorm, SchemeSel, SchemeHid }; /* color schemes */
|
||||
enum { SchemeNorm, SchemeSel }; /* color schemes */
|
||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||
NetWMWindowTypeDialog, NetClientList, NetClientInfo, NetLast }; /* EWMH atoms */
|
||||
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
||||
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
||||
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
||||
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
|
||||
@@ -118,8 +116,6 @@ struct Monitor {
|
||||
int nmaster;
|
||||
int num;
|
||||
int by; /* bar geometry */
|
||||
int btw; /* width of tasks portion of bar */
|
||||
int bt; /* number of tasks */
|
||||
int mx, my, mw, mh; /* screen size */
|
||||
int wx, wy, ww, wh; /* window area */
|
||||
unsigned int seltags;
|
||||
@@ -127,7 +123,6 @@ struct Monitor {
|
||||
unsigned int tagset[2];
|
||||
int showbar;
|
||||
int topbar;
|
||||
int hidsel;
|
||||
Client *clients;
|
||||
Client *sel;
|
||||
Client *stack;
|
||||
@@ -157,7 +152,6 @@ static void checkotherwm(void);
|
||||
static void cleanup(void);
|
||||
static void cleanupmon(Monitor *mon);
|
||||
static void clientmessage(XEvent *e);
|
||||
static void colormodehandler(int sig);
|
||||
static void configure(Client *c);
|
||||
static void configurenotify(XEvent *e);
|
||||
static void configurerequest(XEvent *e);
|
||||
@@ -173,17 +167,13 @@ static void expose(XEvent *e);
|
||||
static void focus(Client *c);
|
||||
static void focusin(XEvent *e);
|
||||
static void focusmon(const Arg *arg);
|
||||
static void focusstackvis(const Arg *arg);
|
||||
static void focusstackhid(const Arg *arg);
|
||||
static void focusstack(int inc, int vis);
|
||||
static void focusstack(const Arg *arg);
|
||||
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 hide(const Arg *arg);
|
||||
static void hidewin(Client *c);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void keypress(XEvent *e);
|
||||
static void killclient(const Arg *arg);
|
||||
@@ -207,32 +197,21 @@ static void scan(void);
|
||||
static int sendevent(Client *c, Atom proto);
|
||||
static void sendmon(Client *c, Monitor *m);
|
||||
static void setclientstate(Client *c, long state);
|
||||
static void setclienttagprop(Client *c);
|
||||
static void setcolormode(void);
|
||||
static void setfocus(Client *c);
|
||||
static void setfullscreen(Client *c, int fullscreen);
|
||||
static void setlayout(const Arg *arg);
|
||||
static void setmfact(const Arg *arg);
|
||||
static void setup(void);
|
||||
static void seturgent(Client *c, int urg);
|
||||
static void show(const Arg *arg);
|
||||
static void showall(const Arg *arg);
|
||||
static void showwin(Client *c);
|
||||
static void showhide(Client *c);
|
||||
static void sigchld(int unused);
|
||||
static void sighup(int unused);
|
||||
static void sigterm(int unused);
|
||||
static void spawn(const Arg *arg);
|
||||
static void spawndmenu(const Arg *arg);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *m);
|
||||
static void togglebar(const Arg *arg);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void focusbynum(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
static void toggleview(const Arg *arg);
|
||||
static void togglewin(const Arg *arg);
|
||||
static void unfocus(Client *c, int setfocus);
|
||||
static void unmanage(Client *c, int destroyed);
|
||||
static void unmapnotify(XEvent *e);
|
||||
@@ -247,7 +226,6 @@ static void updatetitle(Client *c);
|
||||
static void updatewindowtype(Client *c);
|
||||
static void updatewmhints(Client *c);
|
||||
static void view(const Arg *arg);
|
||||
static void warp(const Client *c);
|
||||
static Client *wintoclient(Window w);
|
||||
static Monitor *wintomon(Window w);
|
||||
static int xerror(Display *dpy, XErrorEvent *ee);
|
||||
@@ -281,16 +259,13 @@ static void (*handler[LASTEvent]) (XEvent *) = {
|
||||
[UnmapNotify] = unmapnotify
|
||||
};
|
||||
static Atom wmatom[WMLast], netatom[NetLast];
|
||||
static int restart = 0;
|
||||
static int running = 1;
|
||||
static Cur *cursor[CurLast];
|
||||
static Clr **scheme, **schemedark, **schemelight;
|
||||
static Clr **scheme;
|
||||
static Display *dpy;
|
||||
static Drw *drw;
|
||||
static Monitor *mons, *selmon;
|
||||
static Window root, wmcheckwin;
|
||||
static const char **dmenucmd;
|
||||
static int colormodechanged;
|
||||
|
||||
/* configuration, allows nested code to access above variables */
|
||||
#include "config.h"
|
||||
@@ -465,25 +440,10 @@ buttonpress(XEvent *e)
|
||||
arg.ui = 1 << i;
|
||||
} else if (ev->x < x + TEXTW(selmon->ltsymbol))
|
||||
click = ClkLtSymbol;
|
||||
/* 2px right padding */
|
||||
else if (ev->x > selmon->ww - TEXTW(stext) + lrpad - 2)
|
||||
else if (ev->x > selmon->ww - (int)TEXTW(stext))
|
||||
click = ClkStatusText;
|
||||
else {
|
||||
x += TEXTW(selmon->ltsymbol);
|
||||
c = m->clients;
|
||||
|
||||
if (c) {
|
||||
do {
|
||||
if (!ISVISIBLE(c))
|
||||
continue;
|
||||
else
|
||||
x +=(1.0 / (double)m->bt) * m->btw;
|
||||
} while (ev->x > x && (c = c->next));
|
||||
|
||||
click = ClkWinTitle;
|
||||
arg.v = c;
|
||||
}
|
||||
}
|
||||
} else if ((c = wintoclient(ev->window))) {
|
||||
focus(c);
|
||||
restack(selmon);
|
||||
@@ -493,7 +453,7 @@ buttonpress(XEvent *e)
|
||||
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 || click == ClkWinTitle) && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
|
||||
buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -525,12 +485,9 @@ cleanup(void)
|
||||
cleanupmon(mons);
|
||||
for (i = 0; i < CurLast; i++)
|
||||
drw_cur_free(drw, cursor[i]);
|
||||
for (i = 0; i < LENGTH(colorsdark); i++) {
|
||||
free(schemedark[i]);
|
||||
free(schemelight[i]);
|
||||
}
|
||||
free(schemedark);
|
||||
free(schemelight);
|
||||
for (i = 0; i < LENGTH(colors); i++)
|
||||
drw_scm_free(drw, scheme[i], 3);
|
||||
free(scheme);
|
||||
XDestroyWindow(dpy, wmcheckwin);
|
||||
drw_free(drw);
|
||||
XSync(dpy, False);
|
||||
@@ -573,12 +530,6 @@ clientmessage(XEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
colormodehandler(int sig)
|
||||
{
|
||||
colormodechanged = 1;
|
||||
}
|
||||
|
||||
void
|
||||
configure(Client *c)
|
||||
{
|
||||
@@ -746,7 +697,7 @@ dirtomon(int dir)
|
||||
void
|
||||
drawbar(Monitor *m)
|
||||
{
|
||||
int x, w, tw = 0, n = 0, scm;
|
||||
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;
|
||||
@@ -763,8 +714,6 @@ drawbar(Monitor *m)
|
||||
}
|
||||
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (ISVISIBLE(c))
|
||||
n++;
|
||||
occ |= c->tags;
|
||||
if (c->isurgent)
|
||||
urg |= c->tags;
|
||||
@@ -785,36 +734,16 @@ drawbar(Monitor *m)
|
||||
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
||||
|
||||
if ((w = m->ww - tw - x) > bh) {
|
||||
if (n > 0) {
|
||||
int remainder = w % n;
|
||||
int tabw = (1.0 / (double)n) * w + 1;
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (!ISVISIBLE(c))
|
||||
continue;
|
||||
if (m->sel == c)
|
||||
scm = SchemeSel;
|
||||
else if (HIDDEN(c))
|
||||
scm = SchemeHid;
|
||||
else
|
||||
scm = SchemeNorm;
|
||||
drw_setscheme(drw, scheme[scm]);
|
||||
|
||||
if (remainder >= 0) {
|
||||
if (remainder == 0) {
|
||||
tabw--;
|
||||
}
|
||||
remainder--;
|
||||
}
|
||||
drw_text(drw, x, 0, tabw, bh, lrpad / 2, c->name, 0);
|
||||
x += tabw;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
m->bt = n;
|
||||
m->btw = w;
|
||||
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
|
||||
}
|
||||
|
||||
@@ -860,17 +789,9 @@ void
|
||||
focus(Client *c)
|
||||
{
|
||||
if (!c || !ISVISIBLE(c))
|
||||
for (c = selmon->stack; c && (!ISVISIBLE(c) || HIDDEN(c)); c = c->snext);
|
||||
if (selmon->sel && selmon->sel != c) {
|
||||
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
|
||||
if (selmon->sel && selmon->sel != c)
|
||||
unfocus(selmon->sel, 0);
|
||||
|
||||
if (selmon->hidsel) {
|
||||
hidewin(selmon->sel);
|
||||
if (c)
|
||||
arrange(c->mon);
|
||||
selmon->hidsel = 0;
|
||||
}
|
||||
}
|
||||
if (c) {
|
||||
if (c->mon != selmon)
|
||||
selmon = c->mon;
|
||||
@@ -911,56 +832,31 @@ focusmon(const Arg *arg)
|
||||
unfocus(selmon->sel, 0);
|
||||
selmon = m;
|
||||
focus(NULL);
|
||||
warp(selmon->sel);
|
||||
}
|
||||
|
||||
void
|
||||
focusstackvis(const Arg *arg) {
|
||||
focusstack(arg->i, 0);
|
||||
}
|
||||
|
||||
void
|
||||
focusstackhid(const Arg *arg) {
|
||||
focusstack(arg->i, 1);
|
||||
}
|
||||
|
||||
void
|
||||
focusstack(int inc, int hid)
|
||||
focusstack(const Arg *arg)
|
||||
{
|
||||
Client *c = NULL, *i;
|
||||
// if no client selected AND exclude hidden client; if client selected but fullscreened
|
||||
if ((!selmon->sel && !hid) || (selmon->sel && selmon->sel->isfullscreen && lockfullscreen))
|
||||
|
||||
if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
|
||||
return;
|
||||
if (!selmon->clients)
|
||||
return;
|
||||
if (inc > 0) {
|
||||
if (selmon->sel)
|
||||
for (c = selmon->sel->next;
|
||||
c && (!ISVISIBLE(c) || (!hid && HIDDEN(c)));
|
||||
c = c->next);
|
||||
if (arg->i > 0) {
|
||||
for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
|
||||
if (!c)
|
||||
for (c = selmon->clients;
|
||||
c && (!ISVISIBLE(c) || (!hid && HIDDEN(c)));
|
||||
c = c->next);
|
||||
for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
|
||||
} else {
|
||||
if (selmon->sel) {
|
||||
for (i = selmon->clients; i != selmon->sel; i = i->next)
|
||||
if (ISVISIBLE(i) && !(!hid && HIDDEN(i)))
|
||||
if (ISVISIBLE(i))
|
||||
c = i;
|
||||
} else
|
||||
c = selmon->clients;
|
||||
if (!c)
|
||||
for (; i; i = i->next)
|
||||
if (ISVISIBLE(i) && !(!hid && HIDDEN(i)))
|
||||
if (ISVISIBLE(i))
|
||||
c = i;
|
||||
}
|
||||
if (c) {
|
||||
focus(c);
|
||||
restack(selmon);
|
||||
if (HIDDEN(c)) {
|
||||
showwin(c);
|
||||
c->mon->hidsel = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1080,36 +976,6 @@ grabkeys(void)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
hide(const Arg *arg)
|
||||
{
|
||||
hidewin(selmon->sel);
|
||||
focus(NULL);
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
void
|
||||
hidewin(Client *c) {
|
||||
if (!c || HIDDEN(c))
|
||||
return;
|
||||
|
||||
Window w = c->win;
|
||||
static XWindowAttributes ra, ca;
|
||||
|
||||
// more or less taken directly from blackbox's hide() function
|
||||
XGrabServer(dpy);
|
||||
XGetWindowAttributes(dpy, root, &ra);
|
||||
XGetWindowAttributes(dpy, w, &ca);
|
||||
// prevent UnmapNotify events
|
||||
XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask);
|
||||
XSelectInput(dpy, w, ca.your_event_mask & ~StructureNotifyMask);
|
||||
XUnmapWindow(dpy, w);
|
||||
setclientstate(c, IconicState);
|
||||
XSelectInput(dpy, root, ra.your_event_mask);
|
||||
XSelectInput(dpy, w, ca.your_event_mask);
|
||||
XUngrabServer(dpy);
|
||||
}
|
||||
|
||||
void
|
||||
incnmaster(const Arg *arg)
|
||||
{
|
||||
@@ -1201,26 +1067,6 @@ manage(Window w, XWindowAttributes *wa)
|
||||
updatewindowtype(c);
|
||||
updatesizehints(c);
|
||||
updatewmhints(c);
|
||||
{
|
||||
int format;
|
||||
unsigned long *data, n, extra;
|
||||
Monitor *m;
|
||||
Atom atom;
|
||||
if (XGetWindowProperty(dpy, c->win, netatom[NetClientInfo], 0L, 2L, False, XA_CARDINAL,
|
||||
&atom, &format, &n, &extra, (unsigned char **)&data) == Success && n == 2) {
|
||||
c->tags = *data;
|
||||
for (m = mons; m; m = m->next) {
|
||||
if (m->num == *(data+1)) {
|
||||
c->mon = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (n > 0)
|
||||
XFree(data);
|
||||
}
|
||||
setclienttagprop(c);
|
||||
|
||||
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
||||
grabbuttons(c, 0);
|
||||
if (!c->isfloating)
|
||||
@@ -1232,13 +1078,11 @@ manage(Window w, XWindowAttributes *wa)
|
||||
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
|
||||
(unsigned char *) &(c->win), 1);
|
||||
XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
|
||||
if (!HIDDEN(c))
|
||||
setclientstate(c, NormalState);
|
||||
if (c->mon == selmon)
|
||||
unfocus(selmon->sel, 0);
|
||||
c->mon->sel = c;
|
||||
arrange(c->mon);
|
||||
if (!HIDDEN(c))
|
||||
XMapWindow(dpy, c->win);
|
||||
focus(NULL);
|
||||
}
|
||||
@@ -1327,7 +1171,7 @@ movemouse(const Arg *arg)
|
||||
handler[ev.type](&ev);
|
||||
break;
|
||||
case MotionNotify:
|
||||
if ((ev.xmotion.time - lasttime) <= (1000 / 60))
|
||||
if ((ev.xmotion.time - lasttime) <= (1000 / refreshrate))
|
||||
continue;
|
||||
lasttime = ev.xmotion.time;
|
||||
|
||||
@@ -1360,7 +1204,7 @@ movemouse(const Arg *arg)
|
||||
Client *
|
||||
nexttiled(Client *c)
|
||||
{
|
||||
for (; c && (c->isfloating || !ISVISIBLE(c) || HIDDEN(c)); c = c->next);
|
||||
for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -1380,10 +1224,6 @@ propertynotify(XEvent *e)
|
||||
Window trans;
|
||||
XPropertyEvent *ev = &e->xproperty;
|
||||
|
||||
if (colormodechanged) {
|
||||
setcolormode();
|
||||
colormodechanged = 0;
|
||||
}
|
||||
if ((ev->window == root) && (ev->atom == XA_WM_NAME))
|
||||
updatestatus();
|
||||
else if (ev->state == PropertyDelete)
|
||||
@@ -1417,17 +1257,6 @@ propertynotify(XEvent *e)
|
||||
void
|
||||
quit(const Arg *arg)
|
||||
{
|
||||
if(arg->i) restart = 1;
|
||||
// fix: reloading dwm keeps all the hidden clients hidden
|
||||
Monitor *m;
|
||||
Client *c;
|
||||
for (m = mons; m; m = m->next) {
|
||||
if (m) {
|
||||
for (c = m->stack; c; c = c->next)
|
||||
if (c && HIDDEN(c)) showwin(c);
|
||||
}
|
||||
}
|
||||
|
||||
running = 0;
|
||||
}
|
||||
|
||||
@@ -1456,36 +1285,12 @@ void
|
||||
resizeclient(Client *c, int x, int y, int w, int h)
|
||||
{
|
||||
XWindowChanges wc;
|
||||
unsigned int n;
|
||||
unsigned int gapoffset;
|
||||
unsigned int gapincr;
|
||||
Client *nbc;
|
||||
|
||||
c->oldx = c->x; c->x = wc.x = x;
|
||||
c->oldy = c->y; c->y = wc.y = y;
|
||||
c->oldw = c->w; c->w = wc.width = w;
|
||||
c->oldh = c->h; c->h = wc.height = h;
|
||||
wc.border_width = c->bw;
|
||||
|
||||
/* Get number of clients for the selected monitor */
|
||||
for (n = 0, nbc = nexttiled(selmon->clients); nbc; nbc = nexttiled(nbc->next), n++);
|
||||
|
||||
/* Do nothing if layout is floating */
|
||||
if (c->isfloating || selmon->lt[selmon->sellt]->arrange == NULL) {
|
||||
gapincr = gapoffset = 0;
|
||||
} else {
|
||||
/* Remove border and gap if layout is monocle or only one client */
|
||||
if (selmon->lt[selmon->sellt]->arrange == monocle || n == 1) {
|
||||
gapoffset = 0;
|
||||
gapincr = -2 * borderpx;
|
||||
wc.border_width = 0;
|
||||
} else {
|
||||
gapoffset = gappx;
|
||||
gapincr = 2 * gappx;
|
||||
}
|
||||
}
|
||||
|
||||
c->oldx = c->x; c->x = wc.x = x + gapoffset;
|
||||
c->oldy = c->y; c->y = wc.y = y + gapoffset;
|
||||
c->oldw = c->w; c->w = wc.width = w - gapincr;
|
||||
c->oldh = c->h; c->h = wc.height = h - gapincr;
|
||||
|
||||
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
||||
configure(c);
|
||||
XSync(dpy, False);
|
||||
@@ -1520,7 +1325,7 @@ resizemouse(const Arg *arg)
|
||||
handler[ev.type](&ev);
|
||||
break;
|
||||
case MotionNotify:
|
||||
if ((ev.xmotion.time - lasttime) <= (1000 / 60))
|
||||
if ((ev.xmotion.time - lasttime) <= (1000 / refreshrate))
|
||||
continue;
|
||||
lasttime = ev.xmotion.time;
|
||||
|
||||
@@ -1569,8 +1374,6 @@ restack(Monitor *m)
|
||||
wc.sibling = c->win;
|
||||
}
|
||||
}
|
||||
if (m == selmon && (m->tagset[m->seltags] & m->sel->tags) && m->lt[m->sellt]->arrange != &monocle)
|
||||
warp(m->sel);
|
||||
XSync(dpy, False);
|
||||
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
@@ -1625,7 +1428,6 @@ sendmon(Client *c, Monitor *m)
|
||||
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
|
||||
attach(c);
|
||||
attachstack(c);
|
||||
setclienttagprop(c);
|
||||
focus(NULL);
|
||||
arrange(NULL);
|
||||
}
|
||||
@@ -1639,32 +1441,6 @@ setclientstate(Client *c, long state)
|
||||
PropModeReplace, (unsigned char *)data, 2);
|
||||
}
|
||||
|
||||
void
|
||||
setcolormode(void)
|
||||
{
|
||||
static const char *file = ".lightmode";
|
||||
static char *path = NULL;
|
||||
const char *home;
|
||||
size_t size;
|
||||
|
||||
if (!path && (home = getenv("HOME"))) {
|
||||
size = strlen(home) + 1 + strlen(file) + 1;
|
||||
path = malloc(size);
|
||||
if (!path)
|
||||
die("dwm: malloc failed");
|
||||
|
||||
snprintf(path, size, "%s/%s", home, file);
|
||||
}
|
||||
|
||||
if (access(path, F_OK) == 0) {
|
||||
scheme = schemelight;
|
||||
dmenucmd = dmenulight;
|
||||
} else {
|
||||
scheme = schemedark;
|
||||
dmenucmd = dmenudark;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
sendevent(Client *c, Atom proto)
|
||||
{
|
||||
@@ -1773,17 +1549,9 @@ setup(void)
|
||||
sa.sa_handler = SIG_IGN;
|
||||
sigaction(SIGCHLD, &sa, NULL);
|
||||
|
||||
/* set color mode on SIGUSR1 */
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_handler = colormodehandler;
|
||||
sigaction(SIGUSR1, &sa, NULL);
|
||||
|
||||
/* clean up any zombies (inherited from .xinitrc etc) immediately */
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0);
|
||||
|
||||
signal(SIGHUP, sighup);
|
||||
signal(SIGTERM, sigterm);
|
||||
|
||||
/* init screen */
|
||||
screen = DefaultScreen(dpy);
|
||||
sw = DisplayWidth(dpy, screen);
|
||||
@@ -1810,19 +1578,14 @@ setup(void)
|
||||
netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
|
||||
netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
|
||||
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
|
||||
netatom[NetClientInfo] = XInternAtom(dpy, "_NET_CLIENT_INFO", False);
|
||||
/* init cursors */
|
||||
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
|
||||
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
||||
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
||||
/* init appearance */
|
||||
schemedark = ecalloc(LENGTH(colorsdark), sizeof(Clr *));
|
||||
schemelight = ecalloc(LENGTH(colorslight), sizeof(Clr *));
|
||||
for (i = 0; i < LENGTH(colorsdark); i++) {
|
||||
schemedark[i] = drw_scm_create(drw, colorsdark[i], 3);
|
||||
schemelight[i] = drw_scm_create(drw, colorslight[i], 3);
|
||||
}
|
||||
setcolormode();
|
||||
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();
|
||||
@@ -1838,7 +1601,6 @@ setup(void)
|
||||
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char *) netatom, NetLast);
|
||||
XDeleteProperty(dpy, root, netatom[NetClientList]);
|
||||
XDeleteProperty(dpy, root, netatom[NetClientInfo]);
|
||||
/* select events */
|
||||
wa.cursor = cursor[CurNormal]->cursor;
|
||||
wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask
|
||||
@@ -1863,42 +1625,6 @@ seturgent(Client *c, int urg)
|
||||
XFree(wmh);
|
||||
}
|
||||
|
||||
void
|
||||
show(const Arg *arg)
|
||||
{
|
||||
if (selmon->hidsel)
|
||||
selmon->hidsel = 0;
|
||||
showwin(selmon->sel);
|
||||
}
|
||||
|
||||
void
|
||||
showall(const Arg *arg)
|
||||
{
|
||||
Client *c = NULL;
|
||||
selmon->hidsel = 0;
|
||||
for (c = selmon->clients; c; c = c->next) {
|
||||
if (ISVISIBLE(c))
|
||||
showwin(c);
|
||||
}
|
||||
if (!selmon->sel) {
|
||||
for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
|
||||
if (c)
|
||||
focus(c);
|
||||
}
|
||||
restack(selmon);
|
||||
}
|
||||
|
||||
void
|
||||
showwin(Client *c)
|
||||
{
|
||||
if (!c || !HIDDEN(c))
|
||||
return;
|
||||
|
||||
XMapWindow(dpy, c->win);
|
||||
setclientstate(c, NormalState);
|
||||
arrange(c->mon);
|
||||
}
|
||||
|
||||
void
|
||||
showhide(Client *c)
|
||||
{
|
||||
@@ -1917,33 +1643,13 @@ showhide(Client *c)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sigchld(int unused)
|
||||
{
|
||||
if (signal(SIGCHLD, sigchld) == SIG_ERR)
|
||||
die("can't install SIGCHLD handler:");
|
||||
while (0 < waitpid(-1, NULL, WNOHANG));
|
||||
}
|
||||
|
||||
void
|
||||
sighup(int unused)
|
||||
{
|
||||
Arg a = {.i = 1};
|
||||
quit(&a);
|
||||
}
|
||||
|
||||
void
|
||||
sigterm(int unused)
|
||||
{
|
||||
Arg a = {.i = 0};
|
||||
quit(&a);
|
||||
}
|
||||
|
||||
void
|
||||
spawn(const Arg *arg)
|
||||
{
|
||||
struct sigaction sa;
|
||||
|
||||
if (arg->v == dmenucmd)
|
||||
dmenumon[0] = '0' + selmon->num;
|
||||
if (fork() == 0) {
|
||||
if (dpy)
|
||||
close(ConnectionNumber(dpy));
|
||||
@@ -1959,29 +1665,11 @@ spawn(const Arg *arg)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
setclienttagprop(Client *c)
|
||||
{
|
||||
long data[] = { (long) c->tags, (long) c->mon->num };
|
||||
XChangeProperty(dpy, c->win, netatom[NetClientInfo], XA_CARDINAL, 32,
|
||||
PropModeReplace, (unsigned char *) data, 2);
|
||||
}
|
||||
|
||||
void
|
||||
spawndmenu(const Arg *arg)
|
||||
{
|
||||
dmenumon[0] = '0' + selmon->num;
|
||||
spawn(&(const Arg){.v = dmenucmd});
|
||||
}
|
||||
|
||||
void
|
||||
tag(const Arg *arg)
|
||||
{
|
||||
Client *c;
|
||||
if (selmon->sel && arg->ui & TAGMASK) {
|
||||
c = selmon->sel;
|
||||
selmon->sel->tags = arg->ui & TAGMASK;
|
||||
setclienttagprop(c);
|
||||
focus(NULL);
|
||||
arrange(selmon);
|
||||
}
|
||||
@@ -2046,19 +1734,6 @@ togglefloating(const Arg *arg)
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
void
|
||||
focusbynum(const Arg *arg)
|
||||
{
|
||||
int i;
|
||||
Client *c;
|
||||
|
||||
i = 0;
|
||||
c = nexttiled(selmon->clients);
|
||||
|
||||
for (; c && i < arg->i; c = nexttiled(c->next), i++);
|
||||
focus(c);
|
||||
}
|
||||
|
||||
void
|
||||
toggletag(const Arg *arg)
|
||||
{
|
||||
@@ -2069,7 +1744,6 @@ toggletag(const Arg *arg)
|
||||
newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
|
||||
if (newtags) {
|
||||
selmon->sel->tags = newtags;
|
||||
setclienttagprop(selmon->sel);
|
||||
focus(NULL);
|
||||
arrange(selmon);
|
||||
}
|
||||
@@ -2087,23 +1761,6 @@ toggleview(const Arg *arg)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
togglewin(const Arg *arg)
|
||||
{
|
||||
Client *c = (Client*)arg->v;
|
||||
|
||||
if (c == selmon->sel) {
|
||||
hidewin(c);
|
||||
focus(NULL);
|
||||
arrange(c->mon);
|
||||
} else {
|
||||
if (HIDDEN(c))
|
||||
showwin(c);
|
||||
focus(c);
|
||||
restack(selmon);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
unfocus(Client *c, int setfocus)
|
||||
{
|
||||
@@ -2206,16 +1863,6 @@ updateclientlist(void)
|
||||
(unsigned char *) &(c->win), 1);
|
||||
}
|
||||
|
||||
#ifdef XINERAMA
|
||||
// Custom comparator: sort monitors by x_org to match physical layout left-to-right
|
||||
static int
|
||||
compare_xinerama_x(const void *a, const void *b) {
|
||||
const XineramaScreenInfo *sa = (const XineramaScreenInfo *)a;
|
||||
const XineramaScreenInfo *sb = (const XineramaScreenInfo *)b;
|
||||
return sa->x_org - sb->x_org;
|
||||
}
|
||||
#endif /* XINERAMA */
|
||||
|
||||
int
|
||||
updategeom(void)
|
||||
{
|
||||
@@ -2232,8 +1879,6 @@ updategeom(void)
|
||||
for (n = 0, m = mons; m; m = m->next, n++);
|
||||
/* only consider unique geometries as separate screens */
|
||||
unique = ecalloc(nn, sizeof(XineramaScreenInfo));
|
||||
// Sort monitors by x_org so dwm handles screens in left-to-right order
|
||||
qsort(info, nn, sizeof(XineramaScreenInfo), compare_xinerama_x);
|
||||
for (i = 0, j = 0; i < nn; i++)
|
||||
if (isuniquegeom(unique, j, &info[i]))
|
||||
memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));
|
||||
@@ -2416,28 +2061,6 @@ view(const Arg *arg)
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
void
|
||||
warp(const Client *c)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
if (!c) {
|
||||
XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + selmon->ww / 2, selmon->wy + selmon->wh / 2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getrootptr(&x, &y) ||
|
||||
(x > c->x - c->bw &&
|
||||
y > c->y - c->bw &&
|
||||
x < c->x + c->w + c->bw*2 &&
|
||||
y < c->y + c->h + c->bw*2) ||
|
||||
(y > c->mon->by && y < c->mon->by + bh) ||
|
||||
(c->mon->topbar && !y))
|
||||
return;
|
||||
|
||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
|
||||
}
|
||||
|
||||
Client *
|
||||
wintoclient(Window w)
|
||||
{
|
||||
@@ -2535,7 +2158,6 @@ main(int argc, char *argv[])
|
||||
#endif /* __OpenBSD__ */
|
||||
scan();
|
||||
run();
|
||||
if(restart) execvp(argv[0], argv);
|
||||
cleanup();
|
||||
XCloseDisplay(dpy);
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
87
exitdwm.c
87
exitdwm.c
@@ -1,87 +0,0 @@
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
|
||||
void exitdwm ()
|
||||
{
|
||||
# if \
|
||||
defined S_LOCK || \
|
||||
defined S_RESTART_DWM || \
|
||||
defined S_OFFSCREEN || \
|
||||
defined S_EXIT || \
|
||||
defined S_REBOOT || \
|
||||
defined S_SHUTDOWN || \
|
||||
defined S_LOCK_ICON || \
|
||||
defined S_RESTART_DWM_ICON || \
|
||||
defined S_OFFSCREEN_ICON || \
|
||||
defined S_EXIT_ICON || \
|
||||
defined S_REBOOT_ICON || \
|
||||
defined S_SHUTDOWN_ICON || \
|
||||
defined S_FORMAT || \
|
||||
defined S_FORMAT_CLEAR
|
||||
# error (conflicting macro names)
|
||||
# endif
|
||||
|
||||
# define S_LOCK "Lock"
|
||||
# define S_RESTART_DWM "restart Dwm"
|
||||
# define S_OFFSCREEN "Off-screen"
|
||||
# define S_EXIT "Exit"
|
||||
# define S_REBOOT "Reboot"
|
||||
# define S_SHUTDOWN "Shutdown"
|
||||
# define S_LOCK_ICON "\uf023" // <= FontAwesome icons
|
||||
# define S_RESTART_DWM_ICON "\uf01e"
|
||||
# define S_OFFSCREEN_ICON "\uf108"
|
||||
# define S_EXIT_ICON "\uf2f5"
|
||||
# define S_REBOOT_ICON "\uf021"
|
||||
# define S_SHUTDOWN_ICON "\uf011"
|
||||
|
||||
# define S_FORMAT(ACTION) S_##ACTION##_ICON " " S_##ACTION
|
||||
# define S_FORMAT_CLEAR "sed 's/^..//'"
|
||||
|
||||
FILE * exit_menu = popen (
|
||||
"echo \""
|
||||
S_FORMAT (LOCK) "\n"
|
||||
S_FORMAT (RESTART_DWM) "\n"
|
||||
S_FORMAT (OFFSCREEN) "\n"
|
||||
S_FORMAT (EXIT) "\n"
|
||||
S_FORMAT (REBOOT) "\n"
|
||||
S_FORMAT (SHUTDOWN)
|
||||
"\" | dmenu -p exit: | " S_FORMAT_CLEAR
|
||||
,
|
||||
"r"
|
||||
);
|
||||
|
||||
char exit_action [16];
|
||||
|
||||
if (
|
||||
exit_menu == NULL ||
|
||||
fscanf (exit_menu, "%15[a-zA-Z -]", exit_action) == EOF
|
||||
) {
|
||||
fputs ("Error. Failure in exit_dwm.", stderr);
|
||||
goto close_streams;
|
||||
}
|
||||
|
||||
if (strcmp (exit_action, S_LOCK) == 0) system ("slock & sleep .5; xset dpms force off");
|
||||
else if (strcmp (exit_action, S_RESTART_DWM) == 0) quit (& (const Arg) {1});
|
||||
else if (strcmp (exit_action, S_OFFSCREEN) == 0) system ("sleep .5; xset dpms force off");
|
||||
else if (strcmp (exit_action, S_EXIT) == 0) quit (& (const Arg) {0});
|
||||
else if (strcmp (exit_action, S_REBOOT) == 0) system ("systemctl reboot");
|
||||
else if (strcmp (exit_action, S_SHUTDOWN) == 0) system ("systemctl poweroff -i");
|
||||
|
||||
close_streams:
|
||||
pclose (exit_menu);
|
||||
|
||||
# undef S_LOCK
|
||||
# undef S_RESTART_DWM
|
||||
# undef S_OFFSCREEN
|
||||
# undef S_EXIT
|
||||
# undef S_REBOOT
|
||||
# undef S_SHUTDOWN
|
||||
# undef S_LOCK_ICON
|
||||
# undef S_RESTART_DWM_ICON
|
||||
# undef S_OFFSCREEN_ICON
|
||||
# undef S_EXIT_ICON
|
||||
# undef S_REBOOT_ICON
|
||||
# undef S_SHUTDOWN_ICON
|
||||
# undef S_FORMAT
|
||||
# undef S_FORMAT_CLEAR
|
||||
}
|
||||
Reference in New Issue
Block a user