]> git.lizzy.rs Git - plan9front.git/commitdiff
screenlock: put position check back in grabmouse (thanks deuteron)
authorcinap_lenrek <cinap_lenrek@felloff.net>
Sun, 3 Dec 2017 15:34:35 +0000 (16:34 +0100)
committercinap_lenrek <cinap_lenrek@felloff.net>
Sun, 3 Dec 2017 15:34:35 +0000 (16:34 +0100)
the check was there because changing te position causes another
mouse event to get posted resulting in grabmouse spinning.

sys/src/cmd/screenlock.c

index b010a0c173858f6a67c949c6036055e84a9f024f..8e3e48de8c8b5e824fda47c5cf43c724dce28693 100644 (file)
@@ -91,8 +91,8 @@ blanker(void *)
 void
 grabmouse(void*)
 {
+       int fd, x, y;
        char ibuf[256], obuf[256];
-       int fd;
 
        if((fd = open("/dev/mouse", ORDWR)) < 0)
                sysfatal("can't open /dev/mouse: %r");
@@ -102,9 +102,16 @@ grabmouse(void*)
                screen->r.min.y + Dy(screen->r)/2);
 
        while(read(fd, ibuf, sizeof ibuf) > 0){
-               if(!debug)
-                       fprint(fd, "%s", obuf);
-               blank = time(0);
+               ibuf[12] = 0;
+               ibuf[24] = 0;
+               x = atoi(ibuf+1);
+               y = atoi(ibuf+13);
+               if(x != screen->r.min.x + Dx(screen->r)/2 ||
+                  y != screen->r.min.y + Dy(screen->r)/2){
+                       if(!debug)
+                               fprint(fd, "%s", obuf);
+                       blank = time(0);
+               }
        }
 }