- commit
- 91b8d679b9d691d3642a01f7e79b10efe19b5c44
- parent
- d18e29bc7a78e8bd6fe81f8edf1fd0f46c5756b8
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2019-10-13 09:10
hardcode mouse
Diffstat
| M | config.def.h | 8 | -------- |
| M | xiwm.c | 204 | +++++++++++++++++++++++++++++-------------------------------- |
2 files changed, 98 insertions, 114 deletions
diff --git a/config.def.h b/config.def.h
@@ -40,11 +40,3 @@ static Key keys[] = {
40 40 { Mod1Mask, XK_Left, setposition, {.i = PLeft } },
41 41 { Mod1Mask, XK_Right, setposition, {.i = PRight } },
42 42 };
43 -1
44 -1 /* button definitions */
45 -1 static Button buttons[] = {
46 -1 /* event mask button function argument */
47 -1 { Mod1Mask, Button1, movemouse, {0} },
48 -1 { Mod1Mask, Button3, resizemouse, {0} },
49 -1 };
50 -1
diff --git a/xiwm.c b/xiwm.c
@@ -39,13 +39,6 @@ typedef union {
39 39 const void *v;
40 40 } Arg;
41 41
42 -1 typedef struct {
43 -1 unsigned int mask;
44 -1 unsigned int button;
45 -1 void (*func)(const Arg *arg);
46 -1 const Arg arg;
47 -1 } Button;
48 -1
49 42 typedef struct Client Client;
50 43 struct Client {
51 44 int x, y, w, h;
@@ -79,8 +72,6 @@ static void viewrel(const Arg *arg);
79 72 static void focusstack(const Arg *arg);
80 73 static void setposition(const Arg *arg);
81 74 static void setmfact(const Arg *arg);
82 -1 static void movemouse(const Arg *arg);
83 -1 static void resizemouse(const Arg *arg);
84 75 static void killclient(const Arg *arg);
85 76 static void quit(const Arg *arg);
86 77 static void spawn(const Arg *arg);
@@ -206,19 +197,19 @@ wintoclient(Window w)
206 197 void
207 198 grabbuttons(Client *c, Bool focused)
208 199 {
209 -1 unsigned int i, j;
-1 200 unsigned int i;
210 201 unsigned int modifiers[] = { 0, LockMask };
211 202
212 203 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
213 204 if (!focused)
214 205 XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
215 206 BUTTONMASK, GrabModeSync, GrabModeSync, None, None);
216 -1 for (i = 0; i < LENGTH(buttons); i++)
217 -1 for (j = 0; j < LENGTH(modifiers); j++)
218 -1 XGrabButton(dpy, buttons[i].button,
219 -1 buttons[i].mask | modifiers[j],
220 -1 c->win, False, BUTTONMASK,
221 -1 GrabModeAsync, GrabModeSync, None, None);
-1 207 for (i = 0; i < LENGTH(modifiers); i++) {
-1 208 XGrabButton(dpy, Button1, Mod1Mask|modifiers[i], c->win,
-1 209 False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
-1 210 XGrabButton(dpy, Button3, Mod1Mask|modifiers[i], c->win,
-1 211 False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
-1 212 }
222 213 }
223 214
224 215 void
@@ -566,9 +557,93 @@ keypress(XEvent *e)
566 557 }
567 558
568 559 void
-1 560 movemouse(void)
-1 561 {
-1 562 int x, y, ocx, ocy, nx, ny, di;
-1 563 unsigned int dui;
-1 564 Client *c;
-1 565 XEvent ev;
-1 566 Time lasttime = 0;
-1 567 Window dummy;
-1 568
-1 569 if (!(c = sel))
-1 570 return;
-1 571 if (c->isfullscreen || c->position != PFloat)
-1 572 return;
-1 573 ocx = c->x;
-1 574 ocy = c->y;
-1 575 if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
-1 576 None, None, CurrentTime) != GrabSuccess)
-1 577 return;
-1 578 if (!XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui))
-1 579 return;
-1 580 do {
-1 581 XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
-1 582 switch(ev.type) {
-1 583 case ConfigureRequest:
-1 584 case MapRequest:
-1 585 handler[ev.type](&ev);
-1 586 break;
-1 587 case MotionNotify:
-1 588 if ((ev.xmotion.time - lasttime) <= (1000 / 60))
-1 589 continue;
-1 590 lasttime = ev.xmotion.time;
-1 591
-1 592 nx = ocx + (ev.xmotion.x - x);
-1 593 ny = ocy + (ev.xmotion.y - y);
-1 594 if (c->position == PFloat)
-1 595 resize(c, nx, ny, c->w, c->h, 1);
-1 596 break;
-1 597 }
-1 598 } while (ev.type != ButtonRelease);
-1 599 XUngrabPointer(dpy, CurrentTime);
-1 600 }
-1 601
-1 602 void
-1 603 resizemouse(void)
-1 604 {
-1 605 int ocx, ocy, nw, nh;
-1 606 Client *c;
-1 607 XEvent ev;
-1 608 Time lasttime = 0;
-1 609
-1 610 if (!(c = sel))
-1 611 return;
-1 612 if (c->isfullscreen || c->position != PFloat)
-1 613 return;
-1 614 ocx = c->x;
-1 615 ocy = c->y;
-1 616 if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
-1 617 None, None, CurrentTime) != GrabSuccess)
-1 618 return;
-1 619 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
-1 620 do {
-1 621 XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
-1 622 switch(ev.type) {
-1 623 case ConfigureRequest:
-1 624 case MapRequest:
-1 625 handler[ev.type](&ev);
-1 626 break;
-1 627 case MotionNotify:
-1 628 if ((ev.xmotion.time - lasttime) <= (1000 / 60))
-1 629 continue;
-1 630 lasttime = ev.xmotion.time;
-1 631
-1 632 nw = MAX(ev.xmotion.x - ocx - 1, 1);
-1 633 nh = MAX(ev.xmotion.y - ocy - 1, 1);
-1 634 if (c->position == PFloat)
-1 635 resize(c, c->x, c->y, nw, nh, 1);
-1 636 break;
-1 637 }
-1 638 } while (ev.type != ButtonRelease);
-1 639 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
-1 640 XUngrabPointer(dpy, CurrentTime);
-1 641 while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
-1 642 }
-1 643
-1 644 void
569 645 buttonpress(XEvent *e)
570 646 {
571 -1 unsigned int i;
572 647 Client *c;
573 648 XButtonPressedEvent *ev = &e->xbutton;
574 649
@@ -577,10 +652,12 @@ buttonpress(XEvent *e)
577 652 if (c->isdock)
578 653 return;
579 654 focus(c);
580 -1 for (i = 0; i < LENGTH(buttons); i++)
581 -1 if (buttons[i].func && buttons[i].button == ev->button
582 -1 && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
583 -1 buttons[i].func(&buttons[i].arg);
-1 655 if (CLEANMASK(Mod1Mask) == CLEANMASK(ev->state)) {
-1 656 if (ev->button == Button1)
-1 657 movemouse();
-1 658 if (ev->button == Button3)
-1 659 resizemouse();
-1 660 }
584 661 }
585 662 }
586 663
@@ -740,91 +817,6 @@ killclient(const Arg *arg)
740 817 }
741 818
742 819 void
743 -1 movemouse(const Arg *arg)
744 -1 {
745 -1 int x, y, ocx, ocy, nx, ny, di;
746 -1 unsigned int dui;
747 -1 Client *c;
748 -1 XEvent ev;
749 -1 Time lasttime = 0;
750 -1 Window dummy;
751 -1
752 -1 if (!(c = sel))
753 -1 return;
754 -1 if (c->isfullscreen || c->position != PFloat)
755 -1 return;
756 -1 ocx = c->x;
757 -1 ocy = c->y;
758 -1 if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
759 -1 None, None, CurrentTime) != GrabSuccess)
760 -1 return;
761 -1 if (!XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui))
762 -1 return;
763 -1 do {
764 -1 XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
765 -1 switch(ev.type) {
766 -1 case ConfigureRequest:
767 -1 case MapRequest:
768 -1 handler[ev.type](&ev);
769 -1 break;
770 -1 case MotionNotify:
771 -1 if ((ev.xmotion.time - lasttime) <= (1000 / 60))
772 -1 continue;
773 -1 lasttime = ev.xmotion.time;
774 -1
775 -1 nx = ocx + (ev.xmotion.x - x);
776 -1 ny = ocy + (ev.xmotion.y - y);
777 -1 if (c->position == PFloat)
778 -1 resize(c, nx, ny, c->w, c->h, 1);
779 -1 break;
780 -1 }
781 -1 } while (ev.type != ButtonRelease);
782 -1 XUngrabPointer(dpy, CurrentTime);
783 -1 }
784 -1
785 -1 void
786 -1 resizemouse(const Arg *arg)
787 -1 {
788 -1 int ocx, ocy, nw, nh;
789 -1 Client *c;
790 -1 XEvent ev;
791 -1 Time lasttime = 0;
792 -1
793 -1 if (!(c = sel))
794 -1 return;
795 -1 if (c->isfullscreen || c->position != PFloat)
796 -1 return;
797 -1 ocx = c->x;
798 -1 ocy = c->y;
799 -1 if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
800 -1 None, None, CurrentTime) != GrabSuccess)
801 -1 return;
802 -1 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
803 -1 do {
804 -1 XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
805 -1 switch(ev.type) {
806 -1 case ConfigureRequest:
807 -1 case MapRequest:
808 -1 handler[ev.type](&ev);
809 -1 break;
810 -1 case MotionNotify:
811 -1 if ((ev.xmotion.time - lasttime) <= (1000 / 60))
812 -1 continue;
813 -1 lasttime = ev.xmotion.time;
814 -1
815 -1 nw = MAX(ev.xmotion.x - ocx - 1, 1);
816 -1 nh = MAX(ev.xmotion.y - ocy - 1, 1);
817 -1 if (c->position == PFloat)
818 -1 resize(c, c->x, c->y, nw, nh, 1);
819 -1 break;
820 -1 }
821 -1 } while (ev.type != ButtonRelease);
822 -1 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
823 -1 XUngrabPointer(dpy, CurrentTime);
824 -1 while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
825 -1 }
826 -1
827 -1 void
828 820 quit(const Arg *arg)
829 821 {
830 822 running = False;