diff options
| author | bakkeby <[email protected]> | 2021-02-16 10:26:49 +0100 |
|---|---|---|
| committer | bakkeby <[email protected]> | 2021-02-16 10:26:49 +0100 |
| commit | f5bbd9b4c3b049bb6a74d906e144c1a2e8284337 (patch) | |
| tree | 90bf223611af938a9552ec5921d1b44e3554548d /patch | |
| parent | 009b84cbdc0495807c054564d45c66bda601dd3f (diff) | |
| download | dwm-flexipatch-f5bbd9b4c3b049bb6a74d906e144c1a2e8284337.tar.gz dwm-flexipatch-f5bbd9b4c3b049bb6a74d906e144c1a2e8284337.zip | |
riodraw: upgrading patch to include rio-spawning of windows
Diffstat (limited to 'patch')
| -rw-r--r-- | patch/riodraw.c | 97 | ||||
| -rw-r--r-- | patch/riodraw.h | 6 |
2 files changed, 69 insertions, 34 deletions
diff --git a/patch/riodraw.c b/patch/riodraw.c index 66a7add..b80328f 100644 --- a/patch/riodraw.c +++ b/patch/riodraw.c @@ -1,21 +1,15 @@ /* drag out an area using slop and resize the selected window to it. */ -void -riodraw(const Arg *arg) +int +riodraw(Client *c, const char slopstyle[]) { - char str[100]; 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) - return; strcat(slopcmd, slopstyle); FILE *fp = popen(slopcmd, "r"); @@ -25,7 +19,7 @@ riodraw(const Arg *arg) pclose(fp); if (strlen(strout) < 6) - return; + return 0; for (i = 0; i < strlen(strout); i++){ if (!firstchar) { @@ -37,36 +31,73 @@ riodraw(const Arg *arg) if (strout[i] != 'x') tmpstring[strlen(tmpstring)] = strout[i]; else { - dimensions[counter] = atoi(tmpstring); + riodimensions[counter] = atoi(tmpstring); counter++; memset(tmpstring,0,strlen(tmpstring)); } } - x = dimensions[0]; - y = dimensions[1]; - width = dimensions[2]; - height = dimensions[3]; + if (riodimensions[0] <= -40 || riodimensions[1] <= -40 || riodimensions[2] <= 50 || riodimensions[3] <= 50) { + riodimensions[3] = -1; + return 0; + } - if (!selmon->sel) - return; + if (c) { + rioposition(c, riodimensions[0], riodimensions[1], riodimensions[2], riodimensions[3]); + return 0; + } - c = selmon->sel; + return 1; +} - 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, NULL); - selmon = m; - focus(NULL); - } +void +rioposition(Client *c, int x, int y, int w, int h) +{ + Monitor *m; + if ((m = recttomon(x, y, w, h)) && m != c->mon) { + detach(c); + detachstack(c); + c->mon = m; + c->tags = m->tagset[m->seltags]; + attach(c); + attachstack(c); + 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)); + else + resizeclient(c, x - c->bw, y - c->bw, w, h); + drawbar(c->mon); + arrange(c->mon); + + riodimensions[3] = -1; + riopid = 0; +} + +/* drag out an area using slop and resize the selected window to it */ +void +rioresize(const Arg *arg) +{ + Client *c = (arg && arg->v ? (Client*)arg->v : selmon->sel); + if (c) + riodraw(c, slopresizestyle); +} + +/* Spawn a new window and drag out an area using slop to position it while the window is + * initialising in the background. */ +void +riospawn(const Arg *arg) +{ + riopid = spawncmd(arg); + riodraw(NULL, slopspawnstyle); +} + +void +riospawnsync(const Arg *arg) +{ + if (riodraw(NULL, slopspawnstyle)) + riopid = spawncmd(arg); }
\ No newline at end of file diff --git a/patch/riodraw.h b/patch/riodraw.h index 549da9e..9178804 100644 --- a/patch/riodraw.h +++ b/patch/riodraw.h @@ -1 +1,5 @@ -static void riodraw(const Arg *arg);
\ No newline at end of file +static int riodraw(Client *c, const char slopstyle[]); +static void rioposition(Client *c, int x, int y, int w, int h); +static void rioresize(const Arg *arg); +static void riospawn(const Arg *arg); +static void riospawnsync(const Arg *arg); |
