chiark / gitweb /
Sensitivity: Handle sensitivities < 1.0 without rounding errors
[xf86-input-mtrack.git] / src / gestures.c
index 22a94ac15e4271da5d57905261cda469bc3ccd3f..5ee61181ff539e2d8b63f72454311b121b84c8e3 100644 (file)
@@ -210,10 +210,12 @@ static void buttons_update(struct Gestures* gs,
                }
 
                if (emulate) {
-                       int pos = -1;
+                       int try_zone;
+                       int pos;
 
                        if (cfg->button_zones && earliest >= 0) {
                                pos = ms->touch[earliest].x;
+                               try_zone = 1;
                        }
                        if (cfg->bottom_edge_zones) {
                                int latest_bottom = -1;
@@ -227,14 +229,18 @@ static void buttons_update(struct Gestures* gs,
                                        if (latest_bottom == -1 || timercmp(&ms->touch[i].down, &ms->touch[latest_bottom].down, >))
                                                latest_bottom = i;
                                }
-                               if (latest_bottom >= 0)
+                               if (latest_bottom >= 0) {
                                        pos = ms->touch[latest_bottom].x;
+                                       try_zone = 1;
+                               }
                        }
 
-                       if (pos >= 0) {
+                       if (try_zone) {
                                int zones, left, right;
                                double width;
 
+                               pos -= cfg->pad_xmin;
+
                                zones = 0;
                                if (cfg->button_1touch > 0)
                                        zones++;
@@ -246,8 +252,8 @@ static void buttons_update(struct Gestures* gs,
                                if (zones > 0) {
                                        width = ((double)cfg->pad_width)/((double)zones);
 #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);
+                                       xf86Msg(X_INFO, "buttons_update: pad width %d (min %d), zones %d, zone width %f, x %d\n",
+                                               cfg->pad_width, cfg->pad_xmin, zones, width, pos);
 #endif
                                        for (i = 0; i < zones; i++) {
                                                left = width*i;
@@ -408,8 +414,8 @@ static void trigger_move(struct Gestures* gs,
 {
        if ((gs->move_type == GS_MOVE || !timercmp(&gs->time, &gs->move_wait, <)) && (dx != 0 || dy != 0)) {
                if (trigger_drag_start(gs, cfg, dx, dy)) {
-                       gs->move_dx = (int)(dx*cfg->sensitivity);
-                       gs->move_dy = (int)(dy*cfg->sensitivity);
+                       gs->move_dx = (int)(dx*cfg->sensitivity_big);
+                       gs->move_dy = (int)(dy*cfg->sensitivity_big);
                        gs->move_type = GS_MOVE;
                        gs->move_dist = 0;
                        gs->move_dir = TR_NONE;