chiark / gitweb /
Button zones: Export bottom_edge_zones in MTRACK_PROP_BUTTON_EMULATE_SETTINGS
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 23 Apr 2016 19:26:53 +0000 (20:26 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 26 Apr 2016 19:42:32 +0000 (20:42 +0100)
For backward compatibility this property can now be either 3 or 4
items.  When we generate it, we generate 4 items, but we accept
setting only 3 items.

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

index 3ded861..59bc993 100644 (file)
@@ -105,7 +105,8 @@ void mprops_init(struct MConfig* cfg, InputInfoPtr local) {
        ivals[0] = cfg->button_zones;
        ivals[1] = cfg->button_move;
        ivals[2] = cfg->button_expire;
-       mprops.button_emulate_settings = atom_init_integer(local->dev, MTRACK_PROP_BUTTON_EMULATE_SETTINGS, 3, ivals, 16);
+       ivals[3] = cfg->bottom_edge_zones;
+       mprops.button_emulate_settings = atom_init_integer(local->dev, MTRACK_PROP_BUTTON_EMULATE_SETTINGS, 4, ivals, 16);
 
        ivals[0] = cfg->button_1touch;
        ivals[1] = cfg->button_2touch;
@@ -271,20 +272,27 @@ int mprops_set_property(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop
                }
        }
        else if (property == mprops.button_emulate_settings) {
-               if (prop->size != 3 || prop->format != 16 || prop->type != XA_INTEGER)
+               if (prop->size < 3 || prop->size > 4 || prop->format != 16 || prop->type != XA_INTEGER)
                        return BadMatch;
 
                ivals16 = (uint16_t*)prop->data;
                if (!VALID_BOOL(ivals16[0]) || !VALID_BOOL(ivals16[1]) || ivals16[2] < 0)
                        return BadMatch;
 
+               if (prop->size >= 4) {
+                       if (!VALID_BOOL(ivals16[3]))
+                               return BadMatch;
+               }
+
                if (!checkonly) {
                        cfg->button_zones = ivals16[0];
                        cfg->button_move = ivals16[1];
                        cfg->button_expire = ivals16[2];
+                       if (prop->size >= 4)
+                               cfg->bottom_edge_zones = ivals16[3];
 #ifdef DEBUG_PROPS
-                       xf86Msg(X_INFO, "mtrack: set button emulate settings to %d %d %d\n",
-                               cfg->button_zones, cfg->button_move, cfg->button_expire);
+                       xf86Msg(X_INFO, "mtrack: set button emulate settings to %d %d %d %d\n",
+                               cfg->button_zones, cfg->button_move, cfg->button_expire, cfg->bottom_edge_zones);
 #endif
                }
        }
index 6672741..236dc8a 100644 (file)
@@ -44,7 +44,7 @@
 #define MTRACK_PROP_PRESSURE "Trackpad Touch Pressure"
 // int, 2 values - enable buttons, has integrated button
 #define MTRACK_PROP_BUTTON_SETTINGS "Trackpad Button Settings"
-// int, 3 values - enable button zones, button move emulation, emulation touch expiration
+// int, 3-4 values - enable button zones, button move emulation, emulation touch expiration[, enable bottom edge zones]
 #define MTRACK_PROP_BUTTON_EMULATE_SETTINGS "Trackpad Button Emulation Settings"
 // int, 3 values - button to emulate with 1 touch, 2 touches, 3 touches
 #define MTRACK_PROP_BUTTON_EMULATE_VALUES "Trackpad Button Emulation Values"