diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2012-04-30 10:47:14 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2012-05-01 12:41:09 +1000 |
commit | cc595bd323aab2b0ef7b41fded2f0b5571cf0a8e (patch) | |
tree | edba9f0eb3ee1d8ec7486259183673c15564c088 | |
parent | e19fff64f76200291c22d6b822bb4e8b06816745 (diff) |
Reset all hardware state on DEVICE_OFF (#49161)
Reset all state on DeviceOff to avoid stuck buttons on resume.
X.Org Bug 49161 <http://bugs.freedesktop.org/show_bug.cgi?id=49161>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
-rw-r--r-- | src/synaptics.c | 36 | ||||
-rw-r--r-- | src/synproto.c | 23 | ||||
-rw-r--r-- | src/synproto.h | 1 |
3 files changed, 59 insertions, 1 deletions
diff --git a/src/synaptics.c b/src/synaptics.c index 51ecda5..935650d 100644 --- a/src/synaptics.c +++ b/src/synaptics.c @@ -1074,6 +1074,39 @@ DeviceOn(DeviceIntPtr dev) return Success; } +static void +SynapticsReset(SynapticsPrivate *priv) +{ + SynapticsResetHwState(priv->hwState); + SynapticsResetHwState(priv->local_hw_state); + SynapticsResetHwState(priv->old_hw_state); + SynapticsResetHwState(priv->comm.hwState); + + memset(priv->move_hist, 0, sizeof(priv->move_hist)); + priv->hyst_center_x = 0; + priv->hyst_center_y = 0; + memset(&priv->scroll, 0, sizeof(priv->scroll)); + priv->count_packet_finger = 0; + priv->finger_state = FS_UNTOUCHED; + priv->last_motion_millis = 0; + priv->tap_state = TS_START; + priv->tap_button = 0; + priv->tap_button_state = TBS_BUTTON_UP; + priv->moving_state = MS_FALSE; + priv->vert_scroll_edge_on = FALSE; + priv->horiz_scroll_edge_on = FALSE; + priv->vert_scroll_twofinger_on = FALSE; + priv->horiz_scroll_twofinger_on = FALSE; + priv->circ_scroll_on = FALSE; + priv->circ_scroll_vert = FALSE; + priv->mid_emu_state = MBE_OFF; + priv->nextRepeat = 0; + priv->lastButtons = 0; + priv->prev_z = 0; + priv->prevFingers = 0; +} + + static Bool DeviceOff(DeviceIntPtr dev) { @@ -1086,7 +1119,8 @@ DeviceOff(DeviceIntPtr dev) if (pInfo->fd != -1) { TimerCancel(priv->timer); xf86RemoveEnabledDevice(pInfo); - SynapticsResetTouchHwState(priv->hwState); + SynapticsReset(priv); + if (priv->proto_ops->DeviceOffHook && !priv->proto_ops->DeviceOffHook(pInfo)) rc = !Success; diff --git a/src/synproto.c b/src/synproto.c index 4f44f4d..cf54c4d 100644 --- a/src/synproto.c +++ b/src/synproto.c @@ -134,6 +134,29 @@ SynapticsCopyHwState(struct SynapticsHwState *dst, } void +SynapticsResetHwState(struct SynapticsHwState *hw) +{ + hw->millis = 0; + hw->x = 0; + hw->y = 0; + hw->z = 0; + hw->cumulative_dx = 0; + hw->cumulative_dy = 0; + hw->numFingers = 0; + hw->fingerWidth = 0; + + hw->left = 0; + hw->right = 0; + hw->up = 0; + hw->down = 0; + + hw->middle = 0; + memset(hw->multi, 0, sizeof(hw->multi)); + + SynapticsResetTouchHwState(hw); +} + +void SynapticsResetTouchHwState(struct SynapticsHwState *hw) { #ifdef HAVE_MULTITOUCH diff --git a/src/synproto.h b/src/synproto.h index e16aeb0..7f80bcd 100644 --- a/src/synproto.h +++ b/src/synproto.h @@ -119,6 +119,7 @@ extern struct SynapticsHwState *SynapticsHwStateAlloc(SynapticsPrivate *priv); extern void SynapticsHwStateFree(struct SynapticsHwState **hw); extern void SynapticsCopyHwState(struct SynapticsHwState *dst, const struct SynapticsHwState *src); +extern void SynapticsResetHwState(struct SynapticsHwState *hw); extern void SynapticsResetTouchHwState(struct SynapticsHwState *hw); extern Bool SynapticsIsSoftButtonAreasValid(int *values); |