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.

82 lines
1.8 KiB

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