2021-02-11 11:01:08 +00:00
|
|
|
/* drag out an area using slop and resize the selected window to it. */
|
2021-02-16 09:26:49 +00:00
|
|
|
int
|
|
|
|
riodraw(Client *c, const char slopstyle[])
|
2021-02-11 11:01:08 +00:00
|
|
|
{
|
|
|
|
int i;
|
2021-02-16 09:26:49 +00:00
|
|
|
char str[100];
|
2021-02-11 11:01:08 +00:00
|
|
|
char strout[100];
|
|
|
|
char tmpstring[30] = {0};
|
|
|
|
char slopcmd[100] = "slop -f x%xx%yx%wx%hx ";
|
|
|
|
int firstchar = 0;
|
|
|
|
int counter = 0;
|
|
|
|
|
|
|
|
strcat(slopcmd, slopstyle);
|
|
|
|
FILE *fp = popen(slopcmd, "r");
|
|
|
|
|
|
|
|
while (fgets(str, 100, fp) != NULL)
|
|
|
|
strcat(strout, str);
|
|
|
|
|
|
|
|
pclose(fp);
|
|
|
|
|
|
|
|
if (strlen(strout) < 6)
|
2021-02-16 09:26:49 +00:00
|
|
|
return 0;
|
2021-02-11 11:01:08 +00:00
|
|
|
|
|
|
|
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 {
|
2021-02-16 09:26:49 +00:00
|
|
|
riodimensions[counter] = atoi(tmpstring);
|
2021-02-11 11:01:08 +00:00
|
|
|
counter++;
|
|
|
|
memset(tmpstring,0,strlen(tmpstring));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-16 09:26:49 +00:00
|
|
|
if (riodimensions[0] <= -40 || riodimensions[1] <= -40 || riodimensions[2] <= 50 || riodimensions[3] <= 50) {
|
|
|
|
riodimensions[3] = -1;
|
|
|
|
return 0;
|
|
|
|
}
|
2021-02-11 11:01:08 +00:00
|
|
|
|
2021-02-16 09:26:49 +00:00
|
|
|
if (c) {
|
|
|
|
rioposition(c, riodimensions[0], riodimensions[1], riodimensions[2], riodimensions[3]);
|
|
|
|
return 0;
|
|
|
|
}
|
2021-02-11 11:01:08 +00:00
|
|
|
|
2021-02-16 09:26:49 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2021-02-11 11:01:08 +00:00
|
|
|
|
2021-02-16 09:26:49 +00:00
|
|
|
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);
|
2021-07-24 14:56:51 +00:00
|
|
|
arrange(c->mon);
|
2021-02-16 09:26:49 +00:00
|
|
|
c->mon = m;
|
|
|
|
c->tags = m->tagset[m->seltags];
|
|
|
|
attach(c);
|
|
|
|
attachstack(c);
|
|
|
|
selmon = m;
|
|
|
|
focus(c);
|
|
|
|
}
|
2021-02-11 11:01:08 +00:00
|
|
|
|
2021-02-16 09:26:49 +00:00
|
|
|
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);
|
2021-06-14 05:16:17 +00:00
|
|
|
}
|
|
|
|
|