|
|
|
@ -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);
|
|
|
|
|
}
|