Implement modified, slimmed down version of flextile_deluxe

This commit is contained in:
speedie 2022-11-16 20:48:35 +01:00
parent 259dc8e0bb
commit 5f898f0193
12 changed files with 1117 additions and 592 deletions

View file

@ -151,13 +151,11 @@
- speedwm.icon.spacing: 5 ! Spacing between icon and text in the taskbar (<num>) - speedwm.icon.spacing: 5 ! Spacing between icon and text in the taskbar (<num>)
!@ !@
!! Layout options !! Layout options
!! Deck layout
!@ !@
- speedwm.layout.deck.count: 0 ! Enable deck count in the deck layout (0/1) - speedwm.layout.deck.count: 0 ! Enable deck count in the deck layout (0/1)
!@ !@
- speedwm.layout.deck.format: [%d] - speedwm.layout.deck.format: [%d]
!@
!@
- speedwm.layout.dgrid.forcevsplit: 1 ! Force vertical splits in the dynamic grid layout (0/1)
!@ !@
!! Monocle layout !! Monocle layout
!@ !@

View file

@ -4,7 +4,7 @@
- 4 - Switch to the Grid layout - 4 - Switch to the Grid layout
- 5 - Switch to the Deck layout - 5 - Switch to the Deck layout
- 6 - Switch to the Centered Master layout - 6 - Switch to the Centered Master layout
- 7 - Switch to the Centered Floating Master layout - 7 - Switch to the Tatami layout
- 8 - Switch to the Fibonacci Spiral layout - 8 - Switch to the Fibonacci Spiral layout
- 9 - Switch to the Fibonacci Dwindle layout - 9 - Switch to the Fibonacci Dwindle layout
- 10 - Switch to the Bottom Stack Vertical layout - 10 - Switch to the Bottom Stack Vertical layout
@ -99,4 +99,15 @@
- 99 - Reset vertical barpadding - 99 - Reset vertical barpadding
- 100 - Reset horizontal barpadding - 100 - Reset horizontal barpadding
- 101 - Reset vertical and horizontal barpadding - 101 - Reset vertical and horizontal barpadding
- 102 - Increase stack count by 1
- 103 - Decrease stack count by 1
- 104 - Rotate forward in the layout axis
- 105 - Rotate forward in the master axis
- 106 - Rotate forward in the stack axis
- 107 - Rotate forward in the secondary stack axis
- 108 - Rotate backwards in the layout axis
- 109 - Rotate backwards in the master axis
- 110 - Rotate backwards in the stack axis
- 111 - Rotate backwards in the secondary stack axis
- 112 - Mirror the layout

View file

@ -77,6 +77,9 @@
- Super+Control+w - Increases your volume - Super+Control+w - Increases your volume
- Super+Control+e - Decreases your volume - Super+Control+e - Decreases your volume
- Super+Control+0 - Tag all tags at once. - Super+Control+0 - Tag all tags at once.
- Super+Control+Enter - Mirror the layout
- Super+Control+i - Increase stackcount by 1
- Super+Control+u - Decrease stack count by 1
- Super+Control+z/x - Increase/decrease gaps between windows by 5 - Super+Control+z/x - Increase/decrease gaps between windows by 5
- Super+Control+j/k - Move focus between hidden windows (Can then 'Show') - Super+Control+j/k - Move focus between hidden windows (Can then 'Show')
- Super+Control+Arrow - Moves a window to any corner of your screen (Arrow key) - Super+Control+Arrow - Moves a window to any corner of your screen (Arrow key)

4
draw.c
View file

@ -337,8 +337,8 @@ int
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup) drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup)
{ {
char buf[1024]; char buf[1024];
int ty, th; int ty, th = 0;
unsigned int ew, eh; unsigned int ew = 0, eh = 0;
XftDraw *d = NULL; XftDraw *d = NULL;
size_t i, len; size_t i, len;

View file

@ -14,7 +14,8 @@ PAGEDIR = "/home/anon/Projects/page-improved/projects"
# If you use GNU/Linux, uncomment these lines (remove the # at the start of the line below) # If you use GNU/Linux, uncomment these lines (remove the # at the start of the line below)
FREETYPELIBS = -lfontconfig -lXft FREETYPELIBS = -lfontconfig -lXft
FREETYPEINC = /usr/include/freetype2 FREETYPEINC = /usr/include/freetype2
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Wno-unused-variable -Wno-unused-result -Wno-unused-function -Ofast -march=native ${INCS} ${CPPFLAGS} EXCFLAGS = -Wno-unused-variable -Wno-unused-function
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Wno-unused-result -Ofast -march=native ${INCS} ${CPPFLAGS} ${EXCFLAGS}
LDFLAGS = ${LIBS} -g LDFLAGS = ${LIBS} -g
# OpenBSD support # OpenBSD support

View file

@ -110,6 +110,7 @@ static Key keys[] = {
{ MODIFIER1|CONTROL|SHIFT, -1, XK_j, setcfact, {.f = -0.25} }, { MODIFIER1|CONTROL|SHIFT, -1, XK_j, setcfact, {.f = -0.25} },
{ MODIFIER1|CONTROL|SHIFT, -1, XK_0, setcfact, {.f = 0.00} }, { MODIFIER1|CONTROL|SHIFT, -1, XK_0, setcfact, {.f = 0.00} },
{ MODIFIER1, -1, XK_Return, zoom, {0} }, { MODIFIER1, -1, XK_Return, zoom, {0} },
{ MODIFIER1|CONTROL, -1, XK_Return, mirrorlayout, {0} },
{ MODIFIER1|SHIFT, -1, XK_q, killclient, {0} }, { MODIFIER1|SHIFT, -1, XK_q, killclient, {0} },
{ MODIFIER1|SHIFT, -1, XK_space, togglefloating, {0} }, { MODIFIER1|SHIFT, -1, XK_space, togglefloating, {0} },
{ MODIFIER1|CONTROL, -1, XK_0, view, {.ui = ~0 } }, { MODIFIER1|CONTROL, -1, XK_0, view, {.ui = ~0 } },
@ -130,6 +131,8 @@ static Key keys[] = {
#if USESWITCHER #if USESWITCHER
{ MODIFIER1, -1, XK_Tab, switcherstart, {0} }, { MODIFIER1, -1, XK_Tab, switcherstart, {0} },
#endif #endif
{ MODIFIER1|CONTROL, -1, XK_i, incstackcount, {.i = +1 } },
{ MODIFIER1|CONTROL, -1, XK_u, incstackcount, {.i = -1 } },
/* Floating mode keybinds */ /* Floating mode keybinds */
{ MODIFIER1, -1, XK_w, moveresizeaspect, {.i = +24} }, { MODIFIER1, -1, XK_w, moveresizeaspect, {.i = +24} },

1332
layouts.c

File diff suppressed because it is too large Load diff

View file

@ -49,7 +49,7 @@
* - If you want to modify mouse binds, edit mouse.h. * - If you want to modify mouse binds, edit mouse.h.
* - If you want to extensively change alpha and color options (probably not necessary), you can modify the colors.h header. * - If you want to extensively change alpha and color options (probably not necessary), you can modify the colors.h header.
* *
* The goal of this is to decrease the size of headers and make it easier to find what you want to find, because if I were to combine all of this into one big file, it would be really difficult to hack on it (see dwm-flexipatch for an example). * The goal of this is to decrease the size of headers and make it easier to find what you want to find, because if I were to combine all of this into one big file, it would be really difficult to hack on it (see dwm-tileipatch for an example).
* *
* Also note that: * Also note that:
* *
@ -80,7 +80,8 @@
/* Window alignment options */ /* Window alignment options */
static int bordersize = 1; /* How big your border is in pixels */ static int bordersize = 1; /* How big your border is in pixels */
static int snap = 20; /* Snap pixel */ static int snap = 20; /* Snap pixel */
static int mastercount = 1; /* Number of masters */ static int mastercount = 1; /* Number of clients in the master area */
static int stackcount = 0; /* Number of clients in the stack area */
static int resizehints = 0; /* Show resize hints */ static int resizehints = 0; /* Show resize hints */
static int decorhints = 1; /* Respect decoration hints */ static int decorhints = 1; /* Respect decoration hints */
static int savefloat = 1; /* Save position of floating windows */ static int savefloat = 1; /* Save position of floating windows */
@ -235,9 +236,6 @@ static char monocleformat[] = "[%d/%d]"; /* Format of the mono
static int deckcount = 0; /* Display deck count in the deck layout */ static int deckcount = 0; /* Display deck count in the deck layout */
static char deckformat[] = "[%d]"; /* Format of the deck count. deckcount must be set to 1 for this to be used. */ static char deckformat[] = "[%d]"; /* Format of the deck count. deckcount must be set to 1 for this to be used. */
/* Dynamic Grid layout */
static int forcevsplit = 1; /* Force two clients to always split vertically in the dynamic grid layout */
/* Custom layout */ /* Custom layout */
#define customhistfile ".config/speedwm/history" /* History file */ #define customhistfile ".config/speedwm/history" /* History file */
#define customprompt "dmenu -i -l 10 -p 'Enter an S expression >' <" /* Run launcher to use for the custom layout */ #define customprompt "dmenu -i -l 10 -p 'Enter an S expression >' <" /* Run launcher to use for the custom layout */

View file

@ -11,7 +11,7 @@ static Signal signals[] = {
{ 4, setlayout, {.v = &layouts[3]} }, /* Grid layout */ { 4, setlayout, {.v = &layouts[3]} }, /* Grid layout */
{ 5, setlayout, {.v = &layouts[4]} }, /* Deck layout */ { 5, setlayout, {.v = &layouts[4]} }, /* Deck layout */
{ 6, setlayout, {.v = &layouts[5]} }, /* Centered Master layout */ { 6, setlayout, {.v = &layouts[5]} }, /* Centered Master layout */
{ 7, setlayout, {.v = &layouts[6]} }, /* Centered Floating Master layout */ { 7, setlayout, {.v = &layouts[6]} }, /* Tatami layout */
{ 8, setlayout, {.v = &layouts[7]} }, /* Fibonacci Spiral layout */ { 8, setlayout, {.v = &layouts[7]} }, /* Fibonacci Spiral layout */
{ 9, setlayout, {.v = &layouts[8]} }, /* Fibonacci Dwindle layout */ { 9, setlayout, {.v = &layouts[8]} }, /* Fibonacci Dwindle layout */
{ 10, setlayout, {.v = &layouts[9]} }, /* Bottom Stack layout */ { 10, setlayout, {.v = &layouts[9]} }, /* Bottom Stack layout */
@ -112,4 +112,15 @@ static Signal signals[] = {
{ 99, resetbarpaddingv, {0} }, { 99, resetbarpaddingv, {0} },
{ 100, resetbarpaddingh, {0} }, { 100, resetbarpaddingh, {0} },
{ 101, resetbarpadding, {0} }, { 101, resetbarpadding, {0} },
{ 102, incstackcount, {.i = +1 } },
{ 103, incstackcount, {.i = -1 } },
{ 104, rotatelayoutaxis, {.i = +1 } },
{ 105, rotatelayoutaxis, {.i = +2 } },
{ 106, rotatelayoutaxis, {.i = +3 } },
{ 107, rotatelayoutaxis, {.i = +4 } },
{ 108, rotatelayoutaxis, {.i = -1 } },
{ 109, rotatelayoutaxis, {.i = -2 } },
{ 110, rotatelayoutaxis, {.i = -3 } },
{ 111, rotatelayoutaxis, {.i = -4 } },
{ 112, mirrorlayout, {0} },
}; };

279
speedwm.c
View file

@ -226,6 +226,16 @@ typedef struct {
const Arg arg; const Arg arg;
} Key; } Key;
typedef struct {
int mastercount;
int stackcount;
int layout;
int masteraxis; // master stack area
int stack1axis; // primary stack area
int stack2axis; // secondary stack area, e.g. centered master
void (*symbolfunc)(Monitor *, unsigned int);
} LayoutPreset;
typedef struct { typedef struct {
unsigned int signum; unsigned int signum;
void (*func)(const Arg *); void (*func)(const Arg *);
@ -235,6 +245,7 @@ typedef struct {
typedef struct { typedef struct {
const char *symbol; const char *symbol;
void (*arrange)(Monitor *); void (*arrange)(Monitor *);
LayoutPreset preset;
} Layout; } Layout;
typedef struct Pertag Pertag; typedef struct Pertag Pertag;
@ -245,6 +256,8 @@ struct Monitor {
#endif #endif
float mfact; /* mfact value */ float mfact; /* mfact value */
float cfact; /* cfact value */ float cfact; /* cfact value */
int ltaxis[4];
int stackcount;
int mastercount; /* number of clients in the master stack */ int mastercount; /* number of clients in the master stack */
int num; int num;
int by, bh; /* bar geometry */ int by, bh; /* bar geometry */
@ -435,13 +448,11 @@ static void dragmfact(const Arg *arg);
#endif #endif
static void drawbaritems(Monitor *m); static void drawbaritems(Monitor *m);
static void drawbar(void); static void drawbar(void);
static int drawarrows(Monitor *m);
#if USEROUNDCORNERS #if USEROUNDCORNERS
static void drawroundedcorners(Client *c); static void drawroundedcorners(Client *c);
#endif #endif
static int drawstatusbar(Monitor *m, int bh, char* text); static int drawstatusbar(Monitor *m, int bh, char* text);
static int statuslength(char *stext); static int statuslength(char *stext);
static int textlength(char* stext);
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);
@ -526,12 +537,16 @@ static void resizeclient(Client *c, int x, int y, int w, int h);
#if USEMOUSE #if USEMOUSE
static void resizemouse(const Arg *arg); static void resizemouse(const Arg *arg);
#endif #endif
static void changebarpos(const Arg *arg);
static void restack(Monitor *m); static void restack(Monitor *m);
static void run(void); static void run(void);
static void scantray(void); static void scantray(void);
static void scan(void); static void scan(void);
/* tile functions */
static void mirrorlayout(const Arg *arg);
static void rotatelayoutaxis(const Arg *arg);
static void incstackcount(const Arg *arg);
/* scratchpad functions */ /* scratchpad functions */
static void scratchpad_hide(); static void scratchpad_hide();
static _Bool scratchpad_last_showed_is_killed(void); static _Bool scratchpad_last_showed_is_killed(void);
@ -592,19 +607,42 @@ static void unmanagetray(Window w);
static void tagmon(const Arg *arg); static void tagmon(const Arg *arg);
/* layouts */ /* layouts */
static void setltsymbols(Monitor *m, unsigned int n);
static void monoclesymbols(Monitor *m, unsigned int n);
static void decksymbols(Monitor *m, unsigned int n);
static void layout_no_split(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n);
static void layout_split_vertical(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n);
static void layout_split_horizontal(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n);
static void layout_split_vertical_dual_stack(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n);
static void layout_split_horizontal_dual_stack(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n);
static void layout_split_centered_vertical(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n);
static void layout_split_centered_horizontal(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n);
static void layout_floating_master(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n);
static void layout_split_vertical_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n);
static void layout_split_horizontal_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n);
static void layout_split_vertical_dual_stack_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n);
static void layout_split_horizontal_dual_stack_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n);
static void layout_split_centered_vertical_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n);
static void layout_split_centered_horizontal_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n);
static void layout_floating_master_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n);
static void arrange_left_to_right(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
static void arrange_top_to_bottom(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
static void arrange_monocle(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
static void arrange_dynamicgrid(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
static void arrange_dynamicgrid_alt1(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
static void arrange_dynamicgrid_alt2(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
static void arrange_gridmode(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
static void arrange_horizgrid(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
static void arrange_dwindle(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
static void arrange_spiral(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
static void arrange_tatami(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai);
static void tile(Monitor *m); static void tile(Monitor *m);
static void monocle(Monitor *m);
static void grid(Monitor *m);
static void deck(Monitor *m);
static void spiral(Monitor *m);
static void dwindle(Monitor *m);
static void bstack(Monitor *m); static void bstack(Monitor *m);
static void bstackhoriz(Monitor *m); static void bstackhoriz(Monitor *m);
static void horizgrid(Monitor *m); static void hgrid(Monitor *m);
static void dynamicgrid(Monitor *m); static void ngrid(Monitor *m);
static void centeredmaster(Monitor *m); static void centeredmaster(Monitor *m);
static void centeredfloatingmaster(Monitor *m);
static void stairs(Monitor *m);
#if LAYOUT_CUSTOM #if LAYOUT_CUSTOM
static void custom(Monitor *m); static void custom(Monitor *m);
static void set_s_layout(const Arg *arg); static void set_s_layout(const Arg *arg);
@ -636,9 +674,6 @@ static void resetbar(const Arg *arg);
/* layout indicator */ /* layout indicator */
static void togglelayoutpos(const Arg *arg); static void togglelayoutpos(const Arg *arg);
/* layout toggles */
static void toggleltpos(const Arg *arg);
/* misc toggles */ /* misc toggles */
static void togglefloating(const Arg *arg); static void togglefloating(const Arg *arg);
static void toggleopacity(const Arg *arg); static void toggleopacity(const Arg *arg);
@ -805,6 +840,81 @@ static Monitor *mons, *selmon;
static Monitor *lastselmon; /* IPC */ static Monitor *lastselmon; /* IPC */
#endif #endif
/* See tile_deluxe for reference */
enum {
layout,
master,
stack,
stack2,
ltaxislast,
};
enum {
nosplit,
splitvertical,
splithorizontal,
splitcenteredvertical,
splitcenteredhorizontal,
splitverticaldualstack,
splithorizontaldualstack,
floatingmaster,
splitverticalfixed,
splithorizontalfixed,
splitcenteredverticalfixed,
splitcenteredhorizontalfixed,
splitverticaldualstackfixed,
splithorizontaldualstackfixed,
floatingmasterfixed,
layoutlast,
};
static char layoutsymb[] = {
32,
124,
61,
94,
126,
58,
59,
43,
124,
61,
94,
126,
58,
59,
43,
};
enum {
toptobottom,
lefttoright,
monocle,
dynamicgrid,
dynamicgridalt1,
dynamicgridalt2,
grid,
horizgrid,
dwindle,
spiral,
tatami,
axislast,
};
static char tilesymb[] = {
61,
124,
68,
71,
49,
50,
35,
126,
92,
64,
84,
};
static Window root, wmcheckwin; static Window root, wmcheckwin;
static KeySym keychain = -1; static KeySym keychain = -1;
@ -875,9 +985,6 @@ static int systraypinningfailfirst = 1;
/* Signals */ /* Signals */
#include "signal.h" /* Include signal support */ #include "signal.h" /* Include signal support */
/* Layout code */
#include "layouts.c" /* Enable patched layouts */
/* Rest of the IPC support */ /* Rest of the IPC support */
#if USEIPC #if USEIPC
#include "toggle/ipc-yajl.c" #include "toggle/ipc-yajl.c"
@ -890,7 +997,9 @@ struct Pertag {
int mastercounts[LENGTH(tags) + 1]; /* number of windows in master area */ int mastercounts[LENGTH(tags) + 1]; /* number of windows in master area */
float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */ float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */ unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */ int stackcounts[LENGTH(tags) + 1]; /* number of windows in primary stack area */
int ltaxis[LENGTH(tags) + 1][ltaxislast];
const Layout *ltidxs[LENGTH(tags) + 1][3]; /* matrix of tags and layouts indexes */
int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */ int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
unsigned int gaps[LENGTH(tags) + 1]; unsigned int gaps[LENGTH(tags) + 1];
}; };
@ -1735,6 +1844,7 @@ createmon(void)
m->tagset[0] = m->tagset[1] = startontag ? 1 : 0; m->tagset[0] = m->tagset[1] = startontag ? 1 : 0;
m->mfact = mfact; m->mfact = mfact;
m->mastercount = mastercount; m->mastercount = mastercount;
m->stackcount = stackcount;
m->showbar = !hidebar; m->showbar = !hidebar;
/* bar items */ /* bar items */
@ -1789,17 +1899,28 @@ createmon(void)
/* pertag */ /* pertag */
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
m->ltaxis[layout] = m->lt[0]->preset.layout;
m->ltaxis[master] = m->lt[0]->preset.masteraxis;
m->ltaxis[stack] = m->lt[0]->preset.stack1axis;
m->ltaxis[stack2] = m->lt[0]->preset.stack2axis;
m->pertag = ecalloc(1, sizeof(Pertag)); m->pertag = ecalloc(1, sizeof(Pertag));
m->pertag->curtag = m->pertag->prevtag = 1; m->pertag->curtag = m->pertag->prevtag = 1;
/* pertag */ /* pertag */
for (i = 0; i <= LENGTH(tags); i++) { for (i = 0; i <= LENGTH(tags); i++) {
m->pertag->mastercounts[i] = m->mastercount; m->pertag->mastercounts[i] = m->mastercount;
m->pertag->stackcounts[i] = m->stackcount;
m->pertag->mfacts[i] = m->mfact; m->pertag->mfacts[i] = m->mfact;
m->pertag->ltidxs[i][0] = m->lt[0]; m->pertag->ltidxs[i][0] = m->lt[0];
m->pertag->ltidxs[i][1] = m->lt[1]; m->pertag->ltidxs[i][1] = m->lt[1];
m->pertag->sellts[i] = m->sellt; m->pertag->sellts[i] = m->sellt;
m->pertag->showbars[i] = m->showbar; m->pertag->showbars[i] = m->showbar;
m->pertag->ltaxis[i][layout] = m->ltaxis[layout];
m->pertag->ltaxis[i][master] = m->ltaxis[master];
m->pertag->ltaxis[i][stack] = m->ltaxis[stack];
m->pertag->ltaxis[i][stack2] = m->ltaxis[stack2];
} }
#if USETAGPREVIEW #if USETAGPREVIEW
@ -2040,7 +2161,7 @@ readAndSetColor(int clrIdx, char* txt) {
int int
statuslength(char* stext) statuslength(char* stext)
{ {
int ret, i = -1, j = 0, w, len; int i = -1, w, len;
short isCode = 0; short isCode = 0;
char *text; char *text;
char *p; char *p;
@ -2231,8 +2352,6 @@ dragmfact(const Arg *arg)
return; return;
else if (m->lt[m->sellt]->arrange == &centeredmaster && (fixed || n - m->mastercount > 1)) else if (m->lt[m->sellt]->arrange == &centeredmaster && (fixed || n - m->mastercount > 1))
center = 1; center = 1;
else if (m->lt[m->sellt]->arrange == &centeredfloatingmaster)
center = 1;
else if (m->lt[m->sellt]->arrange == &bstack) else if (m->lt[m->sellt]->arrange == &bstack)
horizontal = 1; horizontal = 1;
else if (m->lt[m->sellt]->arrange == &bstackhoriz) else if (m->lt[m->sellt]->arrange == &bstackhoriz)
@ -2240,11 +2359,7 @@ dragmfact(const Arg *arg)
/* do not allow mfact to be modified under certain conditions */ /* do not allow mfact to be modified under certain conditions */
if (!m->lt[m->sellt]->arrange /* floating layout */ if (!m->lt[m->sellt]->arrange /* floating layout */
|| (!fixed && m->mastercount && n <= m->mastercount) /* no master */ || (!fixed && m->mastercount && n <= m->mastercount) /* no master */
|| m->lt[m->sellt]->arrange == &monocle /* monocle lt */
|| m->lt[m->sellt]->arrange == &grid /* grid lt */
|| m->lt[m->sellt]->arrange == &horizgrid /* horizgrid lt */
|| m->lt[m->sellt]->arrange == &dynamicgrid /* dgrid lt */
) )
return; return;
@ -2339,7 +2454,6 @@ drawbaritems(Monitor *m)
unsigned int i, occ = 0, urg = 0, n = 0; unsigned int i, occ = 0, urg = 0, n = 0;
/* powerline */ /* powerline */
int wt;
Clr *prevscheme, *nxtscheme; /* powerline schemes */ Clr *prevscheme, *nxtscheme; /* powerline schemes */
if (!selmon->hidetagpowerline || !selmon->hidetitlepowerline) { if (!selmon->hidetagpowerline || !selmon->hidetitlepowerline) {
@ -2352,9 +2466,6 @@ drawbaritems(Monitor *m)
int boxs = drw->font->h / 9; int boxs = drw->font->h / 9;
int boxw = drw->font->h / 6 + 2; int boxw = drw->font->h / 6 + 2;
/* monocle layout */
unsigned int s = 0, a = 0;
const char *tagtext; const char *tagtext;
Client *c; Client *c;
@ -2474,18 +2585,6 @@ resizebarwin(m);
} }
} }
/* override layout icon with number of layouts */
if (monoclecount) {
if (m->lt[m->sellt]->arrange == monocle) {
for (c = nexttiled(m->clients), a = 0, s = 0; c; c = nexttiled(c->next), a++)
if (c == m->stack)
s = a + 1;
if (!s && a)
s = 1;
snprintf(m->ltsymbol, sizeof m->ltsymbol, monocleformat, s, a);
}
}
/* draw the layout bar on the right if selmon->layoutposition is not 0 */ /* draw the layout bar on the right if selmon->layoutposition is not 0 */
if (!selmon->layoutposition && !selmon->hidelayout) { if (!selmon->layoutposition && !selmon->hidelayout) {
w = TEXTW(m->ltsymbol); w = TEXTW(m->ltsymbol);
@ -2506,7 +2605,6 @@ resizebarwin(m);
int remainder; int remainder;
int tabw; int tabw;
int docontinue = 0;
/* we're doing this to make sure the title does not get truncated when there's only supposed to be one title anyway */ /* we're doing this to make sure the title does not get truncated when there's only supposed to be one title anyway */
if (!selmon->hideunselectedtitle) { if (!selmon->hideunselectedtitle) {
@ -2738,8 +2836,6 @@ focus(Client *c)
XDeleteProperty(dpy, root, netatom[NetActiveWindow]); XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
} }
selmon->sel = c; selmon->sel = c;
if (selmon->lt[selmon->sellt]->arrange == monocle)
arrangemon(selmon);
drawbar(); drawbar();
} }
@ -3151,6 +3247,57 @@ incmastercount(const Arg *arg)
arrange(selmon); arrange(selmon);
} }
void
mirrorlayout(const Arg *arg)
{
if (!selmon->lt[selmon->sellt]->arrange)
return;
selmon->ltaxis[layout] *= -1;
selmon->pertag->ltaxis[selmon->pertag->curtag][0] = selmon->ltaxis[layout];
arrange(selmon);
}
void
rotatelayoutaxis(const Arg *arg)
{
int incr = (arg->i > 0 ? 1 : -1);
int axis = abs(arg->i) - 1;
if (!selmon->lt[selmon->sellt]->arrange)
return;
if (axis == layout) {
if (selmon->ltaxis[layout] >= 0) {
selmon->ltaxis[layout] += incr;
if (selmon->ltaxis[layout] >= layoutlast)
selmon->ltaxis[layout] = 0;
else if (selmon->ltaxis[layout] < 0)
selmon->ltaxis[layout] = layoutlast - 1;
} else {
selmon->ltaxis[layout] -= incr;
if (selmon->ltaxis[layout] <= -layoutlast)
selmon->ltaxis[layout] = 0;
else if (selmon->ltaxis[layout] > 0)
selmon->ltaxis[layout] = -layoutlast + 1;
}
} else {
selmon->ltaxis[axis] += incr;
if (selmon->ltaxis[axis] >= axislast)
selmon->ltaxis[axis] = 0;
else if (selmon->ltaxis[axis] < 0)
selmon->ltaxis[axis] = axislast - 1;
}
selmon->pertag->ltaxis[selmon->pertag->curtag][axis] = selmon->ltaxis[axis];
arrange(selmon);
setltsymbols(selmon, 0);
}
void
incstackcount(const Arg *arg)
{
selmon->stackcount = selmon->pertag->stackcounts[selmon->pertag->curtag] = MAX(selmon->stackcount + arg->i, 0);
arrange(selmon);
}
#ifdef XINERAMA #ifdef XINERAMA
static int static int
isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info) isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info)
@ -3630,10 +3777,6 @@ manage(Window w, XWindowAttributes *wa)
Client *c, *t = NULL, *term = NULL; Client *c, *t = NULL, *term = NULL;
Window trans = None; Window trans = None;
XWindowChanges wc; XWindowChanges wc;
int format;
unsigned int *ptags;
unsigned long n, extra;
Atom atom;
c = ecalloc(1, sizeof(Client)); c = ecalloc(1, sizeof(Client));
c->win = w; c->win = w;
@ -3730,9 +3873,12 @@ manage(Window w, XWindowAttributes *wa)
updatemotifhints(c); updatemotifhints(c);
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
grabbuttons(c, 0); grabbuttons(c, 0);
if (!c->isfloating) if (!c->isfloating) {
c->isfloating = c->oldstate = t || c->isfixed; c->isfloating = c->oldstate = t || c->isfixed;
XRaiseWindow(dpy, c->win); }
XRaiseWindow(dpy, c->win);
switch(attachdirection){ switch(attachdirection){
case 1: case 1:
attachabove(c); attachabove(c);
@ -4200,9 +4346,10 @@ switcherstart(const Arg *arg)
if (warpcursor) { if (warpcursor) {
selmon->allowwarp = 1; selmon->allowwarp = 1;
if (m == selmon && selmon->allowwarp && (m->tagset[m->seltags] & m->sel->tags) && selmon->lt[selmon->sellt] != &layouts[2]) if (m == selmon && selmon->allowwarp && (m->tagset[m->seltags] & m->sel->tags) && selmon->lt[selmon->sellt] != &layouts[2]) {
warp(m->sel); warp(m->sel);
selmon->allowwarp = 0; selmon->allowwarp = 0;
}
} }
restack(selmon); restack(selmon);
@ -5352,6 +5499,22 @@ setlayout(const Arg *arg)
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1; selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
if (arg && arg->v) if (arg && arg->v)
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v; selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
if (selmon->lt[selmon->sellt]->preset.mastercount && selmon->lt[selmon->sellt]->preset.mastercount != -1)
selmon->mastercount = selmon->lt[selmon->sellt]->preset.mastercount;
if (selmon->lt[selmon->sellt]->preset.stackcount && selmon->lt[selmon->sellt]->preset.stackcount != -1)
selmon->stackcount = selmon->lt[selmon->sellt]->preset.stackcount;
selmon->ltaxis[layout] = selmon->lt[selmon->sellt]->preset.layout;
selmon->ltaxis[master] = selmon->lt[selmon->sellt]->preset.masteraxis;
selmon->ltaxis[stack] = selmon->lt[selmon->sellt]->preset.stack1axis;
selmon->ltaxis[stack2] = selmon->lt[selmon->sellt]->preset.stack2axis;
selmon->pertag->ltaxis[selmon->pertag->curtag][layout] = selmon->ltaxis[layout];
selmon->pertag->ltaxis[selmon->pertag->curtag][master] = selmon->ltaxis[master];
selmon->pertag->ltaxis[selmon->pertag->curtag][stack] = selmon->ltaxis[stack];
selmon->pertag->ltaxis[selmon->pertag->curtag][stack2] = selmon->ltaxis[stack2];
if (selmon->sel) if (selmon->sel)
arrange(selmon); arrange(selmon);
else else
@ -5484,7 +5647,7 @@ setup(void)
netatom[NetWMWindowTypeDesktop] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DESKTOP", False); netatom[NetWMWindowTypeDesktop] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DESKTOP", False);
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False); netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
netatom[NetClientInfo] = XInternAtom(dpy, "_NET_CLIENT_INFO", False); netatom[NetClientInfo] = XInternAtom(dpy, "_NET_CLIENT_INFO", False);
netatom[NetClientListStacking] = XInternAtom(dpy, "_NET_CLIENT_LIST_STACKING", False); netatom[NetClientListStacking] = XInternAtom(dpy, "_NET_CLIENT_LIST_stackING", False);
#if USEFADE #if USEFADE
netatom[NetWMWindowsOpacity] = XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False); netatom[NetWMWindowsOpacity] = XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False);
#endif #endif
@ -6770,10 +6933,15 @@ view(const Arg *arg)
} }
selmon->mastercount = selmon->pertag->mastercounts[selmon->pertag->curtag]; selmon->mastercount = selmon->pertag->mastercounts[selmon->pertag->curtag];
selmon->stackcount = selmon->pertag->stackcounts[selmon->pertag->curtag];
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag]; selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
selmon->sellt = selmon->pertag->sellts[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] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1]; selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
selmon->ltaxis[layout] = selmon->pertag->ltaxis[selmon->pertag->curtag][layout];
selmon->ltaxis[master] = selmon->pertag->ltaxis[selmon->pertag->curtag][master];
selmon->ltaxis[stack] = selmon->pertag->ltaxis[selmon->pertag->curtag][stack];
selmon->ltaxis[stack2] = selmon->pertag->ltaxis[selmon->pertag->curtag][stack2];
if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag]) if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
togglebar(NULL); togglebar(NULL);
@ -7413,3 +7581,6 @@ inplacerotate(const Arg *arg)
arrange(selmon); arrange(selmon);
focus(c); focus(c);
} }
/* Layout code */
#include "layouts.c" /* Enable patched layouts */

45
text.h
View file

@ -26,21 +26,36 @@ static char *usedtags[] = { text_tag1_used, /* Tag 1 text
/* Text for layouts */ /* Text for layouts */
static Layout layouts[] = { static Layout layouts[] = {
{ text_layout1, tile, }, /* tile layout */ /* Tiling */
{ text_layout2, NULL, }, /* floating layout */ { text_layout1, tile, { -1, -1, splitvertical, toptobottom, toptobottom, 0, NULL } },
{ text_layout3, monocle, }, /* monocle layout */ /* Floating */
{ text_layout4, grid }, /* grid layout */ { text_layout2, NULL, {0} },
{ text_layout5, deck }, /* deck layout */ /* Monocle */
{ text_layout6, centeredmaster }, /* centered master layout */ { text_layout3, tile, { -1, -1, nosplit, monocle, monocle, 0, NULL } },
{ text_layout7, centeredfloatingmaster }, /* centered floating layout */ /* Grid */
{ text_layout8, spiral }, /* spiral layout */ { text_layout4, ngrid, {0} },
{ text_layout9, dwindle }, /* dwindle layout */ /* Deck */
{ text_layout10, bstack }, /* bottom stack layout */ { text_layout5, tile, { -1, -1, splitvertical, toptobottom, monocle, 0, NULL } },
{ text_layout11, bstackhoriz }, /* horiz bottom stack layout */ /* Centered Master */
{ text_layout12, horizgrid }, /* horiz grid layout */ { text_layout6, tile, { -1, -1, splithorizontal, lefttoright, toptobottom, 0, monoclesymbols } },
{ text_layout13, dynamicgrid }, /* dynamic grid layout */ /* Tatami */
{ text_layout7, tile, { -1, -1, splitvertical, lefttoright, tatami, 0, NULL } },
/* Spiral */
{ text_layout8, tile, { -1, -1, nosplit, spiral, spiral, 0, NULL } },
/* Dwindle */
{ text_layout9, tile, { -1, -1, nosplit, dwindle, dwindle, 0, NULL } },
/* Bottom Stack */
{ text_layout10, tile, { -1, -1, splithorizontal, lefttoright, lefttoright, 0, NULL } },
/* Bottom Stack (Horizontal */
{ text_layout11, tile, { -1, -1, splithorizontal, lefttoright, toptobottom, 0, NULL } },
/* Horizontal Grid */
{ text_layout12, hgrid, {0} },
/* Dynamic Grid */
{ text_layout13, tile, { -1, -1, nosplit, dynamicgrid, dynamicgrid, 0, NULL } },
/* Custom */
#if LAYOUT_CUSTOM #if LAYOUT_CUSTOM
{ text_layout14, custom }, /* custom layout */ { text_layout14, custom, {0} },
#endif #endif
{ NULL, NULL }, /* Reset to layout 1 */
{ NULL, NULL, {0} },
}; };

View file

@ -142,7 +142,7 @@ ResourcePref resources[] = {
{ "layout.monocle.format", STRING, &monocleformat }, { "layout.monocle.format", STRING, &monocleformat },
{ "layout.monocle.clientcount", INTEGER, &monocleclientcount }, { "layout.monocle.clientcount", INTEGER, &monocleclientcount },
{ "layout.monocle.count", INTEGER, &monoclecount }, { "layout.monocle.count", INTEGER, &monoclecount },
{ "layout.deck.format", STRING, &deckformat }, { "layout.deck.format", STRING, &deckformat },
{ "layout.deck.count", INTEGER, &deckcount }, { "layout.deck.count", INTEGER, &deckcount },
#if USEWINICON #if USEWINICON
{ "icon.size", INTEGER, &iconsize }, { "icon.size", INTEGER, &iconsize },