grab.c: don't grab server on sweeps -- fingers crossed!

This commit is contained in:
Iris Lightshard 2021-03-10 00:22:55 -05:00
parent c4a0ea2970
commit 0e0de29de9
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398

17
grab.c
View file

@ -1,4 +1,4 @@
/* Copyright (c) 1994-1996 David Hogan, see README for licence details */ ./* Copyright (c) 1994-1996 David Hogan, see README for licence details */
#include <stdio.h> #include <stdio.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xos.h> #include <X11/Xos.h>
@ -555,6 +555,9 @@ void misleep(int msec) {
select(0, 0, 0, 0, &t); select(0, 0, 0, 0, &t);
} }
/* Not grabbing the server during sweep ops might make Xorg unstable.
-drkste */
int sweepdrag( int sweepdrag(
Client* c, int but, XButtonEvent* e0, BorderOrient bl, Client* c, int but, XButtonEvent* e0, BorderOrient bl,
int (*recalc)(Client*, int, int, BorderOrient, int)) { int (*recalc)(Client*, int, int, BorderOrient, int)) {
@ -578,7 +581,7 @@ int sweepdrag(
getmouse(&cx, &cy, c->screen); getmouse(&cx, &cy, c->screen);
else else
getmouse(&c->x, &c->y, c->screen); getmouse(&c->x, &c->y, c->screen);
XGrabServer(dpy); //XGrabServer(dpy);
if (bl != BorderUnknown) { if (bl != BorderUnknown) {
notmoved = recalc(c, cx, cy, bl, notmoved); notmoved = recalc(c, cx, cy, bl, notmoved);
} }
@ -588,12 +591,12 @@ int sweepdrag(
if (XCheckMaskEvent(dpy, ButtonMask, &ev) == 0) { if (XCheckMaskEvent(dpy, ButtonMask, &ev) == 0) {
getmouse(&rx, &ry, c->screen); getmouse(&rx, &ry, c->screen);
if (rx != cx || ry != cy || ++idle > 300) { if (rx != cx || ry != cy || ++idle > 300) {
drawbound(c, 0); drawbound(c, 1);
if (rx == cx && ry == cy) { if (rx == cx && ry == cy) {
XUngrabServer(dpy); //XUngrabServer(dpy);
XFlush(dpy); XFlush(dpy);
misleep(500); //misleep(500);
XGrabServer(dpy); //XGrabServer(dpy);
idle = 0; idle = 0;
} }
if (e0 || bl != BorderUnknown) if (e0 || bl != BorderUnknown)
@ -614,7 +617,7 @@ int sweepdrag(
case ButtonRelease: case ButtonRelease:
drawbound(c, 0); drawbound(c, 0);
ungrab(e); ungrab(e);
XUngrabServer(dpy); //XUngrabServer(dpy);
if (e->button != but && c->init) if (e->button != but && c->init)
goto bad; goto bad;
if (c->dx < 0) { if (c->dx < 0) {