Forked from urbie-mk2/xf86-input-synaptics-1.8.99.1.xf86PostTouchEvent.patch
Created
October 27, 2017 22:50
-
-
Save laapsaap/6fdc43416cdbf078e8bd876c9d61b99c to your computer and use it in GitHub Desktop.
xf86PostTouchEvent back in xf86-input-synaptics-1.8.99.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ru xf86-input-synaptics-1.8.99.1/src/synaptics.c xf86-input-synaptics-1.8.99.1-mod/src/synaptics.c | |
--- xf86-input-synaptics-1.8.99.1/src/synaptics.c 2015-11-25 07:28:43.000000000 +0100 | |
+++ xf86-input-synaptics-1.8.99.1-mod/src/synaptics.c 2016-06-15 14:54:09.961917509 +0200 | |
@@ -1190,7 +1190,8 @@ | |
{ | |
InputInfoPtr pInfo = dev->public.devicePrivate; | |
SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private); | |
- | |
+ int i; | |
+ | |
if (!priv->has_touch) | |
return; | |
@@ -1204,8 +1205,23 @@ | |
priv->has_touch = 0; | |
priv->num_slots = 0; | |
} | |
+ | |
+ // x/y + whatever other MT axes we found | |
+ if (!InitTouchClassDeviceStruct(dev, priv->max_touches, | |
+ XIDependentTouch, | |
+ 2 + priv->num_mt_axes)) { | |
+ xf86IDrvMsg(pInfo, X_ERROR, | |
+ "failed to initialize touch class device\n"); | |
+ priv->has_touch = 0; | |
+ priv->num_slots = 0; | |
+ free(priv->open_slots); | |
+ priv->open_slots = NULL; | |
+ return; | |
+ } | |
+ | |
} | |
+ | |
static int | |
DeviceInit(DeviceIntPtr dev) | |
{ | |
@@ -2979,9 +2995,18 @@ | |
HandleTouches(InputInfoPtr pInfo, struct SynapticsHwState *hw) | |
{ | |
SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private; | |
+ SynapticsParameters *para = &priv->synpara; | |
int new_active_touches = priv->num_active_touches; | |
+ int min_touches = 2; | |
+ Bool restart_touches = FALSE; | |
int i; | |
+ if (para->click_action[F3_CLICK1] || para->tap_action[F3_TAP]) | |
+ min_touches = 4; | |
+ else if (para->click_action[F2_CLICK1] || para->tap_action[F2_TAP] || | |
+ para->scroll_twofinger_vert || para->scroll_twofinger_horiz) | |
+ min_touches = 3; | |
+ | |
/* Count new number of active touches */ | |
for (i = 0; i < hw->num_mt_mask; i++) { | |
if (hw->slot_state[i] == SLOTSTATE_OPEN) | |
@@ -2990,6 +3015,58 @@ | |
new_active_touches--; | |
} | |
+ if (priv->has_semi_mt) | |
+ goto out; | |
+ | |
+ if (priv->num_active_touches < min_touches && | |
+ new_active_touches < min_touches) { | |
+ /* We stayed below number of touches needed to send events */ | |
+ goto out; | |
+ } | |
+ else if (priv->num_active_touches >= min_touches && | |
+ new_active_touches < min_touches) { | |
+ /* We are transitioning to less than the number of touches needed to | |
+ * send events. End all currently open touches. */ | |
+ for (i = 0; i < priv->num_active_touches; i++) { | |
+ int slot = priv->open_slots[i]; | |
+ | |
+ xf86PostTouchEvent(pInfo->dev, slot, XI_TouchEnd, 0, | |
+ hw->mt_mask[slot]); | |
+ } | |
+ | |
+ /* Don't send any more events */ | |
+ goto out; | |
+ } | |
+ else if (priv->num_active_touches < min_touches && | |
+ new_active_touches >= min_touches) { | |
+ /* We are transitioning to more than the number of touches needed to | |
+ * send events. Begin all already open touches. */ | |
+ restart_touches = TRUE; | |
+ for (i = 0; i < priv->num_active_touches; i++) { | |
+ int slot = priv->open_slots[i]; | |
+ | |
+ xf86PostTouchEvent(pInfo->dev, slot, XI_TouchBegin, 0, | |
+ hw->mt_mask[slot]); | |
+ } | |
+ } | |
+ | |
+ /* Send touch begin events for all new touches */ | |
+ for (i = 0; i < hw->num_mt_mask; i++) | |
+ if (hw->slot_state[i] == SLOTSTATE_OPEN) | |
+ xf86PostTouchEvent(pInfo->dev, i, XI_TouchBegin, 0, hw->mt_mask[i]); | |
+ /* Send touch update/end events for all the rest */ | |
+ for (i = 0; i < priv->num_active_touches; i++) { | |
+ int slot = priv->open_slots[i]; | |
+ | |
+ /* Don't send update event if we just reopened the touch above */ | |
+ if (hw->slot_state[slot] == SLOTSTATE_UPDATE && !restart_touches) | |
+ xf86PostTouchEvent(pInfo->dev, slot, XI_TouchUpdate, 0, | |
+ hw->mt_mask[slot]); | |
+ else if (hw->slot_state[slot] == SLOTSTATE_CLOSE) | |
+ xf86PostTouchEvent(pInfo->dev, slot, XI_TouchEnd, 0, | |
+ hw->mt_mask[slot]); | |
+ } | |
+out: | |
UpdateTouchState(pInfo, hw); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment