chiark / gitweb /
Sensitivity: Introduce mconfig_get_sensitivity and _set_
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 24 Apr 2016 01:26:27 +0000 (02:26 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 26 Apr 2016 20:06:50 +0000 (21:06 +0100)
In a moment, we are going to make the in-use representation of the
sensitivity more complicated.  We will need accessor methods for use
by the configuration machinery.

Provide these accessor methods now, to reduce noise in the substantive
patch.  For now they just access the single double.

Rename the variable so that we catch all of the references.

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

index 59bc993dd369fd90a099039bfb9cee4f0900fc62..7003dedcecf48fa8dde5bfe2c80eb60b59410e1e 100644 (file)
@@ -91,7 +91,7 @@ void mprops_init(struct MConfig* cfg, InputInfoPtr local) {
        ivals[0] = cfg->trackpad_disable;
        mprops.trackpad_disable = atom_init_integer(local->dev, MTRACK_PROP_TRACKPAD_DISABLE, 1, ivals, 8);
 
-       fvals[0] = (float)cfg->sensitivity;
+       fvals[0] = (float)mconfig_get_sensitivity(cfg);
        mprops.sensitivity = atom_init_float(local->dev, MTRACK_PROP_SENSITIVITY, 1, fvals, mprops.float_type);
 
        ivals[0] = cfg->touch_down;
@@ -231,9 +231,9 @@ int mprops_set_property(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop
                        return BadMatch;
 
                if (!checkonly) {
-                       cfg->sensitivity = fvals[0];
+                       mconfig_set_sensitivity(cfg, fvals[0]);
 #ifdef DEBUG_PROPS
-                       xf86Msg(X_INFO, "mtrack: set sensitivity to %f\n", cfg->sensitivity);
+                       xf86Msg(X_INFO, "mtrack: set sensitivity to %f\n", mconfig_get_sensitivity(cfg));
 #endif
                }
        }
index e14d53c2256d9a6e4c4594d47d2fc28bd6225d5e..fa446351e337468772e3f66cce176ca137b36e7d 100644 (file)
@@ -165,13 +165,23 @@ struct MConfig {
        int drag_timeout;               // How long to wait for a move after tapping? > 0
        int drag_wait;                  // How long to wait before triggering button down? >= 0
        int drag_dist;                  // How far is the finger allowed to move during wait time? >= 0
-       double sensitivity;             // Mouse movement multiplier. >= 0
+       double sensitivity_val;         // Mouse movement multiplier. >= 0
 };
 
 /* Load the MConfig struct with its defaults.
  */
 void mconfig_defaults(struct MConfig* cfg);
 
+/* Set and read ->sensitivity_val
+ *
+ * Configuration code must always use these get/set functions.
+ *
+ * Runtime code which uses the sensitivity to process events is
+ * expected to access the value in cfg directly.
+ */
+void mconfig_set_sensitivity(struct MConfig *cfg, double sensitivity);
+double mconfig_get_sensitivity(const struct MConfig *cfg);
+
 /* Initialize the MConfig struct.
  */
 void mconfig_init(struct MConfig* cfg,
index 867ed81595c25848f0d656aefa477014f9efa0a9..af6d42cc97f89f225e62aa1a3d70b409ad6dae0f 100644 (file)
@@ -414,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_val);
+                       gs->move_dy = (int)(dy*cfg->sensitivity_val);
                        gs->move_type = GS_MOVE;
                        gs->move_dist = 0;
                        gs->move_dir = TR_NONE;
index b68c63cb1429e36a2ac03e55a38164316266ffd3..ca2970130d0edde754922a63c17e63f417451e44 100644 (file)
 
 #include "mconfig.h"
 
+void mconfig_set_sensitivity(struct MConfig *cfg, double sensitivity)
+{
+       cfg->sensitivity_val = sensitivity;
+}
+
+double mconfig_get_sensitivity(const struct MConfig * cfg)
+{
+       return cfg->sensitivity_val;
+}
+
 void mconfig_defaults(struct MConfig* cfg)
 {
        // Configure MTState
@@ -77,7 +87,7 @@ void mconfig_defaults(struct MConfig* cfg)
        cfg->rotate_rt_btn = DEFAULT_ROTATE_RT_BTN;
        cfg->drag_enable = DEFAULT_DRAG_ENABLE;
        cfg->drag_timeout = DEFAULT_DRAG_TIMEOUT;
-       cfg->sensitivity = DEFAULT_SENSITIVITY;
+       mconfig_set_sensitivity(cfg, DEFAULT_SENSITIVITY);
 }
 
 void mconfig_init(struct MConfig* cfg,
@@ -181,6 +191,6 @@ void mconfig_configure(struct MConfig* cfg,
        cfg->drag_dist = MAXVAL(xf86SetIntOption(opts, "TapDragDist", DEFAULT_DRAG_DIST), 0);
        cfg->axis_x_invert = xf86SetBoolOption(opts, "AxisXInvert", DEFAULT_AXIS_X_INVERT);
        cfg->axis_y_invert = xf86SetBoolOption(opts, "AxisYInvert", DEFAULT_AXIS_Y_INVERT);
-       cfg->sensitivity = MAXVAL(xf86SetRealOption(opts, "Sensitivity", DEFAULT_SENSITIVITY), 0);
+       mconfig_set_sensitivity(cfg, MAXVAL(xf86SetRealOption(opts, "Sensitivity", DEFAULT_SENSITIVITY), 0));
 }