add dwm-movieresize instead

This commit is contained in:
Sakooooo 2023-08-02 16:52:40 +03:00
parent 58d438314d
commit 2f3565b134
Signed by: sako
GPG key ID: 3FD715D87D7725E0
4 changed files with 206 additions and 7 deletions

View file

@ -111,6 +111,22 @@ static const Key keys[] = {
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_p, setlayout, {0} }, { MODKEY, XK_p, setlayout, {0} },
{ MODKEY|ShiftMask, XK_p, togglefloating, {0} }, { MODKEY|ShiftMask, XK_p, togglefloating, {0} },
{ MODKEY, XK_Down, moveresize, {.v = "0x 25y 0w 0h" } },
{ MODKEY, XK_Up, moveresize, {.v = "0x -25y 0w 0h" } },
{ MODKEY, XK_Right, moveresize, {.v = "25x 0y 0w 0h" } },
{ MODKEY, XK_Left, moveresize, {.v = "-25x 0y 0w 0h" } },
{ MODKEY|ShiftMask, XK_Down, moveresize, {.v = "0x 0y 0w 25h" } },
{ MODKEY|ShiftMask, XK_Up, moveresize, {.v = "0x 0y 0w -25h" } },
{ MODKEY|ShiftMask, XK_Right, moveresize, {.v = "0x 0y 25w 0h" } },
{ MODKEY|ShiftMask, XK_Left, moveresize, {.v = "0x 0y -25w 0h" } },
{ MODKEY|ControlMask, XK_Up, moveresizeedge, {.v = "t"} },
{ MODKEY|ControlMask, XK_Down, moveresizeedge, {.v = "b"} },
{ MODKEY|ControlMask, XK_Left, moveresizeedge, {.v = "l"} },
{ MODKEY|ControlMask, XK_Right, moveresizeedge, {.v = "r"} },
{ MODKEY|ControlMask|ShiftMask, XK_Up, moveresizeedge, {.v = "T"} },
{ MODKEY|ControlMask|ShiftMask, XK_Down, moveresizeedge, {.v = "B"} },
{ MODKEY|ControlMask|ShiftMask, XK_Left, moveresizeedge, {.v = "L"} },
{ MODKEY|ControlMask|ShiftMask, XK_Right, moveresizeedge, {.v = "R"} },
{ MODKEY|ShiftMask, XK_f, togglefullscr, {0} }, { MODKEY|ShiftMask, XK_f, togglefullscr, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } }, { MODKEY, XK_comma, focusmon, {.i = -1 } },

View file

@ -1,8 +1,12 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
/* includes */
#include <X11/XF86keysym.h>
/* appearance */ /* appearance */
static const unsigned int borderpx = 2; /* border pixel of windows */ static const unsigned int borderpx = 2; /* border pixel of windows */
static const unsigned int gappx = 10; /* gaps between windows */ static const unsigned int gappx = 15; /* gaps between windows */
static const unsigned int snap = 32; /* snap pixel */ static const unsigned int snap = 32; /* snap pixel */
static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */ static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */
static const unsigned int systrayonleft = 0; /* 0: systray in the right corner, >0: systray on left of status text */ static const unsigned int systrayonleft = 0; /* 0: systray in the right corner, >0: systray on left of status text */
@ -11,13 +15,14 @@ static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display
static const int showsystray = 1; /* 0 means no systray */ static const int showsystray = 1; /* 0 means no systray */
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 char *fonts[] = { "monospace:size=10" }; static const char *fonts[] = { "JetBrainsMono NF:size=10" };
static const char dmenufont[] = "monospace:size=10"; static const char dmenufont[] = "monospace:size=10";
static const char col_gray1[] = "#222222"; //static const char col_gray1[] = "#222222";
static const char col_gray1[] = "#000000";
static const char col_gray2[] = "#444444"; static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb"; static const char col_gray3[] = "#cccccc";
static const char col_gray4[] = "#eeeeee"; static const char col_gray4[] = "#eeeeee";
static const char col_cyan[] = "#005577"; static const char col_cyan[] = "#770000";
static const char *colors[][3] = { static const char *colors[][3] = {
/* fg bg border */ /* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
@ -25,18 +30,21 @@ static const char *colors[][3] = {
}; };
static const char *const autostart[] = { static const char *const autostart[] = {
"xsetroot", "-cursor_name", "left_ptr", NULL, "xsetroot", "-cursor_name", "Catppuccin-Mocha-Dark", NULL,
"feh", "--bg-scale", "/home/sako/.config/bspwm/background.png", NULL, "feh", "--bg-scale", "/home/sako/.config/bspwm/background.png", NULL,
"dwmblocks", NULL,
"nm-applet", NULL, "nm-applet", NULL,
"blueman-applet", NULL, "blueman-applet", NULL,
"keepassxc", NULL, "keepassxc", NULL,
"flameshot", NULL, "flameshot", NULL,
"discord", NULL,
"transmission-gtk", "-m", NULL,
NULL /* terminate */ NULL /* terminate */
}; };
/* tagging */ /* tagging */
// static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; // static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static const char *tags[] = { "1", "2", "3", "4", "5", "6" }; static const char *tags[] = { "web", "dev", "irc", "media", "game", "misc" };
static const Rule rules[] = { static const Rule rules[] = {
/* xprop(1): /* xprop(1):
@ -46,6 +54,8 @@ static const Rule rules[] = {
/* class instance title tags mask isfloating monitor */ /* class instance title tags mask isfloating monitor */
{ "Gimp", NULL, NULL, 0, 1, -1 }, { "Gimp", NULL, NULL, 0, 1, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 }, { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
{ "discord", NULL, NULL, 1 << 2, 0, -1 },
{ ".blueman-manager-wrapped", NULL, NULL, 0, 1, -1},
}; };
/* layout(s) */ /* layout(s) */
@ -77,6 +87,10 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *roficmd[] = { "rofi", "-show-icons", "-show", "drun", NULL }; static const char *roficmd[] = { "rofi", "-show-icons", "-show", "drun", NULL };
static const char *termcmd[] = { "kitty", NULL }; static const char *termcmd[] = { "kitty", NULL };
// audio
static const char *upvol[] = { "pactl", "set-sink-volume", "0", "+5%", NULL };
static const char *downvol[] = { "pactl", "set-sink-volume", "0", "-5%", NULL };
static const char *mutevol[] = { "pactl", "set-sink-mute", "0", "toggle", NULL };
static const Key keys[] = { static const Key keys[] = {
/* modifier key function argument */ /* modifier key function argument */
@ -97,6 +111,7 @@ static const Key keys[] = {
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_p, setlayout, {0} }, { MODKEY, XK_p, setlayout, {0} },
{ MODKEY|ShiftMask, XK_p, togglefloating, {0} }, { MODKEY|ShiftMask, XK_p, togglefloating, {0} },
{ MODKEY|ShiftMask, XK_f, togglefullscr, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } }, { MODKEY, XK_comma, focusmon, {.i = -1 } },
{ MODKEY, XK_period, focusmon, {.i = +1 } }, { MODKEY, XK_period, focusmon, {.i = +1 } },
@ -105,6 +120,10 @@ static const Key keys[] = {
{ MODKEY, XK_minus, setgaps, {.i = -1 } }, { MODKEY, XK_minus, setgaps, {.i = -1 } },
{ MODKEY, XK_equal, setgaps, {.i = +1 } }, { MODKEY, XK_equal, setgaps, {.i = +1 } },
{ MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } }, { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
// audio
{ 0, XF86XK_AudioLowerVolume, spawn, {.v = downvol } },
{ 0, XF86XK_AudioMute, spawn, {.v = mutevol } },
{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = upvol } },
TAGKEYS( XK_1, 0) TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1) TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2) TAGKEYS( XK_3, 2)

View file

@ -206,6 +206,8 @@ static void mappingnotify(XEvent *e);
static void maprequest(XEvent *e); static void maprequest(XEvent *e);
static void monocle(Monitor *m); static void monocle(Monitor *m);
static void motionnotify(XEvent *e); static void motionnotify(XEvent *e);
static void moveresize(const Arg *arg);
static void moveresizeedge(const Arg *arg);
static void movemouse(const Arg *arg); static void movemouse(const Arg *arg);
static Client *nexttiled(Client *c); static Client *nexttiled(Client *c);
static void pop(Client *c); static void pop(Client *c);
@ -1363,6 +1365,158 @@ movemouse(const Arg *arg)
} }
} }
void
moveresize(const Arg *arg) {
/* only floating windows can be moved */
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;
/* compute new window position; prevent window from be positioned outside the current monitor */
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 caused by the sloppy focus */
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);
}
}
void
moveresizeedge(const Arg *arg) {
/* move or resize floating window to edge of screen */
Client *c;
c = selmon->sel;
char e;
int nx, ny, nw, nh, ox, oy, ow, oh, bp;
int msx, msy, dx, dy, nmx, nmy;
int starty;
unsigned int dui;
Window dummy;
nx = c->x;
ny = c->y;
nw = c->w;
nh = c->h;
starty = selmon->showbar && topbar ? bh : 0;
bp = selmon->showbar && !topbar ? bh : 0;
if (!c || !arg)
return;
if (selmon->lt[selmon->sellt]->arrange && !c->isfloating)
return;
if(sscanf((char *)arg->v, "%c", &e) != 1)
return;
if(e == 't')
ny = starty;
if(e == 'b')
ny = c->h > selmon->mh - 2 * c->bw ? c->h - bp : selmon->mh - c->h - 2 * c->bw - bp;
if(e == 'l')
nx = selmon->mx;
if(e == 'r')
nx = c->w > selmon->mw - 2 * c->bw ? selmon->mx + c->w : selmon->mx + selmon->mw - c->w - 2 * c->bw;
if(e == 'T') {
/* if you click to resize again, it will return to old size/position */
if(c->h + starty == c->oldh + c->oldy) {
nh = c->oldh;
ny = c->oldy;
} else {
nh = c->h + c->y - starty;
ny = starty;
}
}
if(e == 'B')
nh = c->h + c->y + 2 * c->bw + bp == selmon->mh ? c->oldh : selmon->mh - c->y - 2 * c->bw - bp;
if(e == 'L') {
if(selmon->mx + c->w == c->oldw + c->oldx) {
nw = c->oldw;
nx = c->oldx;
} else {
nw = c->w + c->x - selmon->mx;
nx = selmon->mx;
}
}
if(e == 'R')
nw = c->w + c->x + 2 * c->bw == selmon->mx + selmon->mw ? c->oldw : selmon->mx + selmon->mw - c->x - 2 * c->bw;
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);
resizeclient(c, nx, ny, nw, nh);
/* move cursor along with the window to avoid problems caused by the sloppy focus */
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);
}
}
Client * Client *
nexttiled(Client *c) nexttiled(Client *c)
{ {

View file

@ -239,6 +239,7 @@ static void tagmon(const Arg *arg);
static void tile(Monitor *m); static void tile(Monitor *m);
static void togglebar(const Arg *arg); static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg); static void togglefloating(const Arg *arg);
static void togglefullscr(const Arg *arg);
static void toggletag(const Arg *arg); static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg); static void toggleview(const Arg *arg);
static void unfocus(Client *c, int setfocus); static void unfocus(Client *c, int setfocus);
@ -1219,6 +1220,8 @@ manage(Window w, XWindowAttributes *wa)
updatewindowtype(c); updatewindowtype(c);
updatesizehints(c); updatesizehints(c);
updatewmhints(c); updatewmhints(c);
c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2;
c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2;
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)
@ -2012,6 +2015,13 @@ togglefloating(const Arg *arg)
arrange(selmon); arrange(selmon);
} }
void
togglefullscr(const Arg *arg)
{
if(selmon->sel)
setfullscreen(selmon->sel, !selmon->sel->isfullscreen);
}
void void
toggletag(const Arg *arg) toggletag(const Arg *arg)
{ {