Configuration file for DWM on MacBook Air
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.7 KiB

  1. /*
  2. * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
  3. * See LICENSE file for license details.
  4. */
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <unistd.h>
  8. #include "wm.h"
  9. #define ButtonMask (ButtonPressMask | ButtonReleaseMask)
  10. #define MouseMask (ButtonMask | PointerMotionMask)
  11. void
  12. mresize(Client *c)
  13. {
  14. XEvent ev;
  15. int ocx, ocy;
  16. ocx = c->x;
  17. ocy = c->y;
  18. if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
  19. None, cursor[CurResize], CurrentTime) != GrabSuccess)
  20. return;
  21. XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
  22. for(;;) {
  23. XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
  24. switch(ev.type) {
  25. default: break;
  26. case Expose:
  27. handler[Expose](&ev);
  28. break;
  29. case MotionNotify:
  30. XFlush(dpy);
  31. c->w = abs(ocx - ev.xmotion.x);
  32. c->h = abs(ocy - ev.xmotion.y);
  33. c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
  34. c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
  35. resize(c);
  36. break;
  37. case ButtonRelease:
  38. XUngrabPointer(dpy, CurrentTime);
  39. return;
  40. }
  41. }
  42. }
  43. void
  44. mmove(Client *c)
  45. {
  46. XEvent ev;
  47. int x1, y1, ocx, ocy, di;
  48. unsigned int dui;
  49. Window dummy;
  50. ocx = c->x;
  51. ocy = c->y;
  52. if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
  53. None, cursor[CurMove], CurrentTime) != GrabSuccess)
  54. return;
  55. XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
  56. for(;;) {
  57. XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
  58. switch (ev.type) {
  59. default: break;
  60. case Expose:
  61. handler[Expose](&ev);
  62. break;
  63. case MotionNotify:
  64. XFlush(dpy);
  65. c->x = ocx + (ev.xmotion.x - x1);
  66. c->y = ocy + (ev.xmotion.y - y1);
  67. resize(c);
  68. break;
  69. case ButtonRelease:
  70. XUngrabPointer(dpy, CurrentTime);
  71. return;
  72. }
  73. }
  74. }