Compare commits
2 Commits
b6a7b4a70e
...
52750297f1
Author | SHA1 | Date | |
---|---|---|---|
52750297f1 | |||
dd5f7b8836 |
17
config.def.h
17
config.def.h
@ -19,6 +19,8 @@ static const char *colors[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||
[SchemeHov] = { col_gray4, col_cyan, col_cyan },
|
||||
[SchemeHid] = { col_cyan, col_gray1, col_cyan },
|
||||
};
|
||||
|
||||
/* tagging */
|
||||
@ -80,6 +82,20 @@ static const Key keys[] = {
|
||||
// 关闭 DWM
|
||||
{ MODKEY|ShiftMask, XK_c, quit, {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_s, show, {0} },
|
||||
{ MODKEY|ShiftMask, XK_s, showall, {0} },
|
||||
{ MODKEY, XK_h, hide, {0} },
|
||||
|
||||
// { MODKEY|ControlMask, XK_j, rotatestack, {.i = +1 } },
|
||||
// { MODKEY|ControlMask, XK_k, rotatestack, {.i = -1 } },
|
||||
|
||||
// 全屏
|
||||
{ MODKEY|ShiftMask, XK_f, fullscreen, {0} },
|
||||
|
||||
TAGKEYS( XK_1, 0)
|
||||
TAGKEYS( XK_2, 1)
|
||||
TAGKEYS( XK_3, 2)
|
||||
@ -97,6 +113,7 @@ 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} },
|
||||
|
318
dwm.c
318
dwm.c
@ -51,6 +51,7 @@
|
||||
#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)
|
||||
@ -60,7 +61,7 @@
|
||||
|
||||
/* enums */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
enum { SchemeNorm, SchemeSel }; /* color schemes */
|
||||
enum { SchemeNorm, SchemeSel, SchemeHov, SchemeHid }; /* color schemes */
|
||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
||||
@ -118,6 +119,8 @@ 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;
|
||||
@ -125,8 +128,10 @@ struct Monitor {
|
||||
unsigned int tagset[2];
|
||||
int showbar;
|
||||
int topbar;
|
||||
int hidsel;
|
||||
Client *clients;
|
||||
Client *sel;
|
||||
Client *hov;
|
||||
Client *stack;
|
||||
Monitor *next;
|
||||
Window barwin;
|
||||
@ -169,13 +174,17 @@ static void expose(XEvent *e);
|
||||
static void focus(Client *c);
|
||||
static void focusin(XEvent *e);
|
||||
static void focusmon(const Arg *arg);
|
||||
static void focusstack(const Arg *arg);
|
||||
static void focusstackvis(const Arg *arg);
|
||||
static void focusstackhid(const Arg *arg);
|
||||
static void focusstack(int inc, int vis);
|
||||
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);
|
||||
@ -202,10 +211,14 @@ static void sendmon(Client *c, Monitor *m);
|
||||
static void setclientstate(Client *c, long state);
|
||||
static void setfocus(Client *c);
|
||||
static void setfullscreen(Client *c, int fullscreen);
|
||||
static void fullscreen(const Arg *arg);
|
||||
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 spawn(const Arg *arg);
|
||||
static void tag(const Arg *arg);
|
||||
@ -215,6 +228,7 @@ static void togglebar(const Arg *arg);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
static void toggleview(const Arg *arg);
|
||||
static void togglewin(const Arg *arg);
|
||||
static void unfocus(Client *c, int setfocus);
|
||||
static void unmanage(Client *c, int destroyed);
|
||||
static void unmapnotify(XEvent *e);
|
||||
@ -447,10 +461,25 @@ buttonpress(XEvent *e)
|
||||
arg.ui = 1 << i;
|
||||
} else if (ev->x < x + TEXTW(selmon->ltsymbol))
|
||||
click = ClkLtSymbol;
|
||||
else if (ev->x > selmon->ww - (int)TEXTW(stext))
|
||||
/* 2px right padding */
|
||||
else if (ev->x > selmon->ww - TEXTW(stext) + lrpad - 2)
|
||||
click = ClkStatusText;
|
||||
else
|
||||
click = ClkWinTitle;
|
||||
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);
|
||||
@ -460,7 +489,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 && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
|
||||
buttons[i].func((click == ClkTagBar || click == ClkWinTitle) && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
|
||||
}
|
||||
|
||||
void
|
||||
@ -704,7 +733,7 @@ dirtomon(int dir)
|
||||
void
|
||||
drawbar(Monitor *m)
|
||||
{
|
||||
int x, w, tw = 0;
|
||||
int x, w, tw = 0, n = 0, scm;
|
||||
int boxs = drw->fonts->h / 9;
|
||||
int boxw = drw->fonts->h / 6 + 2;
|
||||
unsigned int i, occ = 0, urg = 0;
|
||||
@ -721,6 +750,8 @@ drawbar(Monitor *m)
|
||||
}
|
||||
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (ISVISIBLE(c))
|
||||
n++;
|
||||
occ |= c->tags;
|
||||
if (c->isurgent)
|
||||
urg |= c->tags;
|
||||
@ -741,16 +772,38 @@ drawbar(Monitor *m)
|
||||
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
||||
|
||||
if ((w = m->ww - tw - x) > bh) {
|
||||
if (m->sel) {
|
||||
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
|
||||
if (m->sel->isfloating)
|
||||
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
|
||||
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->hov == c)
|
||||
scm = SchemeHov;
|
||||
else 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;
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
|
||||
@ -796,9 +849,17 @@ void
|
||||
focus(Client *c)
|
||||
{
|
||||
if (!c || !ISVISIBLE(c))
|
||||
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
|
||||
if (selmon->sel && selmon->sel != c)
|
||||
for (c = selmon->stack; c && (!ISVISIBLE(c) || HIDDEN(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;
|
||||
@ -842,28 +903,52 @@ focusmon(const Arg *arg)
|
||||
}
|
||||
|
||||
void
|
||||
focusstack(const Arg *arg)
|
||||
focusstackvis(const Arg *arg) {
|
||||
focusstack(arg->i, 0);
|
||||
}
|
||||
|
||||
void
|
||||
focusstackhid(const Arg *arg) {
|
||||
focusstack(arg->i, 1);
|
||||
}
|
||||
|
||||
void
|
||||
focusstack(int inc, int hid)
|
||||
{
|
||||
Client *c = NULL, *i;
|
||||
|
||||
if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
|
||||
// if no client selected AND exclude hidden client; if client selected but fullscreened
|
||||
if ((!selmon->sel && !hid) || (selmon->sel && selmon->sel->isfullscreen && lockfullscreen))
|
||||
return;
|
||||
if (arg->i > 0) {
|
||||
for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
|
||||
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 (!c)
|
||||
for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
|
||||
for (c = selmon->clients;
|
||||
c && (!ISVISIBLE(c) || (!hid && HIDDEN(c)));
|
||||
c = c->next);
|
||||
} else {
|
||||
for (i = selmon->clients; i != selmon->sel; i = i->next)
|
||||
if (ISVISIBLE(i))
|
||||
c = i;
|
||||
if (selmon->sel) {
|
||||
for (i = selmon->clients; i != selmon->sel; i = i->next)
|
||||
if (ISVISIBLE(i) && !(!hid && HIDDEN(i)))
|
||||
c = i;
|
||||
} else
|
||||
c = selmon->clients;
|
||||
if (!c)
|
||||
for (; i; i = i->next)
|
||||
if (ISVISIBLE(i))
|
||||
if (ISVISIBLE(i) && !(!hid && HIDDEN(i)))
|
||||
c = i;
|
||||
}
|
||||
if (c) {
|
||||
focus(c);
|
||||
restack(selmon);
|
||||
if (HIDDEN(c)) {
|
||||
showwin(c);
|
||||
c->mon->hidsel = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -983,6 +1068,36 @@ 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)
|
||||
{
|
||||
@ -1085,12 +1200,14 @@ 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 */
|
||||
setclientstate(c, NormalState);
|
||||
if (!HIDDEN(c))
|
||||
setclientstate(c, NormalState);
|
||||
if (c->mon == selmon)
|
||||
unfocus(selmon->sel, 0);
|
||||
c->mon->sel = c;
|
||||
arrange(c->mon);
|
||||
XMapWindow(dpy, c->win);
|
||||
if (!HIDDEN(c))
|
||||
XMapWindow(dpy, c->win);
|
||||
focus(NULL);
|
||||
}
|
||||
|
||||
@ -1134,18 +1251,76 @@ monocle(Monitor *m)
|
||||
void
|
||||
motionnotify(XEvent *e)
|
||||
{
|
||||
int x, i;
|
||||
static Monitor *mon = NULL;
|
||||
Client *c;
|
||||
Monitor *m;
|
||||
XMotionEvent *ev = &e->xmotion;
|
||||
|
||||
if (ev->window != root)
|
||||
if (ev->window != selmon->barwin) {
|
||||
if (selmon->hov) {
|
||||
if (selmon->hov != selmon->sel)
|
||||
XSetWindowBorder(dpy, selmon->hov->win, scheme[SchemeNorm][ColBorder].pixel);
|
||||
else
|
||||
XSetWindowBorder(dpy, selmon->hov->win, scheme[SchemeSel][ColBorder].pixel);
|
||||
|
||||
selmon->hov = NULL;
|
||||
c = wintoclient(ev->window);
|
||||
m = c ? c->mon : wintomon(ev->window);
|
||||
drawbar(m);
|
||||
}
|
||||
|
||||
if (ev->window == root) {
|
||||
if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
|
||||
unfocus(selmon->sel, 1);
|
||||
selmon = m;
|
||||
focus(NULL);
|
||||
}
|
||||
mon = m;
|
||||
}
|
||||
|
||||
return;
|
||||
if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
|
||||
unfocus(selmon->sel, 1);
|
||||
selmon = m;
|
||||
focus(NULL);
|
||||
}
|
||||
mon = m;
|
||||
|
||||
c = wintoclient(ev->window);
|
||||
m = c ? c->mon : wintomon(ev->window);
|
||||
c = m->clients;
|
||||
|
||||
x = 0, i = 0;
|
||||
do
|
||||
x += TEXTW(tags[i]);
|
||||
while (ev->x >= x && ++i < LENGTH(tags));
|
||||
if (i < LENGTH(tags) || ev->x < x + TEXTW(selmon->ltsymbol) || ev->x > selmon->ww - TEXTW(stext) + lrpad - 2) {
|
||||
if (selmon->hov) {
|
||||
if (selmon->hov != selmon->sel)
|
||||
XSetWindowBorder(dpy, selmon->hov->win, scheme[SchemeNorm][ColBorder].pixel);
|
||||
else
|
||||
XSetWindowBorder(dpy, selmon->hov->win, scheme[SchemeSel][ColBorder].pixel);
|
||||
selmon->hov = NULL;
|
||||
drawbar(m);
|
||||
}
|
||||
} else {
|
||||
x += TEXTW(selmon->ltsymbol);
|
||||
if (c) {
|
||||
do {
|
||||
if (!ISVISIBLE(c))
|
||||
continue;
|
||||
else
|
||||
x +=(1.0 / (double)m->bt) * m->btw;
|
||||
} while (ev->x > x && (c = c->next));
|
||||
if (c) {
|
||||
if (selmon->hov) {
|
||||
if (selmon->hov != selmon->sel)
|
||||
XSetWindowBorder(dpy, selmon->hov->win, scheme[SchemeNorm][ColBorder].pixel);
|
||||
else
|
||||
XSetWindowBorder(dpy, selmon->hov->win, scheme[SchemeSel][ColBorder].pixel);
|
||||
}
|
||||
selmon->hov = c;
|
||||
XSetWindowBorder(dpy, c->win, scheme[SchemeHov][ColBorder].pixel);
|
||||
}
|
||||
}
|
||||
drawbar(m);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -1211,7 +1386,7 @@ movemouse(const Arg *arg)
|
||||
Client *
|
||||
nexttiled(Client *c)
|
||||
{
|
||||
for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
|
||||
for (; c && (c->isfloating || !ISVISIBLE(c) || HIDDEN(c)); c = c->next);
|
||||
return c;
|
||||
}
|
||||
|
||||
@ -1264,6 +1439,16 @@ propertynotify(XEvent *e)
|
||||
void
|
||||
quit(const Arg *arg)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -1590,6 +1775,19 @@ setfullscreen(Client *c, int fullscreen)
|
||||
}
|
||||
}
|
||||
|
||||
Layout *last_layout;
|
||||
void
|
||||
fullscreen(const Arg *arg)
|
||||
{
|
||||
if (selmon->showbar) {
|
||||
for(last_layout = (Layout *)layouts; last_layout != selmon->lt[selmon->sellt]; last_layout++);
|
||||
setlayout(&((Arg) { .v = &layouts[2] }));
|
||||
} else {
|
||||
setlayout(&((Arg) { .v = last_layout }));
|
||||
}
|
||||
togglebar(arg);
|
||||
}
|
||||
|
||||
void
|
||||
setlayout(const Arg *arg)
|
||||
{
|
||||
@ -1709,6 +1907,42 @@ 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)
|
||||
{
|
||||
@ -1845,6 +2079,23 @@ 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)
|
||||
{
|
||||
@ -1916,6 +2167,7 @@ updatebars(void)
|
||||
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
|
||||
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
|
||||
XMapRaised(dpy, m->barwin);
|
||||
XSelectInput(dpy, m->barwin, ButtonPressMask|PointerMotionMask);
|
||||
XSetClassHint(dpy, m->barwin, &ch);
|
||||
}
|
||||
}
|
||||
|
543
patches/dwm-awesomebarwithhover-20230431-6.4.diff
Normal file
543
patches/dwm-awesomebarwithhover-20230431-6.4.diff
Normal file
@ -0,0 +1,543 @@
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 061ad66..82a3ed2 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -16,6 +16,8 @@ static const char *colors[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||
+ [SchemeHov] = { col_gray4, col_cyan, col_cyan },
|
||||
+ [SchemeHid] = { col_cyan, col_gray1, col_cyan },
|
||||
};
|
||||
|
||||
/* tagging */
|
||||
@@ -64,8 +66,10 @@ static const Key keys[] = {
|
||||
{ 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_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_i, incnmaster, {.i = +1 } },
|
||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
@@ -84,6 +88,9 @@ 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)
|
||||
@@ -102,6 +109,7 @@ 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} },
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index e5efb6a..8cb5171 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -50,6 +50,7 @@
|
||||
#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)
|
||||
@@ -59,7 +60,7 @@
|
||||
|
||||
/* enums */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
-enum { SchemeNorm, SchemeSel }; /* color schemes */
|
||||
+enum { SchemeNorm, SchemeSel, SchemeHov, SchemeHid }; /* color schemes */
|
||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
||||
@@ -117,6 +118,8 @@ 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;
|
||||
@@ -124,8 +127,10 @@ struct Monitor {
|
||||
unsigned int tagset[2];
|
||||
int showbar;
|
||||
int topbar;
|
||||
+ int hidsel;
|
||||
Client *clients;
|
||||
Client *sel;
|
||||
+ Client *hov;
|
||||
Client *stack;
|
||||
Monitor *next;
|
||||
Window barwin;
|
||||
@@ -168,13 +173,17 @@ static void expose(XEvent *e);
|
||||
static void focus(Client *c);
|
||||
static void focusin(XEvent *e);
|
||||
static void focusmon(const Arg *arg);
|
||||
-static void focusstack(const Arg *arg);
|
||||
+static void focusstackvis(const Arg *arg);
|
||||
+static void focusstackhid(const Arg *arg);
|
||||
+static void focusstack(int inc, int vis);
|
||||
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);
|
||||
@@ -204,6 +213,9 @@ 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 spawn(const Arg *arg);
|
||||
@@ -214,6 +226,7 @@ static void togglebar(const Arg *arg);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
static void toggleview(const Arg *arg);
|
||||
+static void togglewin(const Arg *arg);
|
||||
static void unfocus(Client *c, int setfocus);
|
||||
static void unmanage(Client *c, int destroyed);
|
||||
static void unmapnotify(XEvent *e);
|
||||
@@ -442,10 +455,25 @@ buttonpress(XEvent *e)
|
||||
arg.ui = 1 << i;
|
||||
} else if (ev->x < x + TEXTW(selmon->ltsymbol))
|
||||
click = ClkLtSymbol;
|
||||
- else if (ev->x > selmon->ww - (int)TEXTW(stext))
|
||||
+ /* 2px right padding */
|
||||
+ else if (ev->x > selmon->ww - TEXTW(stext) + lrpad - 2)
|
||||
click = ClkStatusText;
|
||||
- else
|
||||
- click = ClkWinTitle;
|
||||
+ 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);
|
||||
@@ -455,7 +483,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 && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
|
||||
+ buttons[i].func((click == ClkTagBar || click == ClkWinTitle) && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -699,7 +727,7 @@ dirtomon(int dir)
|
||||
void
|
||||
drawbar(Monitor *m)
|
||||
{
|
||||
- int x, w, tw = 0;
|
||||
+ int x, w, tw = 0, n = 0, scm;
|
||||
int boxs = drw->fonts->h / 9;
|
||||
int boxw = drw->fonts->h / 6 + 2;
|
||||
unsigned int i, occ = 0, urg = 0;
|
||||
@@ -716,6 +744,8 @@ drawbar(Monitor *m)
|
||||
}
|
||||
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
+ if (ISVISIBLE(c))
|
||||
+ n++;
|
||||
occ |= c->tags;
|
||||
if (c->isurgent)
|
||||
urg |= c->tags;
|
||||
@@ -736,16 +766,38 @@ drawbar(Monitor *m)
|
||||
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
||||
|
||||
if ((w = m->ww - tw - x) > bh) {
|
||||
- if (m->sel) {
|
||||
- drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
|
||||
- drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
|
||||
- if (m->sel->isfloating)
|
||||
- drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
|
||||
+ 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->hov == c)
|
||||
+ scm = SchemeHov;
|
||||
+ else 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;
|
||||
+ }
|
||||
} 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);
|
||||
}
|
||||
|
||||
@@ -791,9 +843,17 @@ void
|
||||
focus(Client *c)
|
||||
{
|
||||
if (!c || !ISVISIBLE(c))
|
||||
- for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
|
||||
- if (selmon->sel && selmon->sel != c)
|
||||
+ for (c = selmon->stack; c && (!ISVISIBLE(c) || HIDDEN(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;
|
||||
@@ -837,28 +897,52 @@ focusmon(const Arg *arg)
|
||||
}
|
||||
|
||||
void
|
||||
-focusstack(const Arg *arg)
|
||||
+focusstackvis(const Arg *arg) {
|
||||
+ focusstack(arg->i, 0);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+focusstackhid(const Arg *arg) {
|
||||
+ focusstack(arg->i, 1);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+focusstack(int inc, int hid)
|
||||
{
|
||||
Client *c = NULL, *i;
|
||||
-
|
||||
- if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
|
||||
+ // if no client selected AND exclude hidden client; if client selected but fullscreened
|
||||
+ if ((!selmon->sel && !hid) || (selmon->sel && selmon->sel->isfullscreen && lockfullscreen))
|
||||
+ return;
|
||||
+ if (!selmon->clients)
|
||||
return;
|
||||
- if (arg->i > 0) {
|
||||
- for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
|
||||
+ if (inc > 0) {
|
||||
+ if (selmon->sel)
|
||||
+ for (c = selmon->sel->next;
|
||||
+ c && (!ISVISIBLE(c) || (!hid && HIDDEN(c)));
|
||||
+ c = c->next);
|
||||
if (!c)
|
||||
- for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
|
||||
+ for (c = selmon->clients;
|
||||
+ c && (!ISVISIBLE(c) || (!hid && HIDDEN(c)));
|
||||
+ c = c->next);
|
||||
} else {
|
||||
- for (i = selmon->clients; i != selmon->sel; i = i->next)
|
||||
- if (ISVISIBLE(i))
|
||||
- c = i;
|
||||
+ if (selmon->sel) {
|
||||
+ for (i = selmon->clients; i != selmon->sel; i = i->next)
|
||||
+ if (ISVISIBLE(i) && !(!hid && HIDDEN(i)))
|
||||
+ c = i;
|
||||
+ } else
|
||||
+ c = selmon->clients;
|
||||
if (!c)
|
||||
for (; i; i = i->next)
|
||||
- if (ISVISIBLE(i))
|
||||
+ if (ISVISIBLE(i) && !(!hid && HIDDEN(i)))
|
||||
c = i;
|
||||
}
|
||||
if (c) {
|
||||
focus(c);
|
||||
restack(selmon);
|
||||
+ if (HIDDEN(c)) {
|
||||
+ showwin(c);
|
||||
+ c->mon->hidsel = 1;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -968,6 +1052,36 @@ 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)
|
||||
{
|
||||
@@ -1070,12 +1184,14 @@ 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 */
|
||||
- setclientstate(c, NormalState);
|
||||
+ if (!HIDDEN(c))
|
||||
+ setclientstate(c, NormalState);
|
||||
if (c->mon == selmon)
|
||||
unfocus(selmon->sel, 0);
|
||||
c->mon->sel = c;
|
||||
arrange(c->mon);
|
||||
- XMapWindow(dpy, c->win);
|
||||
+ if (!HIDDEN(c))
|
||||
+ XMapWindow(dpy, c->win);
|
||||
focus(NULL);
|
||||
}
|
||||
|
||||
@@ -1119,18 +1235,76 @@ monocle(Monitor *m)
|
||||
void
|
||||
motionnotify(XEvent *e)
|
||||
{
|
||||
+ int x, i;
|
||||
static Monitor *mon = NULL;
|
||||
+ Client *c;
|
||||
Monitor *m;
|
||||
XMotionEvent *ev = &e->xmotion;
|
||||
|
||||
- if (ev->window != root)
|
||||
+ if (ev->window != selmon->barwin) {
|
||||
+ if (selmon->hov) {
|
||||
+ if (selmon->hov != selmon->sel)
|
||||
+ XSetWindowBorder(dpy, selmon->hov->win, scheme[SchemeNorm][ColBorder].pixel);
|
||||
+ else
|
||||
+ XSetWindowBorder(dpy, selmon->hov->win, scheme[SchemeSel][ColBorder].pixel);
|
||||
+
|
||||
+ selmon->hov = NULL;
|
||||
+ c = wintoclient(ev->window);
|
||||
+ m = c ? c->mon : wintomon(ev->window);
|
||||
+ drawbar(m);
|
||||
+ }
|
||||
+
|
||||
+ if (ev->window == root) {
|
||||
+ if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
|
||||
+ unfocus(selmon->sel, 1);
|
||||
+ selmon = m;
|
||||
+ focus(NULL);
|
||||
+ }
|
||||
+ mon = m;
|
||||
+ }
|
||||
+
|
||||
return;
|
||||
- if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
|
||||
- unfocus(selmon->sel, 1);
|
||||
- selmon = m;
|
||||
- focus(NULL);
|
||||
}
|
||||
- mon = m;
|
||||
+
|
||||
+ c = wintoclient(ev->window);
|
||||
+ m = c ? c->mon : wintomon(ev->window);
|
||||
+ c = m->clients;
|
||||
+
|
||||
+ x = 0, i = 0;
|
||||
+ do
|
||||
+ x += TEXTW(tags[i]);
|
||||
+ while (ev->x >= x && ++i < LENGTH(tags));
|
||||
+ if (i < LENGTH(tags) || ev->x < x + TEXTW(selmon->ltsymbol) || ev->x > selmon->ww - TEXTW(stext) + lrpad - 2) {
|
||||
+ if (selmon->hov) {
|
||||
+ if (selmon->hov != selmon->sel)
|
||||
+ XSetWindowBorder(dpy, selmon->hov->win, scheme[SchemeNorm][ColBorder].pixel);
|
||||
+ else
|
||||
+ XSetWindowBorder(dpy, selmon->hov->win, scheme[SchemeSel][ColBorder].pixel);
|
||||
+ selmon->hov = NULL;
|
||||
+ drawbar(m);
|
||||
+ }
|
||||
+ } else {
|
||||
+ x += TEXTW(selmon->ltsymbol);
|
||||
+ if (c) {
|
||||
+ do {
|
||||
+ if (!ISVISIBLE(c))
|
||||
+ continue;
|
||||
+ else
|
||||
+ x +=(1.0 / (double)m->bt) * m->btw;
|
||||
+ } while (ev->x > x && (c = c->next));
|
||||
+ if (c) {
|
||||
+ if (selmon->hov) {
|
||||
+ if (selmon->hov != selmon->sel)
|
||||
+ XSetWindowBorder(dpy, selmon->hov->win, scheme[SchemeNorm][ColBorder].pixel);
|
||||
+ else
|
||||
+ XSetWindowBorder(dpy, selmon->hov->win, scheme[SchemeSel][ColBorder].pixel);
|
||||
+ }
|
||||
+ selmon->hov = c;
|
||||
+ XSetWindowBorder(dpy, c->win, scheme[SchemeHov][ColBorder].pixel);
|
||||
+ }
|
||||
+ }
|
||||
+ drawbar(m);
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1196,7 +1370,7 @@ movemouse(const Arg *arg)
|
||||
Client *
|
||||
nexttiled(Client *c)
|
||||
{
|
||||
- for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
|
||||
+ for (; c && (c->isfloating || !ISVISIBLE(c) || HIDDEN(c)); c = c->next);
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -1249,6 +1423,16 @@ propertynotify(XEvent *e)
|
||||
void
|
||||
quit(const Arg *arg)
|
||||
{
|
||||
+ // 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;
|
||||
}
|
||||
|
||||
@@ -1610,6 +1794,42 @@ 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)
|
||||
{
|
||||
@@ -1744,6 +1964,23 @@ 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)
|
||||
{
|
||||
@@ -1815,6 +2052,7 @@ updatebars(void)
|
||||
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
|
||||
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
|
||||
XMapRaised(dpy, m->barwin);
|
||||
+ XSelectInput(dpy, m->barwin, ButtonPressMask|PointerMotionMask);
|
||||
XSetClassHint(dpy, m->barwin, &ch);
|
||||
}
|
||||
}
|
56
patches/dwm-fullscreen-6.2.diff
Normal file
56
patches/dwm-fullscreen-6.2.diff
Normal file
@ -0,0 +1,56 @@
|
||||
From 54719285bd1a984e2efce6e8a8eab184fec11abf Mon Sep 17 00:00:00 2001
|
||||
From: Sermak <sermak@jarvis.com>
|
||||
Date: Mon, 8 Jul 2019 01:06:44 +0200
|
||||
Subject: [PATCH] Simulate toggleable fullscreen mode
|
||||
|
||||
---
|
||||
config.def.h | 1 +
|
||||
dwm.c | 14 ++++++++++++++
|
||||
2 files changed, 15 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1c0b587..f774cc5 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -76,6 +76,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|ShiftMask, XK_f, fullscreen, {0} },
|
||||
{ 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 4465af1..04b1e06 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -199,6 +199,7 @@ static void sendmon(Client *c, Monitor *m);
|
||||
static void setclientstate(Client *c, long state);
|
||||
static void setfocus(Client *c);
|
||||
static void setfullscreen(Client *c, int fullscreen);
|
||||
+static void fullscreen(const Arg *arg);
|
||||
static void setlayout(const Arg *arg);
|
||||
static void setmfact(const Arg *arg);
|
||||
static void setup(void);
|
||||
@@ -1497,6 +1498,19 @@ setfullscreen(Client *c, int fullscreen)
|
||||
}
|
||||
}
|
||||
|
||||
+Layout *last_layout;
|
||||
+void
|
||||
+fullscreen(const Arg *arg)
|
||||
+{
|
||||
+ if (selmon->showbar) {
|
||||
+ for(last_layout = (Layout *)layouts; last_layout != selmon->lt[selmon->sellt]; last_layout++);
|
||||
+ setlayout(&((Arg) { .v = &layouts[2] }));
|
||||
+ } else {
|
||||
+ setlayout(&((Arg) { .v = last_layout }));
|
||||
+ }
|
||||
+ togglebar(arg);
|
||||
+}
|
||||
+
|
||||
void
|
||||
setlayout(const Arg *arg)
|
||||
{
|
||||
--
|
||||
2.22.0
|
Loading…
Reference in New Issue
Block a user