Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.0 KiB

  1. /* drag out an area using slop and resize the selected window to it. */
  2. int
  3. riodraw(Client *c, const char slopstyle[])
  4. {
  5. int i;
  6. char str[100];
  7. char strout[100];
  8. char tmpstring[30] = {0};
  9. char slopcmd[100] = "slop -f x%xx%yx%wx%hx ";
  10. int firstchar = 0;
  11. int counter = 0;
  12. strcat(slopcmd, slopstyle);
  13. FILE *fp = popen(slopcmd, "r");
  14. while (fgets(str, 100, fp) != NULL)
  15. strcat(strout, str);
  16. pclose(fp);
  17. if (strlen(strout) < 6)
  18. return 0;
  19. for (i = 0; i < strlen(strout); i++){
  20. if (!firstchar) {
  21. if (strout[i] == 'x')
  22. firstchar = 1;
  23. continue;
  24. }
  25. if (strout[i] != 'x')
  26. tmpstring[strlen(tmpstring)] = strout[i];
  27. else {
  28. riodimensions[counter] = atoi(tmpstring);
  29. counter++;
  30. memset(tmpstring,0,strlen(tmpstring));
  31. }
  32. }
  33. if (riodimensions[0] <= -40 || riodimensions[1] <= -40 || riodimensions[2] <= 50 || riodimensions[3] <= 50) {
  34. riodimensions[3] = -1;
  35. return 0;
  36. }
  37. if (c) {
  38. rioposition(c, riodimensions[0], riodimensions[1], riodimensions[2], riodimensions[3]);
  39. return 0;
  40. }
  41. return 1;
  42. }
  43. void
  44. rioposition(Client *c, int x, int y, int w, int h)
  45. {
  46. Monitor *m;
  47. if ((m = recttomon(x, y, w, h)) && m != c->mon) {
  48. detach(c);
  49. detachstack(c);
  50. c->mon = m;
  51. c->tags = m->tagset[m->seltags];
  52. attach(c);
  53. attachstack(c);
  54. selmon = m;
  55. focus(c);
  56. }
  57. c->isfloating = 1;
  58. if (riodraw_borders)
  59. resizeclient(c, x, y, w - (c->bw * 2), h - (c->bw * 2));
  60. else
  61. resizeclient(c, x - c->bw, y - c->bw, w, h);
  62. drawbar(c->mon);
  63. arrange(c->mon);
  64. riodimensions[3] = -1;
  65. riopid = 0;
  66. }
  67. /* drag out an area using slop and resize the selected window to it */
  68. void
  69. rioresize(const Arg *arg)
  70. {
  71. Client *c = (arg && arg->v ? (Client*)arg->v : selmon->sel);
  72. if (c)
  73. riodraw(c, slopresizestyle);
  74. }
  75. /* Spawn a new window and drag out an area using slop to position it while the window is
  76. * initialising in the background. */
  77. void
  78. riospawn(const Arg *arg)
  79. {
  80. riopid = spawncmd(arg);
  81. riodraw(NULL, slopspawnstyle);
  82. }
  83. void
  84. riospawnsync(const Arg *arg)
  85. {
  86. if (riodraw(NULL, slopspawnstyle))
  87. riopid = spawncmd(arg);
  88. }