Cleanup - remove event WSCONS_EVENT_WSMOUSED_SLEEP, WSCONS_EVENT_WSMOUSED_CLOSE.
authorshadchin <shadchin@openbsd.org>
Sun, 21 Dec 2014 18:23:37 +0000 (18:23 +0000)
committershadchin <shadchin@openbsd.org>
Sun, 21 Dec 2014 18:23:37 +0000 (18:23 +0000)
Do not need it now.

ok mpi@

usr.sbin/wsmoused/wsmoused.c

index eeb4aaf..38071f6 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsmoused.c,v 1.32 2014/05/14 18:23:22 shadchin Exp $ */
+/* $OpenBSD: wsmoused.c,v 1.33 2014/12/21 18:23:37 shadchin Exp $ */
 
 /*
  * Copyright (c) 2001 Jean-Baptiste Marchand, Julien Montagne and Jerome Verdon
@@ -329,24 +329,18 @@ normalize_event(struct wscons_event *event)
 }
 
 /* send a wscons_event to the kernel */
-static int
+static void
 treat_event(struct wscons_event *event)
 {
        struct wscons_event mapped_event;
 
        if (IS_MOTION_EVENT(event->type)) {
                ioctl(mouse.cfd, WSDISPLAYIO_WSMOUSED, event);
-               return 1;
        } else if (IS_BUTTON_EVENT(event->type) &&
            (uint)event->value < MOUSE_MAXBUTTON) {
                mouse_map(event, &mapped_event);
                mouse_click(&mapped_event);
-               return 1;
        }
-       if (event->type == WSCONS_EVENT_WSMOUSED_CLOSE)
-               /* we have to close mouse fd */
-               return 0;
-       return 1;
 }
 
 /* split a full mouse event into multiples wscons events */
@@ -446,56 +440,7 @@ wsmoused(void)
                if (mouse.proto == P_WSCONS) {
                        /* wsmouse supported mouse */
                        read(mouse.mfd, &event, sizeof(event));
-                       res = treat_event(&event);
-                       if (!res) {
-                               /*
-                                * close mouse device and sleep until
-                                * the X server releases it
-                                */
-
-                               struct wscons_event sleeping;
-                               unsigned int tries;
-
-                               /* restore mouse resolution to default value */
-                               res = WSMOUSE_RES_DEFAULT;
-                               ioctl(mouse.mfd, WSMOUSEIO_SRES, &res);
-
-                               close(mouse.mfd);
-                               mouse.mfd = -1;
-
-                               /* sleep until X server releases mouse device */
-                               sleeping.type = WSCONS_EVENT_WSMOUSED_SLEEP;
-                               sleeping.value = 0;
-                               ioctl(mouse.cfd, WSDISPLAYIO_WSMOUSED,
-                                   &sleeping);
-
-                               /*
-                                * Since the X server could still be running
-                                * (e.g. when switching from the graphics
-                                * screen to a virtual text console), it might
-                                * not have freed the device yet.
-                                *
-                                * Try to open the device until it succeeds.
-                                */
-                               tries = 0;
-                               for (;;) {
-                                       if ((mouse.mfd = open(mouse.portname,
-                                           O_RDONLY | O_NONBLOCK, 0)) != -1)
-                                               break;
-
-                                       if (tries < 10) {
-                                               tries++;
-                                               sleep(1);
-                                       } else {
-                                               logwarn("unable to open %s, "
-                                                   "will retry in 10 seconds",
-                                                   mouse.portname);
-                                               sleep(10);
-                                       }
-                               }
-
-                               wsmouse_init();
-                       }
+                       treat_event(&event);
                } else {
                        /* serial mouse (not supported by wsmouse) */
                        res = read(mouse.mfd, &b, 1);