From 9c2a824bf6d037e2f7d36f3514f9f59d669f343c Mon Sep 17 00:00:00 2001 From: Stephen Chandler Paul Date: Mon, 10 Mar 2014 18:25:20 -0400 Subject: [PATCH 1/2] Replace is_inside_anybutton_area with current_button_area Signed-off-by: Stephen Chandler Paul --- src/synaptics.c | 36 ++++++++++++++++-------------------- src/synapticsstr.h | 12 +++++++++++- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/synaptics.c b/src/synaptics.c index f778d39..7cb7870 100644 --- a/src/synaptics.c +++ b/src/synaptics.c @@ -89,15 +89,6 @@ enum EdgeType { LEFT_TOP_EDGE = TOP_EDGE | LEFT_EDGE }; -enum SoftButtonAreas { - BOTTOM_BUTTON_AREA = 0, - BOTTOM_RIGHT_BUTTON_AREA = 0, - BOTTOM_MIDDLE_BUTTON_AREA = 1, - TOP_BUTTON_AREA = 2, - TOP_RIGHT_BUTTON_AREA = 2, - TOP_MIDDLE_BUTTON_AREA = 3 -}; - enum SoftButtonAreaEdges { LEFT = 0, RIGHT = 1, @@ -1033,7 +1024,7 @@ SynapticsReset(SynapticsPrivate * priv) priv->finger_state = FS_UNTOUCHED; priv->last_motion_millis = 0; priv->clickpad_click_millis = 0; - priv->inside_button_area = FALSE; + priv->last_button_area = NO_BUTTON_AREA; priv->tap_state = TS_START; priv->tap_button = 0; priv->tap_button_state = TBS_BUTTON_UP; @@ -1576,12 +1567,15 @@ is_inside_top_or_bottom_button_area(SynapticsParameters * para, int offset, return inside_area; } -static Bool -is_inside_anybutton_area(SynapticsParameters * para, int x, int y) +static enum SoftButtonAreas +current_button_area(SynapticsParameters * para, int x, int y) { - return - is_inside_top_or_bottom_button_area(para, BOTTOM_BUTTON_AREA, x, y) || - is_inside_top_or_bottom_button_area(para, TOP_BUTTON_AREA, x, y); + if (is_inside_top_or_bottom_button_area(para, BOTTOM_BUTTON_AREA, x, y)) + return BOTTOM_BUTTON_AREA; + else if (is_inside_top_or_bottom_button_area(para, TOP_BUTTON_AREA, x, y)) + return TOP_BUTTON_AREA; + else + return NO_BUTTON_AREA; } static CARD32 @@ -3131,13 +3125,15 @@ HandleState(InputInfoPtr pInfo, struct SynapticsHwState *hw, CARD32 now, /* Ignore motion *starting* inside softbuttonareas */ if (priv->finger_state < FS_TOUCHED) - priv->inside_button_area = is_inside_anybutton_area(para, hw->x, hw->y); - /* If we already have a finger down, clear inside_button_area if it goes + priv->last_button_area = current_button_area(para, hw->x, hw->y); + /* If we already have a finger down, clear last_button_area if it goes outside of the softbuttonareas */ - else if (priv->inside_button_area && !is_inside_anybutton_area(para, hw->x, hw->y)) - priv->inside_button_area = FALSE; + else if (priv->last_button_area != NO_BUTTON_AREA && + current_button_area(para, hw->x, hw->y) == NO_BUTTON_AREA) + priv->last_button_area = NO_BUTTON_AREA; - ignore_motion = !using_cumulative_coords && priv->inside_button_area; + ignore_motion = + !using_cumulative_coords && priv->last_button_area != NO_BUTTON_AREA; /* these two just update hw->left, right, etc. */ update_hw_button_state(pInfo, hw, now, &delay); diff --git a/src/synapticsstr.h b/src/synapticsstr.h index 72140c3..8480397 100644 --- a/src/synapticsstr.h +++ b/src/synapticsstr.h @@ -150,6 +150,16 @@ enum TouchpadModel { MODEL_UNIBODY_MACBOOK }; +enum SoftButtonAreas { + NO_BUTTON_AREA = -1, + BOTTOM_BUTTON_AREA = 0, + BOTTOM_RIGHT_BUTTON_AREA = 0, + BOTTOM_MIDDLE_BUTTON_AREA = 1, + TOP_BUTTON_AREA = 2, + TOP_RIGHT_BUTTON_AREA = 2, + TOP_MIDDLE_BUTTON_AREA = 3 +}; + typedef struct _SynapticsParameters { /* Parameter data */ int left_edge, right_edge, top_edge, bottom_edge; /* edge coordinates absolute */ @@ -250,7 +260,7 @@ struct _SynapticsPrivateRec { Bool prev_up; /* Previous up button value, for double click emulation */ enum FingerState finger_state; /* previous finger state */ CARD32 last_motion_millis; /* time of the last motion */ - Bool inside_button_area; /* Inside button area (ignore motion) */ + enum SoftButtonAreas last_button_area; /* Last button area we were in */ int clickpad_click_millis; /* Time of last clickpad click */ enum TapState tap_state; /* State of tap processing */ -- 1.8.3.2