chiark / gitweb /
Button zones: Refactor, preparatory to BottomEdgeZones
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 23 Apr 2016 18:51:48 +0000 (19:51 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 26 Apr 2016 19:42:32 +0000 (20:42 +0100)
I intend to add a new feature BottomEdgeZones which reuses the Zone
machinery, but is going to use a different source for the effective X
coordinate which selects the zone.

Break out the computation of `pos'.  pos==-1 means the zone feature is
not in use or not applicable to the event.

No functional change in this commit.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/gestures.c

index 208b39a..5922c00 100644 (file)
@@ -210,8 +210,14 @@ static void buttons_update(struct Gestures* gs,
                }
 
                if (emulate) {
+                       int pos = -1;
+
                        if (cfg->button_zones && earliest >= 0) {
-                               int zones, left, right, pos;
+                               pos = ms->touch[earliest].x;
+                       }
+
+                       if (pos >= 0) {
+                               int zones, left, right;
                                double width;
 
                                zones = 0;
@@ -224,7 +230,6 @@ static void buttons_update(struct Gestures* gs,
 
                                if (zones > 0) {
                                        width = ((double)cfg->pad_width)/((double)zones);
-                                       pos = ms->touch[earliest].x;
 #ifdef DEBUG_GESTURES
                                        xf86Msg(X_INFO, "buttons_update: pad width %d, zones %d, zone width %f, x %d\n",
                                                cfg->pad_width, zones, width, pos);