From c0203d2750f2607e8164e62bd51dbb104aa03237 Mon Sep 17 00:00:00 2001 From: ProsperousPotato Date: Mon, 3 Feb 2025 12:32:50 +0000 Subject: i forgot --- config.h | 32 +++++++++++++++++----------- dwm.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 87 insertions(+), 18 deletions(-) diff --git a/config.h b/config.h index 7f10630..9e00f92 100644 --- a/config.h +++ b/config.h @@ -7,12 +7,13 @@ /* appearance */ static const unsigned int borderpx = 2; /* border pixel of windows */ static const unsigned int snap = 16; /* snap pixel */ -static const unsigned int gappx = 4; /* gaps between windows */ +static unsigned int gappx = 4; /* gaps between windows */ +static const int gaplesscount = 3; /* how many windows spawned before gaps appear */ static const int swallowfloating = 1; /* 1 means swallow floating windows by default */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ -static const char *fonts[] = { "CyberpunkWaifus:size=12:autohint=true, fontawesome:size=12" }; -static const char dmenufont[] = "CyberpunkWaifus:size=12:autohint=true, fontawesome:size=12"; +static const char *fonts[] = { "Terminus:pixelsize=12:antialias=true:autohint=true, fontawesome:size=12" }; +static const char dmenufont[] = "Terminus:pixelsize=12:antialias=true:autohint=true, fontawesome:size=12"; static const char col_gray1[] = "#000000"; static const char col_gray2[] = "#bbbbbb"; static const char col_gray3[] = "#4CAF50"; // Not selected @@ -40,6 +41,7 @@ static const Rule rules[] = { */ /* class instance title tags mask isfloating isterminal noswallow monitor */ { "steam", "steamwebhelper", NULL, 0, 1, 0, 0, -1 }, + { "Steam", "Steam", NULL, 0, 1, 0, 0, -1 }, { "steam", "steamwebhelper", "Steam", 0, 0, 0, 0, -1 }, { "steam", NULL, "Steam Settings", 0, 1, 0, 0, -1 }, { "qemu-system-x86_64","qemu-system-x86_64",NULL, 0, 1, 0, 0, -1 }, @@ -53,6 +55,7 @@ static const Rule rules[] = { { "XTerm", "xterm", NULL, 0, 0, 1, 1, -1 }, { "scrcpy", NULL, NULL, 0, 1, 0, 0, -1 }, { "LibreWolf", "Alert", NULL, 0, 1, 0, 0, -1 }, + { "LibreWolf", "Places", "Library", 0, 1, 0, 0, -1 }, { NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, }; @@ -60,7 +63,7 @@ static const Rule rules[] = { static const float mfact = 0.50; /* factor of master area size [0.05..0.95] */ static const int nmaster = 1; /* number of clients in master area */ static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ -static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ +static const int lockfullscreen = 0; /* 1 will force focus on the fullscreen window */ static const Layout layouts[] = { /* symbol arrange function */ @@ -105,8 +108,8 @@ static const Key keys[] = { { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, { MODKEY|ShiftMask, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, - { MODKEY|ShiftMask, XK_Return, setlayout, {0} }, - { MODKEY, XK_Return, togglefloating, {0} }, + // { MODKEY|ShiftMask, XK_Return, setlayout, {0} }, + { Mod1Mask, XK_f, togglefloating, {0} }, { MODKEY, XK_grave, view, {.ui = ~0 } }, { MODKEY|ShiftMask, XK_grave, tag, {.ui = ~0 } }, { MODKEY, XK_comma, focusmon, {.i = -1 } }, @@ -130,13 +133,19 @@ static const Key keys[] = { { MODKEY, XK_f, togglefullscr, {0} }, { MODKEY, XK_BackSpace, hide, {0} }, { MODKEY, XK_a, showall, {0} }, - { MODKEY, XK_g, spawn, SHCMD("dmenu_games") }, + { Mod1Mask|ShiftMask, XK_j, moveresize, {.v = "0x 25y 0w 0h" } }, + { Mod1Mask|ShiftMask, XK_k, moveresize, {.v = "0x -25y 0w 0h" } }, + { Mod1Mask|ShiftMask, XK_l, moveresize, {.v = "25x 0y 0w 0h" } }, + { Mod1Mask|ShiftMask, XK_h, moveresize, {.v = "-25x 0y 0w 0h" } }, + { Mod1Mask|ControlMask, XK_j, moveresize, {.v = "0x 0y 0w 25h" } }, + { Mod1Mask|ControlMask, XK_k, moveresize, {.v = "0x 0y 0w -25h" } }, + { Mod1Mask|ControlMask, XK_l, moveresize, {.v = "0x 0y 25w 0h" } }, + { Mod1Mask|ControlMask, XK_h, moveresize, {.v = "0x 0y -25w 0h" } }, { MODKEY|ShiftMask, XK_m, spawn, SHCMD(TERMINAL" -e neomutt")}, { MODKEY|ShiftMask, XK_n, spawn, SHCMD(TERMINAL" -e nvim")}, { MODKEY, XK_Escape, spawn, SHCMD(TERMINAL" -e htop")}, { MODKEY, XK_n, spawn, SHCMD(TERMINAL" -e newsboat")}, { MODKEY, XK_e, spawn, SHCMD(TERMINAL" -e lfub")}, - { MODKEY|ShiftMask, XK_slash, spawn, SHCMD(TERMINAL" -e menu") }, { MODKEY, XK_Print, spawn, SHCMD("maimpick") }, { MODKEY, XK_Up, spawn, SHCMD("dwmvol up") }, { MODKEY, XK_Down, spawn, SHCMD("dwmvol down") }, @@ -151,18 +160,17 @@ static const Key keys[] = { { MODKEY, XK_F1, spawn, SHCMD("dwmext") }, { MODKEY, XK_F8, spawn, SHCMD("dwmnet") }, { MODKEY, XK_s, spawn, SHCMD("steam") }, + { MODKEY|ShiftMask, XK_s, spawn, SHCMD("pkill -9 steam") }, { Mod1Mask|ControlMask, XK_Delete, spawn, SHCMD("slock") }, { MODKEY, XK_w, spawn, SHCMD("browse "BROWSER) }, { MODKEY, XK_c, spawn, SHCMD("cliphist add") }, { MODKEY, XK_v, spawn, SHCMD("cliphist sel") }, { MODKEY, XK_x, spawn, SHCMD("xkill") }, { MODKEY, XK_h, viewprev, {0} }, - { MODKEY, XK_l, viewnext, {0} }, + { MODKEY, XK_l, viewnext, {0} }, { MODKEY|ShiftMask, XK_h, tagtoprev, {0} }, - { MODKEY|ShiftMask, XK_l, tagtonext, {0} }, + { MODKEY|ShiftMask, XK_l, tagtonext, {0} }, { MODKEY|ShiftMask, XK_r, quit, {1} }, - - /* Unused keys */ }; /* button definitions */ diff --git a/dwm.c b/dwm.c index d426047..5cb4a91 100644 --- a/dwm.c +++ b/dwm.c @@ -201,6 +201,7 @@ static void mappingnotify(XEvent *e); static void maprequest(XEvent *e); static void monocle(Monitor *m); static void motionnotify(XEvent *e); +static void moveresize(const Arg *arg); static void movemouse(const Arg *arg); static unsigned int nexttag(void); static unsigned int prevtag(void); @@ -1324,8 +1325,6 @@ manage(Window w, XWindowAttributes *wa) if (term) { swallow(term, c); } - if (c && c->mon == selmon) - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2); focus(NULL); } @@ -1439,6 +1438,71 @@ movemouse(const Arg *arg) } } +void +moveresize(const Arg *arg) { + Client *c; + c = selmon->sel; + int x, y, w, h, nx, ny, nw, nh, ox, oy, ow, oh; + char xAbs, yAbs, wAbs, hAbs; + int msx, msy, dx, dy, nmx, nmy; + unsigned int dui; + Window dummy; + + if (!c || !arg) + return; + if (selmon->lt[selmon->sellt]->arrange && !c->isfloating) + return; + if (sscanf((char *)arg->v, "%d%c %d%c %d%c %d%c", &x, &xAbs, &y, &yAbs, &w, &wAbs, &h, &hAbs) != 8) + return; + + nw = c->w + w; + if (wAbs == 'W') + nw = w < selmon->mw - 2 * c->bw ? w : selmon->mw - 2 * c->bw; + + nh = c->h + h; + if (hAbs == 'H') + nh = h < selmon->mh - 2 * c->bw ? h : selmon->mh - 2 * c->bw; + + nx = c->x + x; + if (xAbs == 'X') { + if (x < selmon->mx) + nx = selmon->mx; + else if (x > selmon->mx + selmon->mw) + nx = selmon->mx + selmon->mw - nw - 2 * c->bw; + else + nx = x; + } + + ny = c->y + y; + if (yAbs == 'Y') { + if (y < selmon->my) + ny = selmon->my; + else if (y > selmon->my + selmon->mh) + ny = selmon->my + selmon->mh - nh - 2 * c->bw; + else + ny = y; + } + + ox = c->x; + oy = c->y; + ow = c->w; + oh = c->h; + + XRaiseWindow(dpy, c->win); + Bool xqp = XQueryPointer(dpy, root, &dummy, &dummy, &msx, &msy, &dx, &dy, &dui); + resize(c, nx, ny, nw, nh, True); + + /* move cursor along with the window to avoid problems */ + if (xqp && ox <= msx && (ox + ow) >= msx && oy <= msy && (oy + oh) >= msy) + { + nmx = c->x - ox + c->w - ow; + nmy = c->y - oy + c->h - oh; + /* make sure the cursor stays inside the window */ + if ((msx + nmx) > c->x && (msy + nmy) > c->y) + XWarpPointer(dpy, None, None, 0, 0, 0, 0, nmx, nmy); + } +} + unsigned int nexttag(void) { @@ -2079,7 +2143,7 @@ tile(Monitor *m) Client *c; for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - if (n == 1) + if (n <= gaplesscount) m->gappx = 0; else m->gappx = gappx; @@ -2215,9 +2279,6 @@ unmanage(Client *c, int destroyed) focus(NULL); updateclientlist(); } - if (m == selmon && m->sel) - XWarpPointer(dpy, None, m->sel->win, 0, 0, 0, 0, - m->sel->w/2, m->sel->h/2); } void -- cgit v1.2.3