diff options
Diffstat (limited to 'patch')
| -rw-r--r-- | patch/include.c | 3 | ||||
| -rw-r--r-- | patch/include.h | 3 | ||||
| -rw-r--r-- | patch/riodraw.c | 72 | ||||
| -rw-r--r-- | patch/riodraw.h | 1 |
4 files changed, 79 insertions, 0 deletions
diff --git a/patch/include.c b/patch/include.c index 49590a7..6ddb2f9 100644 --- a/patch/include.c +++ b/patch/include.c @@ -197,6 +197,9 @@ #if RESTARTSIG_PATCH #include "restartsig.c" #endif +#if RIODRAW_PATCH +#include "riodraw.c" +#endif #if ROTATESTACK_PATCH #include "rotatestack.c" #endif diff --git a/patch/include.h b/patch/include.h index 8703af1..b3fe1cb 100644 --- a/patch/include.h +++ b/patch/include.h @@ -193,6 +193,9 @@ #if RESTARTSIG_PATCH #include "restartsig.h" #endif +#if RIODRAW_PATCH +#include "riodraw.h" +#endif #if ROTATESTACK_PATCH #include "rotatestack.h" #endif diff --git a/patch/riodraw.c b/patch/riodraw.c new file mode 100644 index 0000000..ace3acc --- /dev/null +++ b/patch/riodraw.c @@ -0,0 +1,72 @@ +/* drag out an area using slop and resize the selected window to it. */ +void +riodraw(const Arg *arg) +{ + char str[100]; + int i; + 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"); + + while (fgets(str, 100, fp) != NULL) + strcat(strout, str); + + pclose(fp); + + if (strlen(strout) < 6) + 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); + 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; + + 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); + } + + 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)); +}
\ No newline at end of file diff --git a/patch/riodraw.h b/patch/riodraw.h new file mode 100644 index 0000000..549da9e --- /dev/null +++ b/patch/riodraw.h @@ -0,0 +1 @@ +static void riodraw(const Arg *arg);
\ No newline at end of file |
