mirror of
https://github.com/eRgo35/dots.git
synced 2025-12-16 15:36:11 +01:00
monocle tab switching
This commit is contained in:
@@ -7,6 +7,12 @@ static const unsigned int snap = 32; /* snap pixel */
|
|||||||
static const int showbar = 1; /* 0 means no bar */
|
static const int showbar = 1; /* 0 means no bar */
|
||||||
static const int topbar = 1; /* 0 means bottom bar */
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
static const int user_bh = 0; /* 0 means that dwm will calculate bar height, >= 1 means dwm will user_bh as bar height */
|
static const int user_bh = 0; /* 0 means that dwm will calculate bar height, >= 1 means dwm will user_bh as bar height */
|
||||||
|
/* Display modes of the tab bar: never shown, always shown, shown only in */
|
||||||
|
/* monocle mode in the presence of several windows. */
|
||||||
|
/* Modes after showtab_nmodes are disabled. */
|
||||||
|
enum showtab_modes { showtab_never, showtab_auto, showtab_nmodes, showtab_always};
|
||||||
|
static const int showtab = showtab_auto; /* Default tab bar show mode */
|
||||||
|
static const int toptab = False; /* False means bottom tab bar */
|
||||||
static const char *fonts[] = { "monospace:size=10" };
|
static const char *fonts[] = { "monospace:size=10" };
|
||||||
static const char dmenufont[] = "monospace:size=10";
|
static const char dmenufont[] = "monospace:size=10";
|
||||||
static char normbgcolor[] = "#222222";
|
static char normbgcolor[] = "#222222";
|
||||||
@@ -75,6 +81,7 @@ static const Key keys[] = {
|
|||||||
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||||
{ MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } },
|
{ MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } },
|
||||||
{ MODKEY, XK_b, togglebar, {0} },
|
{ MODKEY, XK_b, togglebar, {0} },
|
||||||
|
{ MODKEY, XK_w, tabmode, {-1} },
|
||||||
{ 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, XK_i, incnmaster, {.i = +1 } },
|
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||||
@@ -128,5 +135,6 @@ static const Button buttons[] = {
|
|||||||
{ ClkTagBar, 0, Button3, toggleview, {0} },
|
{ ClkTagBar, 0, Button3, toggleview, {0} },
|
||||||
{ ClkTagBar, MODKEY, Button1, tag, {0} },
|
{ ClkTagBar, MODKEY, Button1, tag, {0} },
|
||||||
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
|
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
|
||||||
|
{ ClkTabBar, 0, Button1, focuswin, {0} },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ static const Layout layouts[] = {
|
|||||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||||
{ "[M]", monocle },
|
{ "[M]", monocle },
|
||||||
{ "HHH", grid },
|
{ "HHH", grid },
|
||||||
|
{ "TTT", bstack },
|
||||||
|
{ "===", bstackhoriz },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* key definitions */
|
/* key definitions */
|
||||||
@@ -86,6 +88,8 @@ static const Key keys[] = {
|
|||||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||||
{ MODKEY, XK_g, setlayout, {.v = &layouts[3]} },
|
{ MODKEY, XK_g, setlayout, {.v = &layouts[3]} },
|
||||||
|
{ MODKEY, XK_u, setlayout, {.v = &layouts[4]} },
|
||||||
|
{ MODKEY, XK_o, setlayout, {.v = &layouts[5]} },
|
||||||
{ MODKEY|ShiftMask, XK_f, fullscreen, {0} },
|
{ MODKEY|ShiftMask, XK_f, fullscreen, {0} },
|
||||||
{ MODKEY, XK_space, setlayout, {0} },
|
{ MODKEY, XK_space, setlayout, {0} },
|
||||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||||
|
|||||||
@@ -1,20 +1,16 @@
|
|||||||
--- config.def.h
|
--- config.def.h 2019-02-02 04:55:28.000000000 -0800
|
||||||
+++ config.def.h
|
+++ config.def.h 2019-07-12 11:40:50.530164308 -0700
|
||||||
@@ -41,6 +41,8 @@ static const Layout layouts[] = {
|
@@ -5,6 +5,13 @@ static const unsigned int borderpx = 1;
|
||||||
{ "[]=", tile }, /* first entry is default */
|
static const unsigned int snap = 32; /* snap pixel */
|
||||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
static const int showbar = 1; /* 0 means no bar */
|
||||||
{ "[M]", monocle },
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
+ { "TTT", bstack },
|
+/* Display modes of the tab bar: never shown, always shown, shown only in */
|
||||||
+ { "===", bstackhoriz },
|
+/* monocle mode in the presence of several windows. */
|
||||||
};
|
+/* Modes after showtab_nmodes are disabled. */
|
||||||
|
+enum showtab_modes { showtab_never, showtab_auto, showtab_nmodes, showtab_always};
|
||||||
/* key definitions */
|
+static const int showtab = showtab_auto; /* Default tab bar show mode */
|
||||||
@@ -76,6 +78,8 @@ static Key keys[] = {
|
+static const int toptab = False; /* False means bottom tab bar */
|
||||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
+
|
||||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
static const char *fonts[] = { "monospace:size=10" };
|
||||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
static const char dmenufont[] = "monospace:size=10";
|
||||||
+ { MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
|
static const char col_gray1[] = "#222222";
|
||||||
+ { MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
|
|
||||||
{ MODKEY, XK_space, setlayout, {0} },
|
|
||||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
|
||||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
|
||||||
|
|||||||
@@ -20,14 +20,22 @@ layout applied.
|
|||||||
Windows are grouped by tags. Each window can be tagged with one or multiple
|
Windows are grouped by tags. Each window can be tagged with one or multiple
|
||||||
tags. Selecting certain tags displays all windows with these tags.
|
tags. Selecting certain tags displays all windows with these tags.
|
||||||
.P
|
.P
|
||||||
Each screen contains a small status bar which displays all available tags, the
|
Each screen contains two small status bars.
|
||||||
layout, the title of the focused window, and the text read from the root window
|
.P
|
||||||
name property, if the screen is focused. A floating window is indicated with an
|
One bar displays all available tags, the layout, the title of the focused
|
||||||
empty square and a maximised floating window is indicated with a filled square
|
window, and the text read from the root window name property, if the screen is
|
||||||
before the windows title. The selected tags are indicated with a different
|
focused. A floating window is indicated with an empty square and a maximised
|
||||||
color. The tags of the focused window are indicated with a filled square in the
|
floating window is indicated with a filled square before the windows title. The
|
||||||
top left corner. The tags which are applied to one or more windows are
|
selected tags are indicated with a different color. The tags of the focused
|
||||||
indicated with an empty square in the top left corner.
|
window are indicated with a filled square in the top left corner. The tags
|
||||||
|
which are applied to one or more windows are indicated with an empty square in
|
||||||
|
the top left corner.
|
||||||
|
.P
|
||||||
|
Another bar contains a tab for each window of the current view and allows
|
||||||
|
navigation between windows, especially in the monocle mode. The different
|
||||||
|
display modes of this bar are described under the Mod1\-w Keybord command
|
||||||
|
section. When a single tag is selected, this tag is indicated in the left corner
|
||||||
|
of the tab bar.
|
||||||
.P
|
.P
|
||||||
dwm draws a small border around windows to indicate the focus state.
|
dwm draws a small border around windows to indicate the focus state.
|
||||||
.P
|
.P
|
||||||
@@ -52,7 +60,8 @@ command.
|
|||||||
.TP
|
.TP
|
||||||
.B Button1
|
.B Button1
|
||||||
click on a tag label to display all windows with that tag, click on the layout
|
click on a tag label to display all windows with that tag, click on the layout
|
||||||
label toggles between tiled and floating layout.
|
label toggles between tiled and floating layout, click on a window name in the
|
||||||
|
tab bar brings focus to that window.
|
||||||
.TP
|
.TP
|
||||||
.B Button3
|
.B Button3
|
||||||
click on a tag label adds/removes all windows with that tag to/from the view.
|
click on a tag label adds/removes all windows with that tag to/from the view.
|
||||||
@@ -118,6 +127,12 @@ Increase master area size.
|
|||||||
.B Mod1\-h
|
.B Mod1\-h
|
||||||
Decrease master area size.
|
Decrease master area size.
|
||||||
.TP
|
.TP
|
||||||
|
.B Mod1\-w
|
||||||
|
Cycle over the tab bar display modes: never displayed, always displayed,
|
||||||
|
displayed only in monocle mode when the view contains more than one window (auto
|
||||||
|
mode). Some display modes can be disabled in the configuration, config.h. In
|
||||||
|
the default configuration only "never" and "auto" display modes are enabled.
|
||||||
|
.TP
|
||||||
.B Mod1\-Return
|
.B Mod1\-Return
|
||||||
Zooms/cycles focused window to/from master area (tiled layouts only).
|
Zooms/cycles focused window to/from master area (tiled layouts only).
|
||||||
.TP
|
.TP
|
||||||
|
|||||||
@@ -30,6 +30,14 @@ top left corner. The tags which are applied to one or more windows are
|
|||||||
indicated with an empty square in the top left corner.
|
indicated with an empty square in the top left corner.
|
||||||
.P
|
.P
|
||||||
dwm draws a small border around windows to indicate the focus state.
|
dwm draws a small border around windows to indicate the focus state.
|
||||||
|
.P
|
||||||
|
On start, dwm can start additional programs that may be specified in two special
|
||||||
|
shell scripts (see the FILES section below), autostart_blocking.sh and
|
||||||
|
autostart.sh. The former is executed first and dwm will wait for its
|
||||||
|
termination before starting. The latter is executed in the background before
|
||||||
|
dwm enters its handler loop.
|
||||||
|
.P
|
||||||
|
Either of these files may be omitted.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.B \-v
|
.B \-v
|
||||||
@@ -155,6 +163,21 @@ Toggles focused window between floating and tiled state.
|
|||||||
.TP
|
.TP
|
||||||
.B Mod1\-Button3
|
.B Mod1\-Button3
|
||||||
Resize focused window while dragging. Tiled windows will be toggled to the floating state.
|
Resize focused window while dragging. Tiled windows will be toggled to the floating state.
|
||||||
|
.SH FILES
|
||||||
|
The files containing programs to be started along with dwm are searched for in
|
||||||
|
the following directories:
|
||||||
|
.IP "1. $XDG_DATA_HOME/dwm"
|
||||||
|
.IP "2. $HOME/.local/share/dwm"
|
||||||
|
.IP "3. $HOME/.dwm"
|
||||||
|
.P
|
||||||
|
The first existing directory is scanned for any of the autostart files below.
|
||||||
|
.TP 15
|
||||||
|
autostart.sh
|
||||||
|
This file is started as a shell background process before dwm enters its handler
|
||||||
|
loop.
|
||||||
|
.TP 15
|
||||||
|
autostart_blocking.sh
|
||||||
|
This file is started before any autostart.sh; dwm waits for its termination.
|
||||||
.SH CUSTOMIZATION
|
.SH CUSTOMIZATION
|
||||||
dwm is customized by creating a custom config.h and (re)compiling the source
|
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||||
code. This keeps it fast, secure and simple.
|
code. This keeps it fast, secure and simple.
|
||||||
|
|||||||
211
dwm/.dwm/dwm.c
211
dwm/.dwm/dwm.c
@@ -82,7 +82,7 @@ enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
|||||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||||
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
||||||
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
||||||
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
enum { ClkTagBar, ClkTabBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
||||||
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
|
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
@@ -130,24 +130,32 @@ typedef struct {
|
|||||||
void (*arrange)(Monitor *);
|
void (*arrange)(Monitor *);
|
||||||
} Layout;
|
} Layout;
|
||||||
|
|
||||||
|
#define MAXTABS 50
|
||||||
|
|
||||||
struct Monitor {
|
struct Monitor {
|
||||||
char ltsymbol[16];
|
char ltsymbol[16];
|
||||||
float mfact;
|
float mfact;
|
||||||
int nmaster;
|
int nmaster;
|
||||||
int num;
|
int num;
|
||||||
int by; /* bar geometry */
|
int by; /* bar geometry */
|
||||||
|
int ty; /* tab 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 */
|
||||||
unsigned int seltags;
|
unsigned int seltags;
|
||||||
unsigned int sellt;
|
unsigned int sellt;
|
||||||
unsigned int tagset[2];
|
unsigned int tagset[2];
|
||||||
int showbar;
|
int showbar;
|
||||||
|
int showtab;
|
||||||
int topbar;
|
int topbar;
|
||||||
|
int toptab;
|
||||||
Client *clients;
|
Client *clients;
|
||||||
Client *sel;
|
Client *sel;
|
||||||
Client *stack;
|
Client *stack;
|
||||||
Monitor *next;
|
Monitor *next;
|
||||||
Window barwin;
|
Window barwin;
|
||||||
|
Window tabwin;
|
||||||
|
int ntabs;
|
||||||
|
int tab_widths[MAXTABS];
|
||||||
const Layout *lt[2];
|
const Layout *lt[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -183,12 +191,15 @@ 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 void drawtab(Monitor *m);
|
||||||
|
static void drawtabs(void);
|
||||||
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);
|
||||||
static void focusin(XEvent *e);
|
static void focusin(XEvent *e);
|
||||||
static void focusmon(const Arg *arg);
|
static void focusmon(const Arg *arg);
|
||||||
static void focusstack(const Arg *arg);
|
static void focusstack(const Arg *arg);
|
||||||
|
static void focuswin(const Arg* arg);
|
||||||
static Atom getatomprop(Client *c, Atom prop);
|
static Atom getatomprop(Client *c, Atom prop);
|
||||||
static int getrootptr(int *x, int *y);
|
static int getrootptr(int *x, int *y);
|
||||||
static long getstate(Window w);
|
static long getstate(Window w);
|
||||||
@@ -231,6 +242,7 @@ static void showhide(Client *c);
|
|||||||
static void sighup(int unused);
|
static void sighup(int unused);
|
||||||
static void sigterm(int unused);
|
static void sigterm(int unused);
|
||||||
static void spawn(const Arg *arg);
|
static void spawn(const Arg *arg);
|
||||||
|
static void tabmode(const Arg *arg);
|
||||||
static void tag(const Arg *arg);
|
static void tag(const Arg *arg);
|
||||||
static void tagmon(const Arg *arg);
|
static void tagmon(const Arg *arg);
|
||||||
static void tile(Monitor *m);
|
static void tile(Monitor *m);
|
||||||
@@ -273,6 +285,7 @@ static char stext[256];
|
|||||||
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 th = 0; /* tab bar geometry */
|
||||||
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;
|
||||||
@@ -435,8 +448,9 @@ arrange(Monitor *m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
arrangemon(Monitor *m)
|
arrangemon(Monitor *m) {
|
||||||
{
|
updatebarpos(m);
|
||||||
|
XMoveResizeWindow(dpy, m->tabwin, m->wx, m->ty, m->ww, th);
|
||||||
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
|
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
|
||||||
if (m->lt[m->sellt]->arrange)
|
if (m->lt[m->sellt]->arrange)
|
||||||
m->lt[m->sellt]->arrange(m);
|
m->lt[m->sellt]->arrange(m);
|
||||||
@@ -486,7 +500,24 @@ buttonpress(XEvent *e)
|
|||||||
click = ClkStatusText;
|
click = ClkStatusText;
|
||||||
else
|
else
|
||||||
click = ClkWinTitle;
|
click = ClkWinTitle;
|
||||||
} else if ((c = wintoclient(ev->window))) {
|
}
|
||||||
|
if(ev->window == selmon->tabwin) {
|
||||||
|
i = 0; x = 0;
|
||||||
|
for(c = selmon->clients; c; c = c->next){
|
||||||
|
if(!ISVISIBLE(c)) continue;
|
||||||
|
x += selmon->tab_widths[i];
|
||||||
|
if (ev->x > x)
|
||||||
|
++i;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
if(i >= m->ntabs) break;
|
||||||
|
}
|
||||||
|
if(c) {
|
||||||
|
click = ClkTabBar;
|
||||||
|
arg.ui = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if((c = wintoclient(ev->window))) {
|
||||||
focus(c);
|
focus(c);
|
||||||
restack(selmon);
|
restack(selmon);
|
||||||
XAllowEvents(dpy, ReplayPointer, CurrentTime);
|
XAllowEvents(dpy, ReplayPointer, CurrentTime);
|
||||||
@@ -494,8 +525,9 @@ buttonpress(XEvent *e)
|
|||||||
}
|
}
|
||||||
for (i = 0; i < LENGTH(buttons); i++)
|
for (i = 0; i < LENGTH(buttons); i++)
|
||||||
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
|
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
|
||||||
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
|
&& 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 == ClkTabBar) && buttons[i].arg.i == 0) ? &arg : &buttons[i].arg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -550,6 +582,8 @@ cleanupmon(Monitor *mon)
|
|||||||
}
|
}
|
||||||
XUnmapWindow(dpy, mon->barwin);
|
XUnmapWindow(dpy, mon->barwin);
|
||||||
XDestroyWindow(dpy, mon->barwin);
|
XDestroyWindow(dpy, mon->barwin);
|
||||||
|
XUnmapWindow(dpy, mon->tabwin);
|
||||||
|
XDestroyWindow(dpy, mon->tabwin);
|
||||||
free(mon);
|
free(mon);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -713,7 +747,10 @@ createmon(void)
|
|||||||
m->mfact = mfact;
|
m->mfact = mfact;
|
||||||
m->nmaster = nmaster;
|
m->nmaster = nmaster;
|
||||||
m->showbar = showbar;
|
m->showbar = showbar;
|
||||||
|
m->showtab = showtab;
|
||||||
m->topbar = topbar;
|
m->topbar = topbar;
|
||||||
|
m->toptab = toptab;
|
||||||
|
m->ntabs = 0;
|
||||||
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);
|
||||||
@@ -830,6 +867,105 @@ drawbars(void)
|
|||||||
drawbar(m);
|
drawbar(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drawtabs(void) {
|
||||||
|
Monitor *m;
|
||||||
|
|
||||||
|
for(m = mons; m; m = m->next)
|
||||||
|
drawtab(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmpint(const void *p1, const void *p2) {
|
||||||
|
/* The actual arguments to this function are "pointers to
|
||||||
|
pointers to char", but strcmp(3) arguments are "pointers
|
||||||
|
to char", hence the following cast plus dereference */
|
||||||
|
return *((int*) p1) > * (int*) p2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
drawtab(Monitor *m) {
|
||||||
|
Client *c;
|
||||||
|
int i;
|
||||||
|
int itag = -1;
|
||||||
|
char view_info[50];
|
||||||
|
int view_info_w = 0;
|
||||||
|
int sorted_label_widths[MAXTABS];
|
||||||
|
int tot_width;
|
||||||
|
int maxsize = bh;
|
||||||
|
int x = 0;
|
||||||
|
int w = 0;
|
||||||
|
|
||||||
|
//view_info: indicate the tag which is displayed in the view
|
||||||
|
for(i = 0; i < LENGTH(tags); ++i){
|
||||||
|
if((selmon->tagset[selmon->seltags] >> i) & 1) {
|
||||||
|
if(itag >=0){ //more than one tag selected
|
||||||
|
itag = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
itag = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(0 <= itag && itag < LENGTH(tags)){
|
||||||
|
snprintf(view_info, sizeof view_info, "[%s]", tags[itag]);
|
||||||
|
} else {
|
||||||
|
strncpy(view_info, "[...]", sizeof view_info);
|
||||||
|
}
|
||||||
|
view_info[sizeof(view_info) - 1 ] = 0;
|
||||||
|
view_info_w = TEXTW(view_info);
|
||||||
|
tot_width = view_info_w;
|
||||||
|
|
||||||
|
/* Calculates number of labels and their width */
|
||||||
|
m->ntabs = 0;
|
||||||
|
for(c = m->clients; c; c = c->next){
|
||||||
|
if(!ISVISIBLE(c)) continue;
|
||||||
|
m->tab_widths[m->ntabs] = TEXTW(c->name);
|
||||||
|
tot_width += m->tab_widths[m->ntabs];
|
||||||
|
++m->ntabs;
|
||||||
|
if(m->ntabs >= MAXTABS) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tot_width > m->ww){ //not enough space to display the labels, they need to be truncated
|
||||||
|
memcpy(sorted_label_widths, m->tab_widths, sizeof(int) * m->ntabs);
|
||||||
|
qsort(sorted_label_widths, m->ntabs, sizeof(int), cmpint);
|
||||||
|
tot_width = view_info_w;
|
||||||
|
for(i = 0; i < m->ntabs; ++i){
|
||||||
|
if(tot_width + (m->ntabs - i) * sorted_label_widths[i] > m->ww)
|
||||||
|
break;
|
||||||
|
tot_width += sorted_label_widths[i];
|
||||||
|
}
|
||||||
|
maxsize = (m->ww - tot_width) / (m->ntabs - i);
|
||||||
|
} else{
|
||||||
|
maxsize = m->ww;
|
||||||
|
}
|
||||||
|
i = 0;
|
||||||
|
for(c = m->clients; c; c = c->next){
|
||||||
|
if(!ISVISIBLE(c)) continue;
|
||||||
|
if(i >= m->ntabs) break;
|
||||||
|
if(m->tab_widths[i] > maxsize) m->tab_widths[i] = maxsize;
|
||||||
|
w = m->tab_widths[i];
|
||||||
|
drw_setscheme(drw, scheme[(c == m->sel) ? SchemeSel : SchemeNorm]);
|
||||||
|
drw_text(drw, x, 0, w, th, 0, c->name, 0);
|
||||||
|
x += w;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
|
||||||
|
/* cleans interspace between window names and current viewed tag label */
|
||||||
|
w = m->ww - view_info_w - x;
|
||||||
|
drw_text(drw, x, 0, w, th, 0, "", 0);
|
||||||
|
|
||||||
|
/* view info */
|
||||||
|
x += w;
|
||||||
|
w = view_info_w;
|
||||||
|
drw_text(drw, x, 0, w, th, 0, view_info, 0);
|
||||||
|
|
||||||
|
drw_map(drw, m->tabwin, 0, 0, m->ww, th);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
enternotify(XEvent *e)
|
enternotify(XEvent *e)
|
||||||
{
|
{
|
||||||
@@ -855,8 +991,10 @@ expose(XEvent *e)
|
|||||||
Monitor *m;
|
Monitor *m;
|
||||||
XExposeEvent *ev = &e->xexpose;
|
XExposeEvent *ev = &e->xexpose;
|
||||||
|
|
||||||
if (ev->count == 0 && (m = wintomon(ev->window)))
|
if(ev->count == 0 && (m = wintomon(ev->window))){
|
||||||
drawbar(m);
|
drawbar(m);
|
||||||
|
drawtab(m);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -882,6 +1020,7 @@ focus(Client *c)
|
|||||||
}
|
}
|
||||||
selmon->sel = c;
|
selmon->sel = c;
|
||||||
drawbars();
|
drawbars();
|
||||||
|
drawtabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* there are some broken focus acquiring clients needing extra handling */
|
/* there are some broken focus acquiring clients needing extra handling */
|
||||||
@@ -934,6 +1073,19 @@ focusstack(const Arg *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
focuswin(const Arg* arg){
|
||||||
|
int iwin = arg->i;
|
||||||
|
Client* c = NULL;
|
||||||
|
for(c = selmon->clients; c && (iwin || !ISVISIBLE(c)) ; c = c->next){
|
||||||
|
if(ISVISIBLE(c)) --iwin;
|
||||||
|
};
|
||||||
|
if(c) {
|
||||||
|
focus(c);
|
||||||
|
restack(selmon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Atom
|
Atom
|
||||||
getatomprop(Client *c, Atom prop)
|
getatomprop(Client *c, Atom prop)
|
||||||
{
|
{
|
||||||
@@ -1355,12 +1507,14 @@ propertynotify(XEvent *e)
|
|||||||
case XA_WM_HINTS:
|
case XA_WM_HINTS:
|
||||||
updatewmhints(c);
|
updatewmhints(c);
|
||||||
drawbars();
|
drawbars();
|
||||||
|
drawtabs();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
|
if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
|
||||||
updatetitle(c);
|
updatetitle(c);
|
||||||
if (c == c->mon->sel)
|
if (c == c->mon->sel)
|
||||||
drawbar(c->mon);
|
drawbar(c->mon);
|
||||||
|
drawtab(c->mon);
|
||||||
}
|
}
|
||||||
if (ev->atom == netatom[NetWMWindowType])
|
if (ev->atom == netatom[NetWMWindowType])
|
||||||
updatewindowtype(c);
|
updatewindowtype(c);
|
||||||
@@ -1499,6 +1653,7 @@ restack(Monitor *m)
|
|||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
|
|
||||||
drawbar(m);
|
drawbar(m);
|
||||||
|
drawtab(m);
|
||||||
if (!m->sel)
|
if (!m->sel)
|
||||||
return;
|
return;
|
||||||
if (m->sel->isfloating || !m->lt[m->sellt]->arrange)
|
if (m->sel->isfloating || !m->lt[m->sellt]->arrange)
|
||||||
@@ -1793,6 +1948,7 @@ setup(void)
|
|||||||
die("no fonts could be loaded.");
|
die("no fonts could be loaded.");
|
||||||
lrpad = drw->fonts->h;
|
lrpad = drw->fonts->h;
|
||||||
bh = user_bh ? user_bh : drw->fonts->h + 2;
|
bh = user_bh ? user_bh : drw->fonts->h + 2;
|
||||||
|
th = bh;
|
||||||
updategeom();
|
updategeom();
|
||||||
/* init atoms */
|
/* init atoms */
|
||||||
utf8string = XInternAtom(dpy, "UTF8_STRING", False);
|
utf8string = XInternAtom(dpy, "UTF8_STRING", False);
|
||||||
@@ -1958,6 +2114,17 @@ togglebar(const Arg *arg)
|
|||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tabmode(const Arg *arg)
|
||||||
|
{
|
||||||
|
if(arg && arg->i >= 0)
|
||||||
|
selmon->showtab = arg->ui % showtab_nmodes;
|
||||||
|
else
|
||||||
|
selmon->showtab = (selmon->showtab + 1 ) % showtab_nmodes;
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
togglefloating(const Arg *arg)
|
togglefloating(const Arg *arg)
|
||||||
{
|
{
|
||||||
@@ -2092,6 +2259,11 @@ updatebars(void)
|
|||||||
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
|
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
|
||||||
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
|
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
|
||||||
XMapRaised(dpy, m->barwin);
|
XMapRaised(dpy, m->barwin);
|
||||||
|
m->tabwin = XCreateWindow(dpy, root, m->wx, m->ty, m->ww, th, 0, DefaultDepth(dpy, screen),
|
||||||
|
CopyFromParent, DefaultVisual(dpy, screen),
|
||||||
|
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
|
||||||
|
XDefineCursor(dpy, m->tabwin, cursor[CurNormal]->cursor);
|
||||||
|
XMapRaised(dpy, m->tabwin);
|
||||||
XSetClassHint(dpy, m->barwin, &ch);
|
XSetClassHint(dpy, m->barwin, &ch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2099,14 +2271,33 @@ updatebars(void)
|
|||||||
void
|
void
|
||||||
updatebarpos(Monitor *m)
|
updatebarpos(Monitor *m)
|
||||||
{
|
{
|
||||||
|
Client *c;
|
||||||
|
int nvis = 0;
|
||||||
|
|
||||||
m->wy = m->my;
|
m->wy = m->my;
|
||||||
m->wh = m->mh;
|
m->wh = m->mh;
|
||||||
if (m->showbar) {
|
if (m->showbar) {
|
||||||
m->wh -= bh;
|
m->wh -= bh;
|
||||||
m->by = m->topbar ? m->wy : m->wy + m->wh;
|
m->by = m->topbar ? m->wy : m->wy + m->wh;
|
||||||
m->wy = m->topbar ? m->wy + bh : m->wy;
|
if ( m->topbar )
|
||||||
} else
|
m->wy += bh;
|
||||||
|
} else {
|
||||||
m->by = -bh;
|
m->by = -bh;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(c = m->clients; c; c = c->next) {
|
||||||
|
if(ISVISIBLE(c)) ++nvis;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m->showtab == showtab_always
|
||||||
|
|| ((m->showtab == showtab_auto) && (nvis > 1) && (m->lt[m->sellt]->arrange == monocle))) {
|
||||||
|
m->wh -= th;
|
||||||
|
m->ty = m->toptab ? m->wy : m->wy + m->wh;
|
||||||
|
if ( m->toptab )
|
||||||
|
m->wy += th;
|
||||||
|
} else {
|
||||||
|
m->ty = -th;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -2344,7 +2535,7 @@ wintomon(Window w)
|
|||||||
if (w == root && getrootptr(&x, &y))
|
if (w == root && getrootptr(&x, &y))
|
||||||
return recttomon(x, y, 1, 1);
|
return recttomon(x, y, 1, 1);
|
||||||
for (m = mons; m; m = m->next)
|
for (m = mons; m; m = m->next)
|
||||||
if (w == m->barwin)
|
if (w == m->barwin || w == m->tabwin)
|
||||||
return m;
|
return m;
|
||||||
if ((c = wintoclient(w)))
|
if ((c = wintoclient(w)))
|
||||||
return c->mon;
|
return c->mon;
|
||||||
|
|||||||
@@ -260,6 +260,8 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
|||||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||||
static void xrdb(const Arg *arg);
|
static void xrdb(const Arg *arg);
|
||||||
static void zoom(const Arg *arg);
|
static void zoom(const Arg *arg);
|
||||||
|
static void bstack(Monitor *m);
|
||||||
|
static void bstackhoriz(Monitor *m);
|
||||||
|
|
||||||
/* variables */
|
/* variables */
|
||||||
static const char autostartblocksh[] = "autostart_blocking.sh";
|
static const char autostartblocksh[] = "autostart_blocking.sh";
|
||||||
@@ -2436,3 +2438,65 @@ main(int argc, char *argv[])
|
|||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bstackhoriz(Monitor *m) {
|
||||||
|
int w, mh, mx, tx, ty, th;
|
||||||
|
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;
|
||||||
|
th = (m->wh - mh) / (n - m->nmaster);
|
||||||
|
ty = m->wy + mh;
|
||||||
|
} else {
|
||||||
|
th = mh = m->wh;
|
||||||
|
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 {
|
||||||
|
resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), 0);
|
||||||
|
if (th != m->wh)
|
||||||
|
ty += HEIGHT(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,11 +1,34 @@
|
|||||||
--- dwm.c
|
--- dwm.c 2019-02-02 04:55:28.000000000 -0800
|
||||||
+++ dwm.c
|
+++ dwm.c 2019-07-12 11:47:37.726846244 -0700
|
||||||
@@ -205,6 +205,8 @@ static void setup(void);
|
@@ -171,12 +179,15 @@ static void detachstack(Client *c);
|
||||||
static void seturgent(Client *c, int urg);
|
static Monitor *dirtomon(int dir);
|
||||||
static void showhide(Client *c);
|
static void drawbar(Monitor *m);
|
||||||
static void sigchld(int unused);
|
static void drawbars(void);
|
||||||
+static void sighup(int unused);
|
+static void drawtab(Monitor *m);
|
||||||
+static void sigterm(int unused);
|
+static void drawtabs(void);
|
||||||
static void spawn(const Arg *arg);
|
static void enternotify(XEvent *e);
|
||||||
static void tag(const Arg *arg);
|
static void expose(XEvent *e);
|
||||||
static void tagmon(const Arg *arg);
|
static void focus(Client *c);
|
||||||
|
static void focusin(XEvent *e);
|
||||||
|
static void focusmon(const Arg *arg);
|
||||||
|
static void focusstack(const Arg *arg);
|
||||||
|
+static void focuswin(const Arg* arg);
|
||||||
|
static int getrootptr(int *x, int *y);
|
||||||
|
static long getstate(Window w);
|
||||||
|
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
||||||
|
@@ -249,6 +261,7 @@ static char stext[256];
|
||||||
|
static int screen;
|
||||||
|
static int sw, sh; /* X display screen geometry width, height */
|
||||||
|
static int bh, blw = 0; /* bar geometry */
|
||||||
|
+static int th = 0; /* tab bar geometry */
|
||||||
|
static int lrpad; /* sum of left and right padding for text */
|
||||||
|
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
||||||
|
static unsigned int numlockmask = 0;
|
||||||
|
@@ -1697,6 +1852,7 @@ setup(void)
|
||||||
|
die("no fonts could be loaded.");
|
||||||
|
lrpad = drw->fonts->h;
|
||||||
|
bh = drw->fonts->h + 2;
|
||||||
|
+ th = bh;
|
||||||
|
updategeom();
|
||||||
|
/* init atoms */
|
||||||
|
utf8string = XInternAtom(dpy, "UTF8_STRING", False);
|
||||||
|
|||||||
@@ -1,488 +0,0 @@
|
|||||||
diff -up dwm-6.2.1/config.def.h dwm-6.2/config.def.h
|
|
||||||
--- dwm-6.2.1/config.def.h 2019-02-02 04:55:28.000000000 -0800
|
|
||||||
+++ dwm-6.2/config.def.h 2019-07-12 11:40:50.530164308 -0700
|
|
||||||
@@ -5,6 +5,13 @@ static const unsigned int borderpx = 1;
|
|
||||||
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 */
|
|
||||||
+/* Display modes of the tab bar: never shown, always shown, shown only in */
|
|
||||||
+/* monocle mode in the presence of several windows. */
|
|
||||||
+/* Modes after showtab_nmodes are disabled. */
|
|
||||||
+enum showtab_modes { showtab_never, showtab_auto, showtab_nmodes, showtab_always};
|
|
||||||
+static const int showtab = showtab_auto; /* Default tab bar show mode */
|
|
||||||
+static const int toptab = False; /* False means bottom tab bar */
|
|
||||||
+
|
|
||||||
static const char *fonts[] = { "monospace:size=10" };
|
|
||||||
static const char dmenufont[] = "monospace:size=10";
|
|
||||||
static const char col_gray1[] = "#222222";
|
|
||||||
@@ -64,6 +71,7 @@ static Key keys[] = {
|
|
||||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
|
||||||
{ MODKEY, XK_b, togglebar, {0} },
|
|
||||||
+ { MODKEY, XK_w, tabmode, {-1} },
|
|
||||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
|
||||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
|
||||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
|
||||||
@@ -111,5 +119,6 @@ static Button buttons[] = {
|
|
||||||
{ ClkTagBar, 0, Button3, toggleview, {0} },
|
|
||||||
{ ClkTagBar, MODKEY, Button1, tag, {0} },
|
|
||||||
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
|
|
||||||
+ { ClkTabBar, 0, Button1, focuswin, {0} },
|
|
||||||
};
|
|
||||||
|
|
||||||
diff -up dwm-6.2.1/dwm.1 dwm-6.2/dwm.1
|
|
||||||
--- dwm-6.2.1/dwm.1 2019-02-02 04:55:28.000000000 -0800
|
|
||||||
+++ dwm-6.2/dwm.1 2019-07-12 11:36:25.453487700 -0700
|
|
||||||
@@ -20,14 +20,22 @@ layout applied.
|
|
||||||
Windows are grouped by tags. Each window can be tagged with one or multiple
|
|
||||||
tags. Selecting certain tags displays all windows with these tags.
|
|
||||||
.P
|
|
||||||
-Each screen contains a small status bar which displays all available tags, the
|
|
||||||
-layout, the title of the focused window, and the text read from the root window
|
|
||||||
-name property, if the screen is focused. A floating window is indicated with an
|
|
||||||
-empty square and a maximised floating window is indicated with a filled square
|
|
||||||
-before the windows title. The selected tags are indicated with a different
|
|
||||||
-color. The tags of the focused window are indicated with a filled square in the
|
|
||||||
-top left corner. The tags which are applied to one or more windows are
|
|
||||||
-indicated with an empty square in the top left corner.
|
|
||||||
+Each screen contains two small status bars.
|
|
||||||
+.P
|
|
||||||
+One bar displays all available tags, the layout, the title of the focused
|
|
||||||
+window, and the text read from the root window name property, if the screen is
|
|
||||||
+focused. A floating window is indicated with an empty square and a maximised
|
|
||||||
+floating window is indicated with a filled square before the windows title. The
|
|
||||||
+selected tags are indicated with a different color. The tags of the focused
|
|
||||||
+window are indicated with a filled square in the top left corner. The tags
|
|
||||||
+which are applied to one or more windows are indicated with an empty square in
|
|
||||||
+the top left corner.
|
|
||||||
+.P
|
|
||||||
+Another bar contains a tab for each window of the current view and allows
|
|
||||||
+navigation between windows, especially in the monocle mode. The different
|
|
||||||
+display modes of this bar are described under the Mod1\-w Keybord command
|
|
||||||
+section. When a single tag is selected, this tag is indicated in the left corner
|
|
||||||
+of the tab bar.
|
|
||||||
.P
|
|
||||||
dwm draws a small border around windows to indicate the focus state.
|
|
||||||
.SH OPTIONS
|
|
||||||
@@ -44,7 +52,8 @@ command.
|
|
||||||
.TP
|
|
||||||
.B Button1
|
|
||||||
click on a tag label to display all windows with that tag, click on the layout
|
|
||||||
-label toggles between tiled and floating layout.
|
|
||||||
+label toggles between tiled and floating layout, click on a window name in the
|
|
||||||
+tab bar brings focus to that window.
|
|
||||||
.TP
|
|
||||||
.B Button3
|
|
||||||
click on a tag label adds/removes all windows with that tag to/from the view.
|
|
||||||
@@ -110,6 +119,12 @@ Increase master area size.
|
|
||||||
.B Mod1\-h
|
|
||||||
Decrease master area size.
|
|
||||||
.TP
|
|
||||||
+.B Mod1\-w
|
|
||||||
+Cycle over the tab bar display modes: never displayed, always displayed,
|
|
||||||
+displayed only in monocle mode when the view contains more than one window (auto
|
|
||||||
+mode). Some display modes can be disabled in the configuration, config.h. In
|
|
||||||
+the default configuration only "never" and "auto" display modes are enabled.
|
|
||||||
+.TP
|
|
||||||
.B Mod1\-Return
|
|
||||||
Zooms/cycles focused window to/from master area (tiled layouts only).
|
|
||||||
.TP
|
|
||||||
diff -up dwm-6.2.1/dwm.c dwm-6.2/dwm.c
|
|
||||||
--- dwm-6.2.1/dwm.c 2019-02-02 04:55:28.000000000 -0800
|
|
||||||
+++ dwm-6.2/dwm.c 2019-07-12 11:47:37.726846244 -0700
|
|
||||||
@@ -64,7 +64,7 @@ enum { NetSupported, NetWMName, NetWMSta
|
|
||||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
|
||||||
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
|
||||||
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
|
||||||
-enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
|
||||||
+enum { ClkTagBar, ClkTabBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
|
||||||
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
|
|
||||||
|
|
||||||
typedef union {
|
|
||||||
@@ -111,24 +111,32 @@ typedef struct {
|
|
||||||
void (*arrange)(Monitor *);
|
|
||||||
} Layout;
|
|
||||||
|
|
||||||
+#define MAXTABS 50
|
|
||||||
+
|
|
||||||
struct Monitor {
|
|
||||||
char ltsymbol[16];
|
|
||||||
float mfact;
|
|
||||||
int nmaster;
|
|
||||||
int num;
|
|
||||||
int by; /* bar geometry */
|
|
||||||
+ int ty; /* tab bar geometry */
|
|
||||||
int mx, my, mw, mh; /* screen size */
|
|
||||||
int wx, wy, ww, wh; /* window area */
|
|
||||||
unsigned int seltags;
|
|
||||||
unsigned int sellt;
|
|
||||||
unsigned int tagset[2];
|
|
||||||
int showbar;
|
|
||||||
+ int showtab;
|
|
||||||
int topbar;
|
|
||||||
+ int toptab;
|
|
||||||
Client *clients;
|
|
||||||
Client *sel;
|
|
||||||
Client *stack;
|
|
||||||
Monitor *next;
|
|
||||||
Window barwin;
|
|
||||||
+ Window tabwin;
|
|
||||||
+ int ntabs;
|
|
||||||
+ int tab_widths[MAXTABS];
|
|
||||||
const Layout *lt[2];
|
|
||||||
};
|
|
||||||
|
|
||||||
@@ -163,12 +171,15 @@ static void detachstack(Client *c);
|
|
||||||
static Monitor *dirtomon(int dir);
|
|
||||||
static void drawbar(Monitor *m);
|
|
||||||
static void drawbars(void);
|
|
||||||
+static void drawtab(Monitor *m);
|
|
||||||
+static void drawtabs(void);
|
|
||||||
static void enternotify(XEvent *e);
|
|
||||||
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 focuswin(const Arg* arg);
|
|
||||||
static int getrootptr(int *x, int *y);
|
|
||||||
static long getstate(Window w);
|
|
||||||
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
|
||||||
@@ -206,6 +217,7 @@ static void seturgent(Client *c, int urg
|
|
||||||
static void showhide(Client *c);
|
|
||||||
static void sigchld(int unused);
|
|
||||||
static void spawn(const Arg *arg);
|
|
||||||
+static void tabmode(const Arg *arg);
|
|
||||||
static void tag(const Arg *arg);
|
|
||||||
static void tagmon(const Arg *arg);
|
|
||||||
static void tile(Monitor *);
|
|
||||||
@@ -240,6 +252,7 @@ static char stext[256];
|
|
||||||
static int screen;
|
|
||||||
static int sw, sh; /* X display screen geometry width, height */
|
|
||||||
static int bh, blw = 0; /* bar geometry */
|
|
||||||
+static int th = 0; /* tab bar geometry */
|
|
||||||
static int lrpad; /* sum of left and right padding for text */
|
|
||||||
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
|
||||||
static unsigned int numlockmask = 0;
|
|
||||||
@@ -392,8 +405,9 @@ arrange(Monitor *m)
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
-arrangemon(Monitor *m)
|
|
||||||
-{
|
|
||||||
+arrangemon(Monitor *m) {
|
|
||||||
+ updatebarpos(m);
|
|
||||||
+ XMoveResizeWindow(dpy, m->tabwin, m->wx, m->ty, m->ww, th);
|
|
||||||
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
|
|
||||||
if (m->lt[m->sellt]->arrange)
|
|
||||||
m->lt[m->sellt]->arrange(m);
|
|
||||||
@@ -443,7 +457,24 @@ buttonpress(XEvent *e)
|
|
||||||
click = ClkStatusText;
|
|
||||||
else
|
|
||||||
click = ClkWinTitle;
|
|
||||||
- } else if ((c = wintoclient(ev->window))) {
|
|
||||||
+ }
|
|
||||||
+ if(ev->window == selmon->tabwin) {
|
|
||||||
+ i = 0; x = 0;
|
|
||||||
+ for(c = selmon->clients; c; c = c->next){
|
|
||||||
+ if(!ISVISIBLE(c)) continue;
|
|
||||||
+ x += selmon->tab_widths[i];
|
|
||||||
+ if (ev->x > x)
|
|
||||||
+ ++i;
|
|
||||||
+ else
|
|
||||||
+ break;
|
|
||||||
+ if(i >= m->ntabs) break;
|
|
||||||
+ }
|
|
||||||
+ if(c) {
|
|
||||||
+ click = ClkTabBar;
|
|
||||||
+ arg.ui = i;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ else if((c = wintoclient(ev->window))) {
|
|
||||||
focus(c);
|
|
||||||
restack(selmon);
|
|
||||||
XAllowEvents(dpy, ReplayPointer, CurrentTime);
|
|
||||||
@@ -451,8 +482,9 @@ 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);
|
|
||||||
+ && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)){
|
|
||||||
+ buttons[i].func(((click == ClkTagBar || click == ClkTabBar) && buttons[i].arg.i == 0) ? &arg : &buttons[i].arg);
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
@@ -506,6 +538,8 @@ cleanupmon(Monitor *mon)
|
|
||||||
}
|
|
||||||
XUnmapWindow(dpy, mon->barwin);
|
|
||||||
XDestroyWindow(dpy, mon->barwin);
|
|
||||||
+ XUnmapWindow(dpy, mon->tabwin);
|
|
||||||
+ XDestroyWindow(dpy, mon->tabwin);
|
|
||||||
free(mon);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -637,7 +671,10 @@ createmon(void)
|
|
||||||
m->mfact = mfact;
|
|
||||||
m->nmaster = nmaster;
|
|
||||||
m->showbar = showbar;
|
|
||||||
+ m->showtab = showtab;
|
|
||||||
m->topbar = topbar;
|
|
||||||
+ m->toptab = toptab;
|
|
||||||
+ m->ntabs = 0;
|
|
||||||
m->lt[0] = &layouts[0];
|
|
||||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
|
||||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
|
||||||
@@ -752,6 +789,105 @@ drawbars(void)
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
+drawtabs(void) {
|
|
||||||
+ Monitor *m;
|
|
||||||
+
|
|
||||||
+ for(m = mons; m; m = m->next)
|
|
||||||
+ drawtab(m);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int
|
|
||||||
+cmpint(const void *p1, const void *p2) {
|
|
||||||
+ /* The actual arguments to this function are "pointers to
|
|
||||||
+ pointers to char", but strcmp(3) arguments are "pointers
|
|
||||||
+ to char", hence the following cast plus dereference */
|
|
||||||
+ return *((int*) p1) > * (int*) p2;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+void
|
|
||||||
+drawtab(Monitor *m) {
|
|
||||||
+ Client *c;
|
|
||||||
+ int i;
|
|
||||||
+ int itag = -1;
|
|
||||||
+ char view_info[50];
|
|
||||||
+ int view_info_w = 0;
|
|
||||||
+ int sorted_label_widths[MAXTABS];
|
|
||||||
+ int tot_width;
|
|
||||||
+ int maxsize = bh;
|
|
||||||
+ int x = 0;
|
|
||||||
+ int w = 0;
|
|
||||||
+
|
|
||||||
+ //view_info: indicate the tag which is displayed in the view
|
|
||||||
+ for(i = 0; i < LENGTH(tags); ++i){
|
|
||||||
+ if((selmon->tagset[selmon->seltags] >> i) & 1) {
|
|
||||||
+ if(itag >=0){ //more than one tag selected
|
|
||||||
+ itag = -1;
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ itag = i;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if(0 <= itag && itag < LENGTH(tags)){
|
|
||||||
+ snprintf(view_info, sizeof view_info, "[%s]", tags[itag]);
|
|
||||||
+ } else {
|
|
||||||
+ strncpy(view_info, "[...]", sizeof view_info);
|
|
||||||
+ }
|
|
||||||
+ view_info[sizeof(view_info) - 1 ] = 0;
|
|
||||||
+ view_info_w = TEXTW(view_info);
|
|
||||||
+ tot_width = view_info_w;
|
|
||||||
+
|
|
||||||
+ /* Calculates number of labels and their width */
|
|
||||||
+ m->ntabs = 0;
|
|
||||||
+ for(c = m->clients; c; c = c->next){
|
|
||||||
+ if(!ISVISIBLE(c)) continue;
|
|
||||||
+ m->tab_widths[m->ntabs] = TEXTW(c->name);
|
|
||||||
+ tot_width += m->tab_widths[m->ntabs];
|
|
||||||
+ ++m->ntabs;
|
|
||||||
+ if(m->ntabs >= MAXTABS) break;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if(tot_width > m->ww){ //not enough space to display the labels, they need to be truncated
|
|
||||||
+ memcpy(sorted_label_widths, m->tab_widths, sizeof(int) * m->ntabs);
|
|
||||||
+ qsort(sorted_label_widths, m->ntabs, sizeof(int), cmpint);
|
|
||||||
+ tot_width = view_info_w;
|
|
||||||
+ for(i = 0; i < m->ntabs; ++i){
|
|
||||||
+ if(tot_width + (m->ntabs - i) * sorted_label_widths[i] > m->ww)
|
|
||||||
+ break;
|
|
||||||
+ tot_width += sorted_label_widths[i];
|
|
||||||
+ }
|
|
||||||
+ maxsize = (m->ww - tot_width) / (m->ntabs - i);
|
|
||||||
+ } else{
|
|
||||||
+ maxsize = m->ww;
|
|
||||||
+ }
|
|
||||||
+ i = 0;
|
|
||||||
+ for(c = m->clients; c; c = c->next){
|
|
||||||
+ if(!ISVISIBLE(c)) continue;
|
|
||||||
+ if(i >= m->ntabs) break;
|
|
||||||
+ if(m->tab_widths[i] > maxsize) m->tab_widths[i] = maxsize;
|
|
||||||
+ w = m->tab_widths[i];
|
|
||||||
+ drw_setscheme(drw, scheme[(c == m->sel) ? SchemeSel : SchemeNorm]);
|
|
||||||
+ drw_text(drw, x, 0, w, th, 0, c->name, 0);
|
|
||||||
+ x += w;
|
|
||||||
+ ++i;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ drw_setscheme(drw, scheme[SchemeNorm]);
|
|
||||||
+
|
|
||||||
+ /* cleans interspace between window names and current viewed tag label */
|
|
||||||
+ w = m->ww - view_info_w - x;
|
|
||||||
+ drw_text(drw, x, 0, w, th, 0, "", 0);
|
|
||||||
+
|
|
||||||
+ /* view info */
|
|
||||||
+ x += w;
|
|
||||||
+ w = view_info_w;
|
|
||||||
+ drw_text(drw, x, 0, w, th, 0, view_info, 0);
|
|
||||||
+
|
|
||||||
+ drw_map(drw, m->tabwin, 0, 0, m->ww, th);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void
|
|
||||||
enternotify(XEvent *e)
|
|
||||||
{
|
|
||||||
Client *c;
|
|
||||||
@@ -776,8 +912,10 @@ expose(XEvent *e)
|
|
||||||
Monitor *m;
|
|
||||||
XExposeEvent *ev = &e->xexpose;
|
|
||||||
|
|
||||||
- if (ev->count == 0 && (m = wintomon(ev->window)))
|
|
||||||
+ if(ev->count == 0 && (m = wintomon(ev->window))){
|
|
||||||
drawbar(m);
|
|
||||||
+ drawtab(m);
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
@@ -803,6 +941,7 @@ focus(Client *c)
|
|
||||||
}
|
|
||||||
selmon->sel = c;
|
|
||||||
drawbars();
|
|
||||||
+ drawtabs();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* there are some broken focus acquiring clients needing extra handling */
|
|
||||||
@@ -855,6 +994,19 @@ focusstack(const Arg *arg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+void
|
|
||||||
+focuswin(const Arg* arg){
|
|
||||||
+ int iwin = arg->i;
|
|
||||||
+ Client* c = NULL;
|
|
||||||
+ for(c = selmon->clients; c && (iwin || !ISVISIBLE(c)) ; c = c->next){
|
|
||||||
+ if(ISVISIBLE(c)) --iwin;
|
|
||||||
+ };
|
|
||||||
+ if(c) {
|
|
||||||
+ focus(c);
|
|
||||||
+ restack(selmon);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
Atom
|
|
||||||
getatomprop(Client *c, Atom prop)
|
|
||||||
{
|
|
||||||
@@ -1233,12 +1385,14 @@ propertynotify(XEvent *e)
|
|
||||||
case XA_WM_HINTS:
|
|
||||||
updatewmhints(c);
|
|
||||||
drawbars();
|
|
||||||
+ drawtabs();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
|
|
||||||
updatetitle(c);
|
|
||||||
if (c == c->mon->sel)
|
|
||||||
drawbar(c->mon);
|
|
||||||
+ drawtab(c->mon);
|
|
||||||
}
|
|
||||||
if (ev->atom == netatom[NetWMWindowType])
|
|
||||||
updatewindowtype(c);
|
|
||||||
@@ -1352,6 +1506,7 @@ restack(Monitor *m)
|
|
||||||
XWindowChanges wc;
|
|
||||||
|
|
||||||
drawbar(m);
|
|
||||||
+ drawtab(m);
|
|
||||||
if (!m->sel)
|
|
||||||
return;
|
|
||||||
if (m->sel->isfloating || !m->lt[m->sellt]->arrange)
|
|
||||||
@@ -1546,6 +1701,7 @@ setup(void)
|
|
||||||
die("no fonts could be loaded.");
|
|
||||||
lrpad = drw->fonts->h;
|
|
||||||
bh = drw->fonts->h + 2;
|
|
||||||
+ th = bh;
|
|
||||||
updategeom();
|
|
||||||
/* init atoms */
|
|
||||||
utf8string = XInternAtom(dpy, "UTF8_STRING", False);
|
|
||||||
@@ -1706,6 +1862,17 @@ togglebar(const Arg *arg)
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
+tabmode(const Arg *arg)
|
|
||||||
+{
|
|
||||||
+ if(arg && arg->i >= 0)
|
|
||||||
+ selmon->showtab = arg->ui % showtab_nmodes;
|
|
||||||
+ else
|
|
||||||
+ selmon->showtab = (selmon->showtab + 1 ) % showtab_nmodes;
|
|
||||||
+ arrange(selmon);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+void
|
|
||||||
togglefloating(const Arg *arg)
|
|
||||||
{
|
|
||||||
if (!selmon->sel)
|
|
||||||
@@ -1816,6 +1983,11 @@ updatebars(void)
|
|
||||||
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
|
|
||||||
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
|
|
||||||
XMapRaised(dpy, m->barwin);
|
|
||||||
+ m->tabwin = XCreateWindow(dpy, root, m->wx, m->ty, m->ww, th, 0, DefaultDepth(dpy, screen),
|
|
||||||
+ CopyFromParent, DefaultVisual(dpy, screen),
|
|
||||||
+ CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
|
|
||||||
+ XDefineCursor(dpy, m->tabwin, cursor[CurNormal]->cursor);
|
|
||||||
+ XMapRaised(dpy, m->tabwin);
|
|
||||||
XSetClassHint(dpy, m->barwin, &ch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1823,14 +1995,33 @@ updatebars(void)
|
|
||||||
void
|
|
||||||
updatebarpos(Monitor *m)
|
|
||||||
{
|
|
||||||
+ Client *c;
|
|
||||||
+ int nvis = 0;
|
|
||||||
+
|
|
||||||
m->wy = m->my;
|
|
||||||
m->wh = m->mh;
|
|
||||||
if (m->showbar) {
|
|
||||||
m->wh -= bh;
|
|
||||||
m->by = m->topbar ? m->wy : m->wy + m->wh;
|
|
||||||
- m->wy = m->topbar ? m->wy + bh : m->wy;
|
|
||||||
- } else
|
|
||||||
+ if ( m->topbar )
|
|
||||||
+ m->wy += bh;
|
|
||||||
+ } else {
|
|
||||||
m->by = -bh;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ for(c = m->clients; c; c = c->next) {
|
|
||||||
+ if(ISVISIBLE(c)) ++nvis;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if(m->showtab == showtab_always
|
|
||||||
+ || ((m->showtab == showtab_auto) && (nvis > 1) && (m->lt[m->sellt]->arrange == monocle))) {
|
|
||||||
+ m->wh -= th;
|
|
||||||
+ m->ty = m->toptab ? m->wy : m->wy + m->wh;
|
|
||||||
+ if ( m->toptab )
|
|
||||||
+ m->wy += th;
|
|
||||||
+ } else {
|
|
||||||
+ m->ty = -th;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
@@ -2067,7 +2258,7 @@ wintomon(Window w)
|
|
||||||
if (w == root && getrootptr(&x, &y))
|
|
||||||
return recttomon(x, y, 1, 1);
|
|
||||||
for (m = mons; m; m = m->next)
|
|
||||||
- if (w == m->barwin)
|
|
||||||
+ if (w == m->barwin || w == m->tabwin)
|
|
||||||
return m;
|
|
||||||
if ((c = wintoclient(w)))
|
|
||||||
return c->mon;
|
|
||||||
@@ -1,224 +0,0 @@
|
|||||||
diff -up a/dwm.c b/dwm.c
|
|
||||||
--- a/dwm.c 2020-05-23 00:20:34.877944603 +0200
|
|
||||||
+++ b/dwm.c 2020-06-22 12:49:55.298859682 +0200
|
|
||||||
@@ -111,6 +111,7 @@ typedef struct {
|
|
||||||
void (*arrange)(Monitor *);
|
|
||||||
} Layout;
|
|
||||||
|
|
||||||
+typedef struct Pertag Pertag;
|
|
||||||
struct Monitor {
|
|
||||||
char ltsymbol[16];
|
|
||||||
float mfact;
|
|
||||||
@@ -130,6 +131,7 @@ struct Monitor {
|
|
||||||
Monitor *next;
|
|
||||||
Window barwin;
|
|
||||||
const Layout *lt[2];
|
|
||||||
+ Pertag *pertag;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
@@ -271,6 +273,15 @@ static Window root, wmcheckwin;
|
|
||||||
/* configuration, allows nested code to access above variables */
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
+struct Pertag {
|
|
||||||
+ unsigned int curtag, prevtag; /* current and previous tag */
|
|
||||||
+ int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
|
|
||||||
+ float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
|
|
||||||
+ unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
|
|
||||||
+ const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
|
|
||||||
+ int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
|
||||||
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
|
||||||
|
|
||||||
@@ -631,6 +642,7 @@ Monitor *
|
|
||||||
createmon(void)
|
|
||||||
{
|
|
||||||
Monitor *m;
|
|
||||||
+ unsigned int i;
|
|
||||||
|
|
||||||
m = ecalloc(1, sizeof(Monitor));
|
|
||||||
m->tagset[0] = m->tagset[1] = 1;
|
|
||||||
@@ -641,6 +653,20 @@ createmon(void)
|
|
||||||
m->lt[0] = &layouts[0];
|
|
||||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
|
||||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
|
||||||
+ m->pertag = ecalloc(1, sizeof(Pertag));
|
|
||||||
+ m->pertag->curtag = m->pertag->prevtag = 1;
|
|
||||||
+
|
|
||||||
+ for (i = 0; i <= LENGTH(tags); i++) {
|
|
||||||
+ m->pertag->nmasters[i] = m->nmaster;
|
|
||||||
+ m->pertag->mfacts[i] = m->mfact;
|
|
||||||
+
|
|
||||||
+ m->pertag->ltidxs[i][0] = m->lt[0];
|
|
||||||
+ m->pertag->ltidxs[i][1] = m->lt[1];
|
|
||||||
+ m->pertag->sellts[i] = m->sellt;
|
|
||||||
+
|
|
||||||
+ m->pertag->showbars[i] = m->showbar;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -966,7 +992,16 @@ grabkeys(void)
|
|
||||||
void
|
|
||||||
incnmaster(const Arg *arg)
|
|
||||||
{
|
|
||||||
+ unsigned int i;
|
|
||||||
selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
|
|
||||||
+ for(i=0; i<LENGTH(tags); ++i)
|
|
||||||
+ if(selmon->tagset[selmon->seltags] & 1<<i)
|
|
||||||
+ selmon->pertag->nmasters[i+1] = selmon->nmaster;
|
|
||||||
+
|
|
||||||
+ if(selmon->pertag->curtag == 0)
|
|
||||||
+ {
|
|
||||||
+ selmon->pertag->nmasters[0] = selmon->nmaster;
|
|
||||||
+ }
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1500,11 +1535,26 @@ setfullscreen(Client *c, int fullscreen)
|
|
||||||
void
|
|
||||||
setlayout(const Arg *arg)
|
|
||||||
{
|
|
||||||
+ unsigned int i;
|
|
||||||
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
|
||||||
selmon->sellt ^= 1;
|
|
||||||
if (arg && arg->v)
|
|
||||||
selmon->lt[selmon->sellt] = (Layout *)arg->v;
|
|
||||||
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
|
|
||||||
+
|
|
||||||
+ for(i=0; i<LENGTH(tags); ++i)
|
|
||||||
+ if(selmon->tagset[selmon->seltags] & 1<<i)
|
|
||||||
+ {
|
|
||||||
+ selmon->pertag->ltidxs[i+1][selmon->sellt] = selmon->lt[selmon->sellt];
|
|
||||||
+ selmon->pertag->sellts[i+1] = selmon->sellt;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if(selmon->pertag->curtag == 0)
|
|
||||||
+ {
|
|
||||||
+ selmon->pertag->ltidxs[0][selmon->sellt] = selmon->lt[selmon->sellt];
|
|
||||||
+ selmon->pertag->sellts[0] = selmon->sellt;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
if (selmon->sel)
|
|
||||||
arrange(selmon);
|
|
||||||
else
|
|
||||||
@@ -1516,13 +1566,24 @@ void
|
|
||||||
setmfact(const Arg *arg)
|
|
||||||
{
|
|
||||||
float f;
|
|
||||||
+ unsigned int i;
|
|
||||||
|
|
||||||
if (!arg || !selmon->lt[selmon->sellt]->arrange)
|
|
||||||
return;
|
|
||||||
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
|
|
||||||
- if (f < 0.1 || f > 0.9)
|
|
||||||
+ if (arg->f == 0.0)
|
|
||||||
+ f = mfact;
|
|
||||||
+ if (f < 0.05 || f > 0.95)
|
|
||||||
return;
|
|
||||||
selmon->mfact = f;
|
|
||||||
+ for(i=0; i<LENGTH(tags); ++i)
|
|
||||||
+ if(selmon->tagset[selmon->seltags] & 1<<i)
|
|
||||||
+ selmon->pertag->mfacts[i+1] = f;
|
|
||||||
+
|
|
||||||
+ if(selmon->pertag->curtag == 0)
|
|
||||||
+ {
|
|
||||||
+ selmon->pertag->mfacts[0] = f;
|
|
||||||
+ }
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1699,7 +1760,16 @@ tile(Monitor *m)
|
|
||||||
void
|
|
||||||
togglebar(const Arg *arg)
|
|
||||||
{
|
|
||||||
+ unsigned int i;
|
|
||||||
selmon->showbar = !selmon->showbar;
|
|
||||||
+ for(i=0; i<LENGTH(tags); ++i)
|
|
||||||
+ if(selmon->tagset[selmon->seltags] & 1<<i)
|
|
||||||
+ selmon->pertag->showbars[i+1] = selmon->showbar;
|
|
||||||
+
|
|
||||||
+ if(selmon->pertag->curtag == 0)
|
|
||||||
+ {
|
|
||||||
+ selmon->pertag->showbars[0] = selmon->showbar;
|
|
||||||
+ }
|
|
||||||
updatebarpos(selmon);
|
|
||||||
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
|
||||||
arrange(selmon);
|
|
||||||
@@ -1738,9 +1808,33 @@ void
|
|
||||||
toggleview(const Arg *arg)
|
|
||||||
{
|
|
||||||
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
|
||||||
+ int i;
|
|
||||||
|
|
||||||
if (newtagset) {
|
|
||||||
selmon->tagset[selmon->seltags] = newtagset;
|
|
||||||
+
|
|
||||||
+ if (newtagset == ~0) {
|
|
||||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
+ selmon->pertag->curtag = 0;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* test if the user did not select the same tag */
|
|
||||||
+ if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
|
|
||||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
+ for (i = 0; !(newtagset & 1 << i); i++) ;
|
|
||||||
+ selmon->pertag->curtag = i + 1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* apply settings for this view */
|
|
||||||
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
|
||||||
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
|
||||||
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
|
||||||
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
|
||||||
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
|
||||||
+
|
|
||||||
+ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
|
||||||
+ togglebar(NULL);
|
|
||||||
+
|
|
||||||
focus(NULL);
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
||||||
@@ -2035,11 +2129,37 @@ updatewmhints(Client *c)
|
|
||||||
void
|
|
||||||
view(const Arg *arg)
|
|
||||||
{
|
|
||||||
+ int i;
|
|
||||||
+ unsigned int tmptag;
|
|
||||||
+
|
|
||||||
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
|
||||||
return;
|
|
||||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
|
||||||
- if (arg->ui & TAGMASK)
|
|
||||||
+ if (arg->ui & TAGMASK) {
|
|
||||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
|
||||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
+
|
|
||||||
+ if (arg->ui == ~0)
|
|
||||||
+ selmon->pertag->curtag = 0;
|
|
||||||
+ else {
|
|
||||||
+ for (i = 0; !(arg->ui & 1 << i); i++) ;
|
|
||||||
+ selmon->pertag->curtag = i + 1;
|
|
||||||
+ }
|
|
||||||
+ } else {
|
|
||||||
+ tmptag = selmon->pertag->prevtag;
|
|
||||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
+ selmon->pertag->curtag = tmptag;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
|
||||||
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
|
||||||
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
|
||||||
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
|
||||||
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
|
||||||
+
|
|
||||||
+ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
|
||||||
+ togglebar(NULL);
|
|
||||||
+
|
|
||||||
focus(NULL);
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user