Merge pull request #3 from speediegq/main
Fix bugs, codebase improvements, misc
This commit is contained in:
commit
da39686524
|
@ -39,8 +39,8 @@ or
|
||||||
|
|
||||||
## Current bugs
|
## Current bugs
|
||||||
- ~~Taskbar not working properly~~ (fixed in commit [e9015f2](https://github.com/Lucas-mother3/suckless-utils/commit/e9015f2d2a09ef66f1c9e188b277c89d23635195) & [7085f9](https://github.com/Lucas-mother3/suckless-utils/commit/7085f97d80fc203d6f54d0209af07007c0347880)). Thanks, [Speedie](https://speedie.gq)!
|
- ~~Taskbar not working properly~~ (fixed in commit [e9015f2](https://github.com/Lucas-mother3/suckless-utils/commit/e9015f2d2a09ef66f1c9e188b277c89d23635195) & [7085f9](https://github.com/Lucas-mother3/suckless-utils/commit/7085f97d80fc203d6f54d0209af07007c0347880)). Thanks, [Speedie](https://speedie.gq)!
|
||||||
- Unhiding a hidden window (using the show/hide function) and if it's the only program running, crashes dwm
|
- ~~Unhiding a hidden window (using the show/hide function) and if it's the only program running, crashes dwm~~
|
||||||
- Alt-tab crashes dwm altogther (idk man)
|
- ~~Alt-tab crashes dwm altogther (idk man)~~
|
||||||
|
|
||||||
## Patching even further
|
## Patching even further
|
||||||
|
|
||||||
|
|
3
dwm/.gitignore
vendored
Normal file
3
dwm/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
*.o
|
||||||
|
dwm
|
||||||
|
config.h
|
|
@ -77,9 +77,6 @@ static const int resizehints = 1; /* 1 means respect size hints in tiled resi
|
||||||
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||||
static const int decorhints = 1; /* 1 means respect decoration hints */
|
static const int decorhints = 1; /* 1 means respect decoration hints */
|
||||||
|
|
||||||
#include "layouts.c"
|
|
||||||
#include "horizgrid.c"
|
|
||||||
#include "gaplessgrid.c"
|
|
||||||
static const Layout layouts[] = {
|
static const Layout layouts[] = {
|
||||||
/* symbol arrange function */
|
/* symbol arrange function */
|
||||||
{ "[]=", tile }, /* first entry is default */
|
{ "[]=", tile }, /* first entry is default */
|
||||||
|
@ -101,25 +98,14 @@ static const Layout layouts[] = {
|
||||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||||
|
|
||||||
/* commands */
|
|
||||||
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
|
|
||||||
/* replace the values with ones on col_color as an workaround */
|
|
||||||
static const char *dmenucmd[] = { "j4-dmenu-desktop", "--dmenu", "dmenu -fn 'Hack Nerd Font:size=14' -nb '#173f4f' -nf '#ffffff' -sb '#124f5f' -sf '#eeeeee' -g 6 -l 6 ", "--term", "st", NULL };
|
|
||||||
static const char *dmenualt[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_color1, "-nf", col_color3, "-sb", col_color5, "-sf", col_color4, "-g", "6", "-l", "6", NULL};
|
|
||||||
static const char *termcmd[] = { "st", NULL };
|
|
||||||
static const char *tabtermcmd[] = { "tabbed", "-r 2", "st", "-w", "''", NULL };
|
|
||||||
static const char *firefoxcmd[] = { "firefox", NULL };
|
|
||||||
static const char *thunarcmd[] = { "dolphin", NULL };
|
|
||||||
|
|
||||||
#include "shiftview.c"
|
|
||||||
static Key keys[] = {
|
static Key keys[] = {
|
||||||
/* modifier key function argument */
|
/* modifier key function argument */
|
||||||
{ Mod4Mask, XK_s, spawn, {.v = dmenucmd } },
|
{ Mod4Mask, XK_s, spawn, SHCMD("j4-dmenu-desktop --dmenu dmenu -fn 'Hack Nerd Font:size=14' -nb '#173f4f' -nf '#ffffff' -sb '#124f5f' -sf '#eeeeee' -g 6 -l 6 --term st") },
|
||||||
{ Mod4Mask|ShiftMask, XK_s, spawn, {.v = dmenualt } },
|
{ Mod4Mask|ShiftMask, XK_s, spawn, SHCMD("dmenu_run -fn 'Hack Nerd Font:size=14' -nb '#173f4f' -nf '#ffffff' -sb '#124f5f' -sf '#eeeeee' -g 6 -l 6") },
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
{ MODKEY|ShiftMask, XK_Return, spawn, SHCMD("st -e") },
|
||||||
{ MODKEY|ShiftMask, XK_t, spawn, {.v = tabtermcmd } },
|
{ MODKEY|ShiftMask, XK_t, spawn, SHCMD("tabbed -r 2 st -w ''") },
|
||||||
{ MODKEY|ShiftMask, XK_i, spawn, {.v = firefoxcmd } },
|
{ MODKEY|ShiftMask, XK_i, spawn, SHCMD("firefox") },
|
||||||
{ Mod4Mask, XK_e, spawn, {.v = thunarcmd } },
|
{ Mod4Mask, XK_e, spawn, SHCMD("dolphin") },
|
||||||
{ Mod4Mask, XK_Print, spawn, SHCMD("maim ~/Pictures/Screenshot_$(date +%s).png") },
|
{ Mod4Mask, XK_Print, spawn, SHCMD("maim ~/Pictures/Screenshot_$(date +%s).png") },
|
||||||
{ MODKEY|ShiftMask, XK_b, togglebar, {0} },
|
{ MODKEY|ShiftMask, XK_b, togglebar, {0} },
|
||||||
{ MODKEY|ShiftMask, XK_n, togglefollow, {0} },
|
{ MODKEY|ShiftMask, XK_n, togglefollow, {0} },
|
||||||
|
@ -175,13 +161,13 @@ static Key keys[] = {
|
||||||
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
||||||
static Button buttons[] = {
|
static Button buttons[] = {
|
||||||
/* click event mask button function argument */
|
/* click event mask button function argument */
|
||||||
{ ClkButton, 0, Button1, spawn, {.v = dmenucmd } },
|
{ ClkButton, 0, Button1, spawn, SHCMD("j4-dmenu-desktop --dmenu dmenu -fn 'Hack Nerd Font:size=14' -nb '#173f4f' -nf '#ffffff' -sb '#124f5f' -sf '#eeeeee' -g 6 -l 6 --term st") },
|
||||||
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
||||||
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
||||||
{ ClkFollowSymbol, 0, Button1, togglefollow, {0} },
|
{ ClkFollowSymbol, 0, Button1, togglefollow, {0} },
|
||||||
{ ClkWinTitle, 0, Button1, togglewin, {0} },
|
{ ClkWinTitle, 0, Button1, togglewin, {0} },
|
||||||
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||||
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
{ ClkStatusText, 0, Button2, spawn, SHCMD("st -e") },
|
||||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||||
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||||
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||||
|
|
49
dwm/dwm.c
49
dwm/dwm.c
|
@ -242,6 +242,7 @@ static void setmfact(const Arg *arg);
|
||||||
static void setup(void);
|
static void setup(void);
|
||||||
static void seturgent(Client *c, int urg);
|
static void seturgent(Client *c, int urg);
|
||||||
static void show(const Arg *arg);
|
static void show(const Arg *arg);
|
||||||
|
static void shiftview(const Arg *arg);
|
||||||
static void showwin(Client *c);
|
static void showwin(Client *c);
|
||||||
static void showhide(Client *c);
|
static void showhide(Client *c);
|
||||||
static void sigchld(int unused);
|
static void sigchld(int unused);
|
||||||
|
@ -321,6 +322,8 @@ static Visual *visual;
|
||||||
static int depth;
|
static int depth;
|
||||||
static Colormap cmap;
|
static Colormap cmap;
|
||||||
|
|
||||||
|
#include "layouts.c"
|
||||||
|
|
||||||
/* configuration, allows nested code to access above variables */
|
/* configuration, allows nested code to access above variables */
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
@ -1979,6 +1982,21 @@ show(const Arg *arg)
|
||||||
showwin(selmon->sel);
|
showwin(selmon->sel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
shiftview(const Arg *arg) {
|
||||||
|
Arg shifted;
|
||||||
|
|
||||||
|
if(arg->i > 0) // left circular shift
|
||||||
|
shifted.ui = (selmon->tagset[selmon->seltags] << arg->i)
|
||||||
|
| (selmon->tagset[selmon->seltags] >> (LENGTH(tags) - arg->i));
|
||||||
|
|
||||||
|
else // right circular shift
|
||||||
|
shifted.ui = selmon->tagset[selmon->seltags] >> (- arg->i)
|
||||||
|
| selmon->tagset[selmon->seltags] << (LENGTH(tags) + arg->i);
|
||||||
|
|
||||||
|
view(&shifted);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
showwin(Client *c)
|
showwin(Client *c)
|
||||||
{
|
{
|
||||||
|
@ -2019,8 +2037,6 @@ sigchld(int unused)
|
||||||
void
|
void
|
||||||
spawn(const Arg *arg)
|
spawn(const Arg *arg)
|
||||||
{
|
{
|
||||||
if (arg->v == dmenucmd)
|
|
||||||
dmenumon[0] = '0' + selmon->num;
|
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
if (dpy)
|
if (dpy)
|
||||||
close(ConnectionNumber(dpy));
|
close(ConnectionNumber(dpy));
|
||||||
|
@ -2103,7 +2119,9 @@ drawTab(int nwins, int first, Monitor *m)
|
||||||
Monitor *m = selmon;
|
Monitor *m = selmon;
|
||||||
XSetWindowAttributes wa = {
|
XSetWindowAttributes wa = {
|
||||||
.override_redirect = True,
|
.override_redirect = True,
|
||||||
.background_pixmap = ParentRelative,
|
.background_pixel = 0,
|
||||||
|
.border_pixel = 0,
|
||||||
|
.colormap = cmap,
|
||||||
.event_mask = ButtonPressMask|ExposureMask
|
.event_mask = ButtonPressMask|ExposureMask
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2129,9 +2147,9 @@ drawTab(int nwins, int first, Monitor *m)
|
||||||
|
|
||||||
h = selmon->maxHTab;
|
h = selmon->maxHTab;
|
||||||
/* XCreateWindow(display, parent, x, y, width, height, border_width, depth, class, visual, valuemask, attributes); just reference */
|
/* XCreateWindow(display, parent, x, y, width, height, border_width, depth, class, visual, valuemask, attributes); just reference */
|
||||||
m->tabwin = XCreateWindow(dpy, root, posX, posY, selmon->maxWTab, selmon->maxHTab, 2, DefaultDepth(dpy, screen),
|
m->tabwin = XCreateWindow(dpy, root, posX, posY, selmon->maxWTab, selmon->maxHTab, 2, depth,
|
||||||
CopyFromParent, DefaultVisual(dpy, screen),
|
InputOutput, visual,
|
||||||
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); /* create tabwin */
|
CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa);
|
||||||
|
|
||||||
XDefineCursor(dpy, m->tabwin, cursor[CurNormal]->cursor);
|
XDefineCursor(dpy, m->tabwin, cursor[CurNormal]->cursor);
|
||||||
XMapRaised(dpy, m->tabwin);
|
XMapRaised(dpy, m->tabwin);
|
||||||
|
@ -2394,17 +2412,20 @@ void
|
||||||
togglewin(const Arg *arg)
|
togglewin(const Arg *arg)
|
||||||
{
|
{
|
||||||
Client *c = (Client*)arg->v;
|
Client *c = (Client*)arg->v;
|
||||||
|
if (!c)
|
||||||
|
c = selmon->sel;
|
||||||
|
if (!c)
|
||||||
|
return;
|
||||||
|
|
||||||
if (c == selmon->sel) {
|
if (HIDDEN(c)) {
|
||||||
hidewin(c);
|
|
||||||
focus(NULL);
|
|
||||||
arrange(c->mon);
|
|
||||||
} else {
|
|
||||||
if (HIDDEN(c))
|
|
||||||
showwin(c);
|
showwin(c);
|
||||||
focus(c);
|
} else {
|
||||||
restack(selmon);
|
hidewin(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restack(c->mon);
|
||||||
|
focus(c);
|
||||||
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
void
|
|
||||||
gaplessgrid(Monitor *m) {
|
|
||||||
unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
|
|
||||||
Client *c;
|
|
||||||
|
|
||||||
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ;
|
|
||||||
if(n == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* grid dimensions */
|
|
||||||
for(cols = 0; cols <= n/2; cols++)
|
|
||||||
if(cols*cols >= n)
|
|
||||||
break;
|
|
||||||
if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
|
|
||||||
cols = 2;
|
|
||||||
rows = n/cols;
|
|
||||||
|
|
||||||
/* window geometries */
|
|
||||||
cw = cols ? m->ww / cols : m->ww;
|
|
||||||
cn = 0; /* current column number */
|
|
||||||
rn = 0; /* current row number */
|
|
||||||
for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
|
|
||||||
if(i/rows + 1 > cols - n%cols)
|
|
||||||
rows = n/cols + 1;
|
|
||||||
ch = rows ? m->wh / rows : m->wh;
|
|
||||||
cx = m->wx + cn*cw;
|
|
||||||
cy = m->wy + rn*ch;
|
|
||||||
resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
|
|
||||||
rn++;
|
|
||||||
if(rn >= rows) {
|
|
||||||
rn = 0;
|
|
||||||
cn++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
void
|
|
||||||
horizgrid(Monitor *m) {
|
|
||||||
Client *c;
|
|
||||||
unsigned int n, i;
|
|
||||||
int w = 0;
|
|
||||||
int ntop, nbottom = 0;
|
|
||||||
|
|
||||||
/* Count windows */
|
|
||||||
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
|
||||||
|
|
||||||
if(n == 0)
|
|
||||||
return;
|
|
||||||
else if(n == 1) { /* Just fill the whole screen */
|
|
||||||
c = nexttiled(m->clients);
|
|
||||||
resize(c, m->wx, m->wy, m->ww - (2*c->bw), m->wh - (2*c->bw), False);
|
|
||||||
} else if(n == 2) { /* Split vertically */
|
|
||||||
w = m->ww / 2;
|
|
||||||
c = nexttiled(m->clients);
|
|
||||||
resize(c, m->wx, m->wy, w - (2*c->bw), m->wh - (2*c->bw), False);
|
|
||||||
c = nexttiled(c->next);
|
|
||||||
resize(c, m->wx + w, m->wy, w - (2*c->bw), m->wh - (2*c->bw), False);
|
|
||||||
} else {
|
|
||||||
ntop = n / 2;
|
|
||||||
nbottom = n - ntop;
|
|
||||||
for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
|
||||||
if(i < ntop)
|
|
||||||
resize(c, m->wx + i * m->ww / ntop, m->wy, m->ww / ntop - (2*c->bw), m->wh / 2 - (2*c->bw), False);
|
|
||||||
else
|
|
||||||
resize(c, m->wx + (i - ntop) * m->ww / nbottom, m->wy + m->wh / 2, m->ww / nbottom - (2*c->bw), m->wh / 2 - (2*c->bw), False);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -25,3 +25,72 @@ grid(Monitor *m) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gaplessgrid(Monitor *m) {
|
||||||
|
unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ;
|
||||||
|
if(n == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* grid dimensions */
|
||||||
|
for(cols = 0; cols <= n/2; cols++)
|
||||||
|
if(cols*cols >= n)
|
||||||
|
break;
|
||||||
|
if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
|
||||||
|
cols = 2;
|
||||||
|
rows = n/cols;
|
||||||
|
|
||||||
|
/* window geometries */
|
||||||
|
cw = cols ? m->ww / cols : m->ww;
|
||||||
|
cn = 0; /* current column number */
|
||||||
|
rn = 0; /* current row number */
|
||||||
|
for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
|
||||||
|
if(i/rows + 1 > cols - n%cols)
|
||||||
|
rows = n/cols + 1;
|
||||||
|
ch = rows ? m->wh / rows : m->wh;
|
||||||
|
cx = m->wx + cn*cw;
|
||||||
|
cy = m->wy + rn*ch;
|
||||||
|
resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
|
||||||
|
rn++;
|
||||||
|
if(rn >= rows) {
|
||||||
|
rn = 0;
|
||||||
|
cn++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
horizgrid(Monitor *m) {
|
||||||
|
Client *c;
|
||||||
|
unsigned int n, i;
|
||||||
|
int w = 0;
|
||||||
|
int ntop, nbottom = 0;
|
||||||
|
|
||||||
|
/* Count windows */
|
||||||
|
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
|
||||||
|
if(n == 0)
|
||||||
|
return;
|
||||||
|
else if(n == 1) { /* Just fill the whole screen */
|
||||||
|
c = nexttiled(m->clients);
|
||||||
|
resize(c, m->wx, m->wy, m->ww - (2*c->bw), m->wh - (2*c->bw), False);
|
||||||
|
} else if(n == 2) { /* Split vertically */
|
||||||
|
w = m->ww / 2;
|
||||||
|
c = nexttiled(m->clients);
|
||||||
|
resize(c, m->wx, m->wy, w - (2*c->bw), m->wh - (2*c->bw), False);
|
||||||
|
c = nexttiled(c->next);
|
||||||
|
resize(c, m->wx + w, m->wy, w - (2*c->bw), m->wh - (2*c->bw), False);
|
||||||
|
} else {
|
||||||
|
ntop = n / 2;
|
||||||
|
nbottom = n - ntop;
|
||||||
|
for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||||
|
if(i < ntop)
|
||||||
|
resize(c, m->wx + i * m->ww / ntop, m->wy, m->ww / ntop - (2*c->bw), m->wh / 2 - (2*c->bw), False);
|
||||||
|
else
|
||||||
|
resize(c, m->wx + (i - ntop) * m->ww / nbottom, m->wy + m->wh / 2, m->ww / nbottom - (2*c->bw), m->wh / 2 - (2*c->bw), False);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
/** Function to shift the current view to the left/right
|
|
||||||
*
|
|
||||||
* @param: "arg->i" stores the number of tags to shift right (positive value)
|
|
||||||
* or left (negative value)
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
shiftview(const Arg *arg) {
|
|
||||||
Arg shifted;
|
|
||||||
|
|
||||||
if(arg->i > 0) // left circular shift
|
|
||||||
shifted.ui = (selmon->tagset[selmon->seltags] << arg->i)
|
|
||||||
| (selmon->tagset[selmon->seltags] >> (LENGTH(tags) - arg->i));
|
|
||||||
|
|
||||||
else // right circular shift
|
|
||||||
shifted.ui = selmon->tagset[selmon->seltags] >> (- arg->i)
|
|
||||||
| selmon->tagset[selmon->seltags] << (LENGTH(tags) + arg->i);
|
|
||||||
|
|
||||||
view(&shifted);
|
|
||||||
}
|
|
BIN
dwm/util.o
BIN
dwm/util.o
Binary file not shown.
Loading…
Reference in a new issue