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.

63 lines
1.6 KiB

  1. void
  2. moveresize(const Arg *arg) {
  3. /* only floating windows can be moved */
  4. Client *c;
  5. c = selmon->sel;
  6. int x, y, w, h, nx, ny, nw, nh, ox, oy, ow, oh;
  7. char xAbs, yAbs, wAbs, hAbs;
  8. int msx, msy, dx, dy, nmx, nmy;
  9. unsigned int dui;
  10. Window dummy;
  11. if (!c || !arg)
  12. return;
  13. if (selmon->lt[selmon->sellt]->arrange && !c->isfloating)
  14. return;
  15. if (sscanf((char *)arg->v, "%d%c %d%c %d%c %d%c", &x, &xAbs, &y, &yAbs, &w, &wAbs, &h, &hAbs) != 8)
  16. return;
  17. /* compute new window position; prevent window from be positioned outside the current monitor */
  18. nw = c->w + w;
  19. if (wAbs == 'W')
  20. nw = w < selmon->mw - 2 * c->bw ? w : selmon->mw - 2 * c->bw;
  21. nh = c->h + h;
  22. if (hAbs == 'H')
  23. nh = h < selmon->mh - 2 * c->bw ? h : selmon->mh - 2 * c->bw;
  24. nx = c->x + x;
  25. if (xAbs == 'X') {
  26. if (x < selmon->mx)
  27. nx = selmon->mx;
  28. else if (x > selmon->mx + selmon->mw)
  29. nx = selmon->mx + selmon->mw - nw - 2 * c->bw;
  30. else
  31. nx = x;
  32. }
  33. ny = c->y + y;
  34. if (yAbs == 'Y') {
  35. if (y < selmon->my)
  36. ny = selmon->my;
  37. else if (y > selmon->my + selmon->mh)
  38. ny = selmon->my + selmon->mh - nh - 2 * c->bw;
  39. else
  40. ny = y;
  41. }
  42. ox = c->x;
  43. oy = c->y;
  44. ow = c->w;
  45. oh = c->h;
  46. XRaiseWindow(dpy, c->win);
  47. Bool xqp = XQueryPointer(dpy, root, &dummy, &dummy, &msx, &msy, &dx, &dy, &dui);
  48. resize(c, nx, ny, nw, nh, True);
  49. /* move cursor along with the window to avoid problems caused by the sloppy focus */
  50. if (xqp && ox <= msx && (ox + ow) >= msx && oy <= msy && (oy + oh) >= msy)
  51. {
  52. nmx = c->x - ox + c->w - ow;
  53. nmy = c->y - oy + c->h - oh;
  54. XWarpPointer(dpy, None, None, 0, 0, 0, 0, nmx, nmy);
  55. }
  56. }