[PATCH synaptics 06/12] Move scroll button handling out of HandleState.

Peter Hutterer peter.hutterer at who-t.net
Thu May 6 21:41:58 PDT 2010


Again, just to make the code easier to read, no functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/synaptics.c |   44 ++++++++++++++++++++++++++------------------
 1 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/src/synaptics.c b/src/synaptics.c
index 3ce7a30..c3a4ebc 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -2126,6 +2126,30 @@ adjust_state_from_scrollbuttons(const LocalDevicePtr local, struct SynapticsHwSt
     return double_click;
 }
 
+static inline void
+post_button_click(const LocalDevicePtr local, const int button)
+{
+    xf86PostButtonEvent(local->dev, FALSE, button, TRUE, 0, 0);
+    xf86PostButtonEvent(local->dev, FALSE, button, FALSE, 0, 0);
+}
+
+
+static inline void
+post_scroll_events(const LocalDevicePtr local, struct ScrollData scroll)
+{
+    while (scroll.up-- > 0)
+        post_button_click(local, 4);
+
+    while (scroll.down-- > 0)
+        post_button_click(local, 5);
+
+    while (scroll.left-- > 0)
+        post_button_click(local, 6);
+
+    while (scroll.right-- > 0)
+        post_button_click(local, 7);
+}
+
 /*
  * React on changes in the hardware state. This function is called every time
  * the hardware state changes. The return value is used to specify how many
@@ -2260,24 +2284,8 @@ HandleState(LocalDevicePtr local, struct SynapticsHwState *hw)
     /* Process scroll events only if coordinates are
      * in the Synaptics Area
      */
-    if (inside_active_area) {
-        while (scroll.up-- > 0) {
-		xf86PostButtonEvent(local->dev, FALSE, 4, TRUE, 0, 0);
-		xf86PostButtonEvent(local->dev, FALSE, 4, FALSE, 0, 0);
-        }
-        while (scroll.down-- > 0) {
-		xf86PostButtonEvent(local->dev, FALSE, 5, TRUE, 0, 0);
-		xf86PostButtonEvent(local->dev, FALSE, 5, FALSE, 0, 0);
-        }
-        while (scroll.left-- > 0) {
-		xf86PostButtonEvent(local->dev, FALSE, 6, TRUE, 0, 0);
-		xf86PostButtonEvent(local->dev, FALSE, 6, FALSE, 0, 0);
-        }
-        while (scroll.right-- > 0) {
-		xf86PostButtonEvent(local->dev, FALSE, 7, TRUE, 0, 0);
-		xf86PostButtonEvent(local->dev, FALSE, 7, FALSE, 0, 0);
-        }
-    }
+    if (inside_active_area)
+	post_scroll_events(local, scroll);
 
     if (double_click) {
 	int i;
-- 
1.6.6.1



More information about the xorg-devel mailing list