Sorry for the repetition, it seems that single-touch state
needs the same treatment as MT state when wsmouse is being
reopened. Single-touch state "synchronizes" itself immediately
when the first changes occur, but it may happen that the first
touch after a restart with dirty state won't trigger pointer
motion (if there is no update of the contact count).

The patch reverts wsmouse_mt_init to its previous form, the
input state will now be cleared completely by wsmousedoopen.

OK?


Index: wsmouse.c
===================================================================
RCS file: /cvs/src/sys/dev/wscons/wsmouse.c,v
retrieving revision 1.32
diff -u -p -r1.32 wsmouse.c
--- wsmouse.c   12 Jul 2016 22:02:53 -0000      1.32
+++ wsmouse.c   13 Jul 2016 21:59:01 -0000
@@ -379,6 +379,8 @@ wsmousedoopen(struct wsmouse_softc *sc, 
 {
        sc->sc_base.me_evp = evp;
 
+       wsmouse_input_reset(&sc->input);
+
        /* enable the device, and punt if that's not possible */
        return (*sc->sc_accessops->enable)(sc->sc_accesscookie);
 }
@@ -1266,8 +1268,11 @@ wsmouse_mt_init(struct device *sc, int n
            &((struct wsmouse_softc *) sc)->input;
        int n, size;
 
+       if (num_slots == input->mt.num_slots
+           && (!tracking == ((input->flags & MT_TRACKING) == 0)))
+               return (0);
+
        free_mt_slots(input);
-       memset(&input->mt, 0, sizeof(struct mt_state));
 
        if (tracking)
                input->flags |= MT_TRACKING;
@@ -1375,4 +1380,25 @@ void
 wsmouse_input_cleanup(struct wsmouseinput *input)
 {
        free_mt_slots(input);
+}
+
+void
+wsmouse_input_reset(struct wsmouseinput *input)
+{
+       int num_slots, *matrix;
+       struct mt_slot *slots;
+
+       memset(&input->btn, 0, sizeof(struct btn_state));
+       memset(&input->motion, 0, sizeof(struct motion_state));
+       memset(&input->touch, 0, sizeof(struct touch_state));
+       input->touch.min_pressure = input->params.pressure_hi;
+       if ((num_slots = input->mt.num_slots)) {
+               slots = input->mt.slots;
+               matrix = input->mt.matrix;
+               memset(&input->mt, 0, sizeof(struct mt_state));
+               memset(slots, 0, num_slots * sizeof(struct mt_slot));
+               input->mt.num_slots = num_slots;
+               input->mt.slots = slots;
+               input->mt.matrix = matrix;
+       }
 }
Index: wsmouseinput.h
===================================================================
RCS file: /cvs/src/sys/dev/wscons/wsmouseinput.h,v
retrieving revision 1.1
diff -u -p -r1.1 wsmouseinput.h
--- wsmouseinput.h      30 Mar 2016 23:34:12 -0000      1.1
+++ wsmouseinput.h      13 Jul 2016 21:59:01 -0000
@@ -141,6 +141,7 @@ void wsmouse_init_scaling(struct wsmouse
 
 void wsmouse_input_init(struct wsmouseinput *, struct wseventvar **);
 void wsmouse_input_cleanup(struct wsmouseinput *);
+void wsmouse_input_reset(struct wsmouseinput *);
 
 
 #define FOREACHBIT(v, i) \

Reply via email to