Add toggles for all layouts, fix potential segfault caused by improper

usage of dmenu/slock -v
This commit is contained in:
speedie 2022-09-03 19:08:07 +02:00
parent 8b879eb3eb
commit dae123f3d0
5 changed files with 140 additions and 5 deletions

View file

@ -1,3 +1,4 @@
#if LAYOUT_TILE
static void
tile(Monitor *m)
{
@ -36,7 +37,9 @@ tile(Monitor *m)
sy += HEIGHT(c) + ih;
}
}
#endif
#if LAYOUT_MONOCLE
void
monocle(Monitor *m)
{
@ -62,7 +65,9 @@ monocle(Monitor *m)
if (!c->isfloating && ISVISIBLE(c))
XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y);
}
#endif
#if LAYOUT_GRID
void
grid(Monitor *m)
{
@ -92,7 +97,9 @@ grid(Monitor *m)
resize(c, cx, cy, cw + (cc < cwrest ? 1 : 0) - 2*c->bw, ch + (cr < chrest ? 1 : 0) - 2*c->bw, False);
}
}
#endif
#if LAYOUT_GLGRID
void
gaplessgrid(Monitor *m)
{
@ -141,7 +148,9 @@ gaplessgrid(Monitor *m)
}
}
}
#endif
#if LAYOUT_FIBO
void
fibonacci(Monitor *m, int s)
{
@ -228,19 +237,25 @@ fibonacci(Monitor *m, int s)
resize(c, nx, ny, nw - (2*c->bw), nh - (2*c->bw), False);
}
}
#endif
#if LAYOUT_DWINDLE
void
dwindle(Monitor *m)
{
fibonacci(m, 1);
}
#endif
#if LAYOUT_SPIRAL
void
spiral(Monitor *m)
{
fibonacci(m, 0);
}
#endif
#if LAYOUT_TCL
void
tcl(Monitor * m)
{
@ -315,7 +330,9 @@ tcl(Monitor * m)
y = c->y + HEIGHT(c);
}
}
#endif
#if LAYOUT_BSTACK
static void
bstack(Monitor *m)
{
@ -356,7 +373,9 @@ bstack(Monitor *m)
}
}
}
#endif
#if LAYOUT_BSTACKH
static void
bstackhoriz(Monitor *m)
{
@ -398,7 +417,9 @@ bstackhoriz(Monitor *m)
}
}
}
#endif
#if LAYOUT_HGRID
void
horizgrid(Monitor *m) {
Client *c;
@ -459,7 +480,9 @@ horizgrid(Monitor *m) {
sx += WIDTH(c) + iv;
}
}
#endif
#if LAYOUT_DGRID
void
dynamicgrid(Monitor *m)
{
@ -513,7 +536,9 @@ dynamicgrid(Monitor *m)
resize(c, cx, cy, cw - (2*c->bw), ch - (2*c->bw), 0);
}
}
#endif
#if LAYOUT_TATAMI
void
tatami(Monitor *m) {
unsigned int i, n, nx, ny, nw, nh,
@ -671,7 +696,9 @@ tatami(Monitor *m) {
}
}
}
#endif
#if LAYOUT_TW
void
tilewide(Monitor *m)
{
@ -736,7 +763,9 @@ stairs(Monitor *m)
}
}
}
#endif
#if LAYOUT_CM
void
centeredmaster(Monitor *m)
{
@ -821,7 +850,9 @@ centeredmaster(Monitor *m)
}
}
}
#endif
#if LAYOUT_CFM
void
centeredfloatingmaster(Monitor *m)
{
@ -874,7 +905,9 @@ centeredfloatingmaster(Monitor *m)
sx += WIDTH(c) + iv;
}
}
#endif
#if LAYOUT_DECK
void
deck(Monitor *m)
{
@ -915,7 +948,9 @@ deck(Monitor *m)
resize(c, sx, sy, sw - (2*c->bw), sh - (2*c->bw), 0);
}
}
#endif
#if LAYOUT_TILE54
void
tile54(Monitor *m)
{
@ -952,7 +987,9 @@ tile54(Monitor *m)
ty += HEIGHT(c);
}
}
#endif
#if LAYOUT_COL
void
col(Monitor *m)
{
@ -978,4 +1015,5 @@ col(Monitor *m)
y += HEIGHT(c);
}
}
#endif

View file

@ -5,24 +5,61 @@
* Once you're done with your edits, run 'make clean install'. */
static const Layout layouts[] = {
#if LAYOUT_TILE
{ "(L1)", tile },
#endif
/* Floating layout (if no layout is available */
{ "(L2)", NULL },
#if LAYOUT_MONOCLE
{ "(L3)", monocle },
#endif
#if LAYOUT_GRID
{ "(L4)", grid },
#endif
#if LAYOUT_DECK
{ "(L5)", deck },
#endif
#if LAYOUT_CM
{ "(L6)", centeredmaster },
#endif
#if LAYOUT_CFM
{ "(L7)", centeredfloatingmaster },
#endif
#if LAYOUT_SPIRAL
{ "(L8)", spiral },
#endif
#if LAYOUT_DWINDLE
{ "(L9)", dwindle },
#endif
#if LAYOUT_TCL
{ "(L10)", tcl },
#endif
#if LAYOUT_BSTACK
{ "(L11)", bstack },
#endif
#if LAYOUT_BSTACKH
{ "(L12)", bstackhoriz },
#endif
#if LAYOUT_HGRID
{ "(L13)", horizgrid },
#endif
#if LAYOUT_TATAMI
{ "(L14)", tatami },
#endif
#if LAYOUT_TW
{ "(L15)", tilewide },
#endif
#if LAYOUT_STAIRS
{ "(L16)", stairs },
#endif
#if LAYOUT_TILE54
{ "(L17)", tile54 },
#endif
#if LAYOUT_COL
{ "(L18)", col },
#endif
#if LAYOUT_DGRID
{ "(L19)", dynamicgrid },
#endif
{ NULL, NULL },
};

View file

@ -55,10 +55,10 @@ elif [ "$trayer_srg" = "true" ]; then
fi
# Check if dmenu exists
dmenu -v > /dev/null || printf "\nWARNING: dmenu was not found. This means running applications will potentially be very inconvenient. It also means most bundled scripts will NOT work unless modified to work with rofi. See help for more information"
command -v dmenu > /dev/null || printf "\nWARNING: dmenu was not found. This means running applications will potentially be very inconvenient. It also means most bundled scripts will NOT work unless modified to work with rofi. See help for more information"
# Check if slock exists
slock -v > /dev/null || printf "\nWARNING: slock was not found. This means the shutdown menu can't lock your screen."
command -v slock > /dev/null || printf "\nWARNING: slock was not found. This means the shutdown menu can't lock your screen."
result="$(echo "$xrdb_exists$wmctrl_exists$xsetroot_exists$xwallpaper_exists$xmodmap_exists$trayer_exists")"

View file

@ -272,12 +272,20 @@ typedef struct {
/* function declarations */
static void applyrules(Client *c);
#if LAYOUT_CM
static void centeredmaster(Monitor *m);
#endif
#if LAYOUT_CFM
static void centeredfloatingmaster(Monitor *m);
#endif
#if LAYOUT_TW
static void tilewide(Monitor *m);
#endif
static void getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc);
static void getfacts(Monitor *m, int msize, int ssize, float *mf, float *sf, int *mr, int *sr);
#if LAYOUT_STAIRS
static void stairs(Monitor *m);
#endif
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
static void spawnscratch(const Arg *arg);
static void inplacerotate(const Arg *arg);
@ -305,7 +313,9 @@ static void checkotherwm(void);
static void cleanup(void);
static void cleanupmon(Monitor *mon);
static void clientmessage(XEvent *e);
#if LAYOUT_COL
static void col(Monitor *);
#endif
static void configure(Client *c);
static void configurenotify(XEvent *e);
static void livereloadxrdb(const Arg *arg);
@ -315,7 +325,9 @@ static void autostart_exec(void);
static void moveresize(const Arg *arg);
static void moveresizeedge(const Arg *arg);
static Monitor *createmon(void);
#if LAYOUT_DECK
static void deck(Monitor *m);
#endif
static void cyclelayout(const Arg *arg);
static void destroynotify(XEvent *e);
static void detach(Client *c);
@ -361,7 +373,9 @@ static void managealtbar(Window win, XWindowAttributes *wa);
static void managetray(Window win, XWindowAttributes *wa);
static void mappingnotify(XEvent *e);
static void maprequest(XEvent *e);
#if LAYOUT_MONOCLE
static void monocle(Monitor *m);
#endif
static void motionnotify(XEvent *e);
#if USEMOUSE
static void movemouse(const Arg *arg);
@ -443,8 +457,12 @@ static void unmanagetray(Window w);
static void getpreview(void);
#endif
static void tagmon(const Arg *arg);
#if LAYOUT_TILE
static void tile(Monitor *);
#endif
#if LAYOUT_TILE54
static void tile54(Monitor *);
#endif
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void toggleopacity(const Arg *arg);
@ -1713,7 +1731,10 @@ drawbar(Monitor *m)
int x = 0, w = 0, tw = 0, scm;
int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0, n = 0, a = 0, s = 0;
unsigned int i, occ = 0, urg = 0, n = 0;
#if LAYOUT_MONOCLE
unsigned int s = 0, a = 0;
#endif
const char *tagtext;
Client *c;
@ -1753,8 +1774,6 @@ drawbar(Monitor *m)
urg |= c->tags;
}
//x = 0;
/* Draw the layout bar on the left if leftlayout = 1 */
/* If colorlayoutnorm = 0, draw using SchemeLayout */
if (leftlayout && !hidelayout) {
@ -1781,6 +1800,7 @@ drawbar(Monitor *m)
x += w;
}
#if LAYOUT_MONOCLE
if (monoclecount) {
if (m->lt[m->sellt]->arrange == monocle) {
for (c = nexttiled(m->clients), a = 0, s = 0; c; c = nexttiled(c->next), a++)
@ -1791,6 +1811,7 @@ drawbar(Monitor *m)
snprintf(m->ltsymbol, sizeof m->ltsymbol, monocleformat, s, a);
}
}
#endif
/* Draw the layout bar on the right if leftlayout is not 0 */
/* If colorlayoutnorm = 0, draw using SchemeLayout */
@ -1930,8 +1951,10 @@ focus(Client *c)
XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
}
selmon->sel = c;
#if LAYOUT_MONOCLE
if (selmon->lt[selmon->sellt]->arrange == monocle)
arrangemon(selmon);
#endif
drawbars();
}

View file

@ -1,11 +1,48 @@
/* Toggle patches
* This header allows you to enable/disable patches that can break compability or decrease performance with certain OSes or configurations.
*/
/* IPC */
#define USEIPC 1 /* Whether or not to use IPC. If you set this to 1, set USEIPC to true in toggle.mk and comment the YAJLLIBS and YAJLINC lines in config.mk. Not compatible with BSDs so for those, set this to 0. */
/* Alpha related patches
*
* These do not have any dependencies but can slow down older computers.
* Because of this, you can easily toggle them on/off.
*/
#define USEALPHA 1 /* Whether or not to use transparency for the bar */
#define USEFADE 1 /* Whether or not to use fading windows */
#define USEMOUSE 1 /* Whether or not to use mouse binds */
/* Image related patches
*
* These can slow down speedwm slightly but if you use modern computers, it's not noticeable.
* If you wish to disable them though, set them to 0.
*/
#define USEIMLIB2 1 /* Whether or not to use imlib2. Required by USEWINICON and USETAGPREVIEW. */
#define USEWINICON 1 /* Whether or not to use window icons. Requires imlib to be enabled in toggle.mk and it must be installed. */
#define USETAGPREVIEW 1 /* Whether or not to use tag previews. Requires imlib to be enabled in toggle.mk and it must be installed. */
/* Layouts
* If you don't use a layout, you can remove it to keep the speedwm binary small.
*/
#define LAYOUT_TILE 1 /* Whether or not to include the tiling layout */
#define LAYOUT_TILE54 1 /* Whether or not to include hte 5:4 tiling layout */
#define LAYOUT_MONOCLE 1 /* Whether or not to include the monocle layout */
#define LAYOUT_GRID 1 /* Whether or not to include the grid layout */
#define LAYOUT_GLGRID 1 /* Whether or not to include the gapless grid layout */
#define LAYOUT_FIBO 1 /* Whether or not to include the fibonacci layout */
#define LAYOUT_DWINDLE 1 /* Whether or not to include the dwindle layout */
#define LAYOUT_SPIRAL 1 /* Whether or not to include the spiral layout */
#define LAYOUT_TCL 1 /* Whether or not to include the three column layout */
#define LAYOUT_BSTACK 1 /* Whether or not to include the bottom stack layout */
#define LAYOUT_BSTACKH 1 /* Whether or not to include the horizontal bottom stack layout */
#define LAYOUT_HGRID 1 /* Whether or not to include the horizontal grid layout */
#define LAYOUT_DGRID 1 /* Whether or not to include the dynamic grid layout */
#define LAYOUT_TATAMI 1 /* Whether or not to include the tatami layout */
#define LAYOUT_TW 1 /* Whether or not to include the wide tiling layout */
#define LAYOUT_CM 1 /* Whether or not to include the centered master layout */
#define LAYOUT_CFM 1 /* Whether or not to include the centered floating master layout */
#define LAYOUT_DECK 1 /* Whether or not to include the deck layout */
#define LAYOUT_COL 1 /* Whether or not to include the column layout */
#define LAYOUT_STAIRS 1 /* Whether or not to include the stairs layout */