]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/cmd/screenlock.c
merge
[plan9front.git] / sys / src / cmd / screenlock.c
index cbf4b9b8f1471603491be8ac8d600a43a8681446..8e3e48de8c8b5e824fda47c5cf43c724dce28693 100644 (file)
@@ -24,7 +24,7 @@ readline(char *buf, int nbuf)
        int i;
 
        i = 0;
-       while(i < nbuf-1)
+       while(i < nbuf-1){
                if(read(0, &c, 1) != 1 || c == '\04' || c == '\177'){
                        i = 0;
                        break;
@@ -36,6 +36,8 @@ readline(char *buf, int nbuf)
                        i = 0;
                else
                        buf[i++] = c;
+               blank = time(0);
+       }
        buf[i] = '\0';
 }
 
@@ -62,8 +64,6 @@ checkpassword(void)
                        break;
 
                auth_freeAI(ai);
-               blank = time(0);
-
                border(screen, screen->r, 8, display->black, ZP);
                flushimage(display, 1);
        }
@@ -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);
+               }
        }
 }