|
|
|
@ -1,30 +1,33 @@
|
|
|
|
|
From 6735c4a1429741ece2c4e417cd67518c8cd5fabe Mon Sep 17 00:00:00 2001
|
|
|
|
|
From 992ec6cae35803aeda3d4481c673fd3fc67c12a2 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: bakkeby <bakkeby@gmail.com>
|
|
|
|
|
Date: Sun, 14 Feb 2021 14:09:56 +0100
|
|
|
|
|
Subject: [PATCH 2/2] f
|
|
|
|
|
Date: Thu, 11 Feb 2021 11:08:32 +0100
|
|
|
|
|
Subject: [PATCH] Adding rio-like draw-to-resize windows.
|
|
|
|
|
|
|
|
|
|
This was backported from instantWM and depends on an external tool
|
|
|
|
|
slop to be installed.
|
|
|
|
|
|
|
|
|
|
Contributed by jzbor.
|
|
|
|
|
---
|
|
|
|
|
config.def.h | 7 +-
|
|
|
|
|
config.def.h | 5 ++
|
|
|
|
|
config.mk | 6 +-
|
|
|
|
|
dwm.c | 238 +++++++++++++++++++++++++++++++++++++++++----------
|
|
|
|
|
3 files changed, 204 insertions(+), 47 deletions(-)
|
|
|
|
|
dwm.c | 237 +++++++++++++++++++++++++++++++++++++++++++++++++--
|
|
|
|
|
3 files changed, 242 insertions(+), 6 deletions(-)
|
|
|
|
|
|
|
|
|
|
diff --git a/config.def.h b/config.def.h
|
|
|
|
|
index cc9e851..d727f3f 100644
|
|
|
|
|
index 1c0b587..d727f3f 100644
|
|
|
|
|
--- a/config.def.h
|
|
|
|
|
+++ b/config.def.h
|
|
|
|
|
@@ -5,7 +5,9 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
|
|
|
|
|
@@ -5,6 +5,9 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
|
|
|
|
|
static const unsigned int snap = 32; /* snap pixel */
|
|
|
|
|
static const int showbar = 1; /* 0 means no bar */
|
|
|
|
|
static const int topbar = 1; /* 0 means bottom bar */
|
|
|
|
|
-static const char slopstyle[] = "-t 0 -c 0.92,0.85,0.69,0.3"; /* do NOT define -f (format) here */
|
|
|
|
|
+static const char slopspawnstyle[] = "-t 0 -c 0.92,0.85,0.69,0.3 -o"; /* do NOT define -f (format) here */
|
|
|
|
|
+static const char slopresizestyle[] = "-t 0 -c 0.92,0.85,0.69,0.3"; /* do NOT define -f (format) here */
|
|
|
|
|
+static const int riodraw_borders = 0; /* 0 or 1, indicates whether the area drawn using slop includes the window borders */
|
|
|
|
|
static const char *fonts[] = { "monospace:size=10" };
|
|
|
|
|
static const char dmenufont[] = "monospace:size=10";
|
|
|
|
|
static const char col_gray1[] = "#222222";
|
|
|
|
|
@@ -64,6 +66,8 @@ static Key keys[] = {
|
|
|
|
|
@@ -63,6 +66,8 @@ static Key keys[] = {
|
|
|
|
|
/* modifier key function argument */
|
|
|
|
|
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
|
|
|
|
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
|
|
|
@ -33,14 +36,6 @@ index cc9e851..d727f3f 100644
|
|
|
|
|
{ MODKEY, XK_b, togglebar, {0} },
|
|
|
|
|
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
|
|
|
|
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
|
|
|
|
@@ -95,7 +99,6 @@ static Key keys[] = {
|
|
|
|
|
TAGKEYS( XK_8, 7)
|
|
|
|
|
TAGKEYS( XK_9, 8)
|
|
|
|
|
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
|
|
|
|
- { MODKEY, XK_s, riodraw, {0} },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* button definitions */
|
|
|
|
|
diff --git a/config.mk b/config.mk
|
|
|
|
|
index 6d36cb7..e65c09a 100644
|
|
|
|
|
--- a/config.mk
|
|
|
|
@ -62,7 +57,7 @@ index 6d36cb7..e65c09a 100644
|
|
|
|
|
# flags
|
|
|
|
|
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
|
|
|
|
diff --git a/dwm.c b/dwm.c
|
|
|
|
|
index dd85686..ad0f2d4 100644
|
|
|
|
|
index 4465af1..78fb7cc 100644
|
|
|
|
|
--- a/dwm.c
|
|
|
|
|
+++ b/dwm.c
|
|
|
|
|
@@ -40,6 +40,12 @@
|
|
|
|
@ -125,11 +120,10 @@ index dd85686..ad0f2d4 100644
|
|
|
|
|
static void keypress(XEvent *e);
|
|
|
|
|
static void killclient(const Arg *arg);
|
|
|
|
|
static void manage(Window w, XWindowAttributes *wa);
|
|
|
|
|
@@ -192,7 +201,10 @@ static void resize(Client *c, int x, int y, int w, int h, int interact);
|
|
|
|
|
@@ -192,6 +201,10 @@ static void resize(Client *c, int x, int y, int w, int h, int interact);
|
|
|
|
|
static void resizeclient(Client *c, int x, int y, int w, int h);
|
|
|
|
|
static void resizemouse(const Arg *arg);
|
|
|
|
|
static void restack(Monitor *m);
|
|
|
|
|
-static void riodraw(const Arg *arg);
|
|
|
|
|
+static void riodraw(const char slopstyle[]);
|
|
|
|
|
+static void rioposition(Client *c, int x, int y, int w, int h);
|
|
|
|
|
+static void rioresize(const Arg *arg);
|
|
|
|
@ -137,7 +131,7 @@ index dd85686..ad0f2d4 100644
|
|
|
|
|
static void run(void);
|
|
|
|
|
static void scan(void);
|
|
|
|
|
static int sendevent(Client *c, Atom proto);
|
|
|
|
|
@@ -207,6 +219,7 @@ static void seturgent(Client *c, int urg);
|
|
|
|
|
@@ -206,6 +219,7 @@ static void seturgent(Client *c, int urg);
|
|
|
|
|
static void showhide(Client *c);
|
|
|
|
|
static void sigchld(int unused);
|
|
|
|
|
static void spawn(const Arg *arg);
|
|
|
|
@ -145,7 +139,7 @@ index dd85686..ad0f2d4 100644
|
|
|
|
|
static void tag(const Arg *arg);
|
|
|
|
|
static void tagmon(const Arg *arg);
|
|
|
|
|
static void tile(Monitor *);
|
|
|
|
|
@@ -228,6 +241,7 @@ static void updatetitle(Client *c);
|
|
|
|
|
@@ -227,6 +241,7 @@ static void updatetitle(Client *c);
|
|
|
|
|
static void updatewindowtype(Client *c);
|
|
|
|
|
static void updatewmhints(Client *c);
|
|
|
|
|
static void view(const Arg *arg);
|
|
|
|
@ -153,7 +147,7 @@ index dd85686..ad0f2d4 100644
|
|
|
|
|
static Client *wintoclient(Window w);
|
|
|
|
|
static Monitor *wintomon(Window w);
|
|
|
|
|
static int xerror(Display *dpy, XErrorEvent *ee);
|
|
|
|
|
@@ -244,6 +258,9 @@ static int bh, blw = 0; /* bar geometry */
|
|
|
|
|
@@ -243,6 +258,9 @@ static int bh, blw = 0; /* bar geometry */
|
|
|
|
|
static int lrpad; /* sum of left and right padding for text */
|
|
|
|
|
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
|
|
|
|
static unsigned int numlockmask = 0;
|
|
|
|
@ -163,7 +157,7 @@ index dd85686..ad0f2d4 100644
|
|
|
|
|
static void (*handler[LASTEvent]) (XEvent *) = {
|
|
|
|
|
[ButtonPress] = buttonpress,
|
|
|
|
|
[ClientMessage] = clientmessage,
|
|
|
|
|
@@ -268,6 +285,7 @@ static Display *dpy;
|
|
|
|
|
@@ -267,6 +285,7 @@ static Display *dpy;
|
|
|
|
|
static Drw *drw;
|
|
|
|
|
static Monitor *mons, *selmon;
|
|
|
|
|
static Window root, wmcheckwin;
|
|
|
|
@ -171,7 +165,7 @@ index dd85686..ad0f2d4 100644
|
|
|
|
|
|
|
|
|
|
/* configuration, allows nested code to access above variables */
|
|
|
|
|
#include "config.h"
|
|
|
|
|
@@ -872,6 +890,39 @@ getatomprop(Client *c, Atom prop)
|
|
|
|
|
@@ -871,6 +890,39 @@ getatomprop(Client *c, Atom prop)
|
|
|
|
|
return atom;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -211,7 +205,7 @@ index dd85686..ad0f2d4 100644
|
|
|
|
|
int
|
|
|
|
|
getrootptr(int *x, int *y)
|
|
|
|
|
{
|
|
|
|
|
@@ -971,6 +1022,15 @@ incnmaster(const Arg *arg)
|
|
|
|
|
@@ -970,6 +1022,15 @@ incnmaster(const Arg *arg)
|
|
|
|
|
arrange(selmon);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -227,7 +221,7 @@ index dd85686..ad0f2d4 100644
|
|
|
|
|
#ifdef XINERAMA
|
|
|
|
|
static int
|
|
|
|
|
isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info)
|
|
|
|
|
@@ -1024,6 +1084,7 @@ manage(Window w, XWindowAttributes *wa)
|
|
|
|
|
@@ -1023,6 +1084,7 @@ manage(Window w, XWindowAttributes *wa)
|
|
|
|
|
|
|
|
|
|
c = ecalloc(1, sizeof(Client));
|
|
|
|
|
c->win = w;
|
|
|
|
@ -235,7 +229,7 @@ index dd85686..ad0f2d4 100644
|
|
|
|
|
/* geometry */
|
|
|
|
|
c->x = c->oldx = wa->x;
|
|
|
|
|
c->y = c->oldy = wa->y;
|
|
|
|
|
@@ -1072,6 +1133,16 @@ manage(Window w, XWindowAttributes *wa)
|
|
|
|
|
@@ -1071,6 +1133,16 @@ manage(Window w, XWindowAttributes *wa)
|
|
|
|
|
if (c->mon == selmon)
|
|
|
|
|
unfocus(selmon->sel, 0);
|
|
|
|
|
c->mon->sel = c;
|
|
|
|
@ -252,83 +246,55 @@ index dd85686..ad0f2d4 100644
|
|
|
|
|
arrange(c->mon);
|
|
|
|
|
XMapWindow(dpy, c->win);
|
|
|
|
|
focus(NULL);
|
|
|
|
|
@@ -1370,36 +1441,30 @@ restack(Monitor *m)
|
|
|
|
|
@@ -1369,6 +1441,99 @@ restack(Monitor *m)
|
|
|
|
|
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-/* drag out an area using slop and resize the selected window to it. */
|
|
|
|
|
void
|
|
|
|
|
-riodraw(const Arg *arg)
|
|
|
|
|
+void
|
|
|
|
|
+riodraw(const char slopstyle[])
|
|
|
|
|
{
|
|
|
|
|
- char str[100];
|
|
|
|
|
int i;
|
|
|
|
|
+{
|
|
|
|
|
+ int i;
|
|
|
|
|
+ char str[100];
|
|
|
|
|
char strout[100];
|
|
|
|
|
- int dimensions[4];
|
|
|
|
|
- int width, height, x, y;
|
|
|
|
|
char tmpstring[30] = {0};
|
|
|
|
|
char slopcmd[100] = "slop -f x%xx%yx%wx%hx ";
|
|
|
|
|
int firstchar = 0;
|
|
|
|
|
int counter = 0;
|
|
|
|
|
- Monitor *m;
|
|
|
|
|
- Client *c;
|
|
|
|
|
|
|
|
|
|
- if (!selmon->sel)
|
|
|
|
|
+ char strout[100];
|
|
|
|
|
+ char tmpstring[30] = {0};
|
|
|
|
|
+ char slopcmd[100] = "slop -f x%xx%yx%wx%hx ";
|
|
|
|
|
+ int firstchar = 0;
|
|
|
|
|
+ int counter = 0;
|
|
|
|
|
+
|
|
|
|
|
+ if (!riopid && !rioclient)
|
|
|
|
|
return;
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ strcat(slopcmd, slopstyle);
|
|
|
|
|
+ FILE *fp = popen(slopcmd, "r");
|
|
|
|
|
+
|
|
|
|
|
strcat(slopcmd, slopstyle);
|
|
|
|
|
FILE *fp = popen(slopcmd, "r");
|
|
|
|
|
|
|
|
|
|
- while (fgets(str, 100, fp) != NULL) {
|
|
|
|
|
+ while (fgets(str, 100, fp) != NULL)
|
|
|
|
|
strcat(strout, str);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
pclose(fp);
|
|
|
|
|
|
|
|
|
|
- if (strlen(strout) < 6) {
|
|
|
|
|
+ strcat(strout, str);
|
|
|
|
|
+
|
|
|
|
|
+ pclose(fp);
|
|
|
|
|
+
|
|
|
|
|
+ if (strlen(strout) < 6)
|
|
|
|
|
return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < strlen(strout); i++){
|
|
|
|
|
if (!firstchar) {
|
|
|
|
|
@@ -1408,42 +1473,65 @@ riodraw(const Arg *arg)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- if (strout[i] != 'x') {
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ for (i = 0; i < strlen(strout); i++){
|
|
|
|
|
+ if (!firstchar) {
|
|
|
|
|
+ if (strout[i] == 'x')
|
|
|
|
|
+ firstchar = 1;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (strout[i] != 'x')
|
|
|
|
|
tmpstring[strlen(tmpstring)] = strout[i];
|
|
|
|
|
- } else {
|
|
|
|
|
- dimensions[counter] = atoi(tmpstring);
|
|
|
|
|
+ tmpstring[strlen(tmpstring)] = strout[i];
|
|
|
|
|
+ else {
|
|
|
|
|
+ riodimensions[counter] = atoi(tmpstring);
|
|
|
|
|
counter++;
|
|
|
|
|
memset(tmpstring,0,strlen(tmpstring));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- x = dimensions[0];
|
|
|
|
|
- y = dimensions[1];
|
|
|
|
|
- width = dimensions[2];
|
|
|
|
|
- height = dimensions[3];
|
|
|
|
|
-
|
|
|
|
|
- if (!selmon->sel)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- c = selmon->sel;
|
|
|
|
|
+ counter++;
|
|
|
|
|
+ memset(tmpstring,0,strlen(tmpstring));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (rioclient)
|
|
|
|
|
+ rioposition(rioclient, riodimensions[0], riodimensions[1], riodimensions[2], riodimensions[3]);
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
- if (width > 50 && height > 50 && x > -40 && y > -40 && width < selmon->mw + 40 && height < selmon->mh + 40 &&
|
|
|
|
|
- (abs(c->w - width) > 20 || abs(c->h - height) > 20 || abs(c->x - x) > 20 || abs(c->y - y) > 20)) {
|
|
|
|
|
- if ((m = recttomon(x, y, width, height)) != selmon) {
|
|
|
|
|
- sendmon(c, m);
|
|
|
|
|
- unfocus(selmon->sel, 0);
|
|
|
|
|
+
|
|
|
|
|
+void
|
|
|
|
|
+rioposition(Client *c, int x, int y, int w, int h)
|
|
|
|
|
+{
|
|
|
|
@ -342,19 +308,10 @@ index dd85686..ad0f2d4 100644
|
|
|
|
|
+ c->tags = m->tagset[m->seltags];
|
|
|
|
|
+ attach(c);
|
|
|
|
|
+ attachstack(c);
|
|
|
|
|
selmon = m;
|
|
|
|
|
- focus(NULL);
|
|
|
|
|
+ selmon = m;
|
|
|
|
|
+ focus(c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- if (!c->isfloating)
|
|
|
|
|
- togglefloating(NULL);
|
|
|
|
|
- resizeclient(c, x, y, width - (c->bw * 2), height - (c->bw * 2));
|
|
|
|
|
- arrange(selmon);
|
|
|
|
|
- } else {
|
|
|
|
|
- fprintf(stderr, "error %s", strout);
|
|
|
|
|
- }
|
|
|
|
|
- memset(tmpstring,0,strlen(tmpstring));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ c->isfloating = 1;
|
|
|
|
|
+ if (riodraw_borders)
|
|
|
|
|
+ resizeclient(c, x, y, w - (c->bw * 2), h - (c->bw * 2));
|
|
|
|
@ -363,7 +320,7 @@ index dd85686..ad0f2d4 100644
|
|
|
|
|
+ drawbar(c->mon);
|
|
|
|
|
+ arrange(c->mon);
|
|
|
|
|
+ } else
|
|
|
|
|
+ fprintf(stderr, "rioposition: refusing to position client %s at x (%d), y (%d), w (%d), h (%d)", c->name, x, y, w, h);
|
|
|
|
|
+ fprintf(stderr, "rioposition: refusing to position client %s at x (%d), y (%d), w (%d), h (%d)\n", c->name, x, y, w, h);
|
|
|
|
|
+
|
|
|
|
|
+ riodimensions[3] = -1;
|
|
|
|
|
+ rioclient = NULL;
|
|
|
|
@ -384,10 +341,12 @@ index dd85686..ad0f2d4 100644
|
|
|
|
|
+{
|
|
|
|
|
+ riopid = spawncmd(arg);;
|
|
|
|
|
+ riodraw(slopspawnstyle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
void
|
|
|
|
|
@@ -1716,9 +1804,16 @@ sigchld(int unused)
|
|
|
|
|
run(void)
|
|
|
|
|
{
|
|
|
|
|
@@ -1639,9 +1804,16 @@ sigchld(int unused)
|
|
|
|
|
void
|
|
|
|
|
spawn(const Arg *arg)
|
|
|
|
|
{
|
|
|
|
@ -405,7 +364,7 @@ index dd85686..ad0f2d4 100644
|
|
|
|
|
if (dpy)
|
|
|
|
|
close(ConnectionNumber(dpy));
|
|
|
|
|
setsid();
|
|
|
|
|
@@ -1727,6 +1822,7 @@ spawn(const Arg *arg)
|
|
|
|
|
@@ -1650,6 +1822,7 @@ spawn(const Arg *arg)
|
|
|
|
|
perror(" failed");
|
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
|
}
|
|
|
|
@ -413,7 +372,7 @@ index dd85686..ad0f2d4 100644
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
@@ -2121,6 +2217,58 @@ view(const Arg *arg)
|
|
|
|
|
@@ -2044,6 +2217,58 @@ view(const Arg *arg)
|
|
|
|
|
arrange(selmon);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -472,7 +431,7 @@ index dd85686..ad0f2d4 100644
|
|
|
|
|
Client *
|
|
|
|
|
wintoclient(Window w)
|
|
|
|
|
{
|
|
|
|
|
@@ -2212,6 +2360,8 @@ main(int argc, char *argv[])
|
|
|
|
|
@@ -2135,6 +2360,8 @@ main(int argc, char *argv[])
|
|
|
|
|
fputs("warning: no locale support\n", stderr);
|
|
|
|
|
if (!(dpy = XOpenDisplay(NULL)))
|
|
|
|
|
die("dwm: cannot open display");
|
|
|
|
|