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.

81 lines
1.8 KiB

  1. void
  2. dragcfact(const Arg *arg)
  3. {
  4. int prev_x, prev_y, dist_x, dist_y;
  5. float fact;
  6. Client *c;
  7. XEvent ev;
  8. Time lasttime = 0;
  9. if (!(c = selmon->sel))
  10. return;
  11. if (c->isfloating) {
  12. resizemouse(arg);
  13. return;
  14. }
  15. #if !FAKEFULLSCREEN_PATCH
  16. #if FAKEFULLSCREEN_CLIENT_PATCH
  17. if (c->isfullscreen && !c->fakefullscreen) /* no support resizing fullscreen windows by mouse */
  18. return;
  19. #else
  20. if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */
  21. return;
  22. #endif // FAKEFULLSCREEN_CLIENT_PATCH
  23. #endif // !FAKEFULLSCREEN_PATCH
  24. restack(selmon);
  25. if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
  26. None, cursor[CurIronCross]->cursor, CurrentTime) != GrabSuccess)
  27. return;
  28. #if WARP_PATCH
  29. ignore_warp = 1;
  30. #endif // WARP_PATCH
  31. XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2);
  32. prev_x = prev_y = -999999;
  33. do {
  34. XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
  35. switch(ev.type) {
  36. case ConfigureRequest:
  37. case Expose:
  38. case MapRequest:
  39. handler[ev.type](&ev);
  40. break;
  41. case MotionNotify:
  42. if ((ev.xmotion.time - lasttime) <= (1000 / 60))
  43. continue;
  44. lasttime = ev.xmotion.time;
  45. if (prev_x == -999999) {
  46. prev_x = ev.xmotion.x_root;
  47. prev_y = ev.xmotion.y_root;
  48. }
  49. dist_x = ev.xmotion.x - prev_x;
  50. dist_y = ev.xmotion.y - prev_y;
  51. if (abs(dist_x) > abs(dist_y)) {
  52. fact = (float) 4.0 * dist_x / c->mon->ww;
  53. } else {
  54. fact = (float) -4.0 * dist_y / c->mon->wh;
  55. }
  56. if (fact)
  57. setcfact(&((Arg) { .f = fact }));
  58. prev_x = ev.xmotion.x;
  59. prev_y = ev.xmotion.y;
  60. break;
  61. }
  62. } while (ev.type != ButtonRelease);
  63. #if WARP_PATCH
  64. ignore_warp = 0;
  65. #endif // WARP_PATCH
  66. XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2);
  67. XUngrabPointer(dpy, CurrentTime);
  68. while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
  69. }