transfered to git.noahsw.xyz and added warp

This commit is contained in:
Noah Swerhun 2021-04-19 15:04:27 -05:00
parent 235ef56fae
commit 947e6c080e
8 changed files with 104 additions and 14 deletions

View file

@ -1,7 +1,8 @@
/* See LICENSE file for copyright and license details. */
#define TERMCLASS "st-256color"
#define TERMINAL "/usr/local/bin/st"
#define BROWSER "/usr/bin/waterfox"
/* appearance */
static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int snap = 3; /* snap pixel */
@ -13,8 +14,8 @@ static const unsigned int gappoh = 5; /* horiz outer gap between windo
static const unsigned int gappov = 5; /* vert outer gap between windows and screen edge */
static int smartgaps = 0; /* 1 means no outer gap when there is only one window */
static const int swallowfloating = 0; /* 1 means swallow floating windows by default */
static const char *fonts[] = { "Roboto Mono:size=10", "Joypixels:size=10" };
static const char dmenufont[] = "Roboto Mono:size=10";
static const char *fonts[] = { "Source Code Pro:size=10", "Joypixels:size=10" };
static const char dmenufont[] = "Source Code Pro:size=10";
static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb";
@ -38,7 +39,9 @@ static const Rule rules[] = {
{ "Gimp", NULL, NULL, 0, 1, 0, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 },
{ TERMCLASS, NULL, NULL, 0, 0, 1, 0, -1 },
{ TERMCLASS, NULL, "pulsemixer", 0, 1, 0, 0, -1 },
{ NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */
{ NULL, NULL, "Logon to thinkorswim", 0, 1, 0, 0, -1 }
};
/* layout(s) */
@ -85,14 +88,16 @@ static const Layout layouts[] = {
/* commands */
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 *termcmd[] = { "st", NULL };
static const char *browser[] = { "waterfox-current", NULL };
static const char *termcmd[] = { TERMINAL, NULL };
static const char *browser[] = { BROWSER, NULL };
static const char *passmenu[] = { "passmenu", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, "-l", "5", "-i", NULL };
static const char *scrotselection[] = { "sleep", "0.5", "&&", "scrot", "-s", "~/pics/screenshots/%Y-%m-%d-%s%w%h.jpg", NULL };
static const char *manmenu[] = { "manmenu", NULL };
static const char *manmenu[] = { "/home/noah/.local/bin/manmenu", NULL };
static const char *scrotselection[] = { "/usr/bin/scrot", "-s", "~/pcs/screenshots/%Y-%m-%d-%s%w%h.jpg", NULL };
static const char *upvol[] = { "/usr/bin/pactl", "set-sink-volume", "@DEFAULT_SINK@", "+2%", NULL };
static const char *downvol[] = { "/usr/bin/pactl", "set-sink-volume", "@DEFAULT_SINK@", "-2%", NULL };
static const char *mutevol[] = { "/usr/bin/pactl", "set-sink-mute", "@DEFAULT_SINK@", "toggle", NULL };
static const char *pulsemixer[] = { TERMINAL, "-e", "/usr/bin/pulsemixer", NULL };
static const char *uni[] = { "/home/noah/.local/bin/uni", NULL };
static Key keys[] = {
/* modifier key function argument */
@ -122,7 +127,9 @@ static Key keys[] = {
{ MODKEY, XK_w, spawn, {.v = browser } },
{ MODKEY, XK_p, spawn, {.v = passmenu } },
{ MODKEY, XK_Print, spawn, {.v = scrotselection } },
{ MODKEY, XK_c, spawn, {.v = manmenu } },
{ MODKEY, XK_e, spawn, {.v = pulsemixer } },
{ MODKEY, XK_y, spawn, {.v = manmenu } },
{ MODKEY, XK_r, spawn, {.v = uni } },
{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = upvol } },
{ 0, XF86XK_AudioLowerVolume, spawn, {.v = downvol } },
{ 0, XF86XK_AudioMute, spawn, {.v = mutevol } },

View file

@ -28,7 +28,7 @@ LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-r
# flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os -Wno-unused-function ${INCS} ${CPPFLAGS}
LDFLAGS = ${LIBS}
# Solaris

BIN
drw.o

Binary file not shown.

BIN
dwm

Binary file not shown.

58
dwm-warp-6.2.diff Normal file
View file

@ -0,0 +1,58 @@
diff --git a/dwm.c b/dwm.c
index 4465af1..bf74f60 100644
--- a/dwm.c
+++ b/dwm.c
@@ -227,6 +227,7 @@ static void updatetitle(Client *c);
static void updatewindowtype(Client *c);
static void updatewmhints(Client *c);
static void view(const Arg *arg);
+static void warp(const Client *c);
static Client *wintoclient(Window w);
static Monitor *wintomon(Window w);
static int xerror(Display *dpy, XErrorEvent *ee);
@@ -827,6 +828,7 @@ focusmon(const Arg *arg)
unfocus(selmon->sel, 0);
selmon = m;
focus(NULL);
+ warp(selmon->sel);
}
void
@@ -1367,6 +1369,8 @@ restack(Monitor *m)
}
XSync(dpy, False);
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
+ if (m == selmon && (m->tagset[m->seltags] & m->sel->tags) && selmon->lt[selmon->sellt] != &layouts[2])
+ warp(m->sel);
}
void
@@ -2044,6 +2048,28 @@ view(const Arg *arg)
arrange(selmon);
}
+void
+warp(const Client *c)
+{
+ int x, y;
+
+ if (!c) {
+ XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + selmon->ww/2, selmon->wy + selmon->wh/2);
+ return;
+ }
+
+ if (!getrootptr(&x, &y) ||
+ (x > c->x - c->bw &&
+ y > c->y - c->bw &&
+ x < c->x + c->w + c->bw*2 &&
+ y < c->y + c->h + c->bw*2) ||
+ (y > c->mon->by && y < c->mon->by + bh) ||
+ (c->mon->topbar && !y))
+ return;
+
+ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
+}
+
Client *
wintoclient(Window w)
{

25
dwm.c
View file

@ -240,6 +240,7 @@ static void updatetitle(Client *c);
static void updatewindowtype(Client *c);
static void updatewmhints(Client *c);
static void view(const Arg *arg);
static void warp(const Client *c);
static Client *wintoclient(Window w);
static Monitor *wintomon(Window w);
static int xerror(Display *dpy, XErrorEvent *ee);
@ -904,6 +905,7 @@ focusmon(const Arg *arg)
unfocus(selmon->sel, 0);
selmon = m;
focus(NULL);
warp(selmon->sel);
}
void
@ -1419,6 +1421,8 @@ resizemouse(const Arg *arg)
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
XUngrabPointer(dpy, CurrentTime);
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
if (m == selmon && (m->tagset[m->seltags] & m->sel->tags) && selmon->lt[selmon->sellt] != &layouts[2])
warp(m->sel);
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
sendmon(c, m);
selmon = m;
@ -2245,6 +2249,27 @@ swallowingclient(Window w)
return NULL;
}
void
warp(const Client *c)
{
int x, y;
if (!c) {
XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + selmon->ww/2, selmon->wy + selmon->wh/2);
return;
}
if (!getrootptr(&x, &y) ||
(x > c->x - c->bw &&
y > c->y - c->bw &&
x < c->x + c->w + c->bw*2 &&
y < c->y + c->h + c->bw*2) ||
(y > c->mon->by && y < c->mon->by + bh) ||
(c->mon->topbar && !y))
return;
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
}
Client *
wintoclient(Window w)

BIN
dwm.o

Binary file not shown.

BIN
util.o

Binary file not shown.