Assign touch point IDs, for protocol A multitouch drivers that do not
assign IDs themselves.
511581
@Override
    public boolean filter(TouchState state) {
        if (oldState.getPointCount() == 0) {
            for (int i = 0; i < state.getPointCount(); i++) {
                state.getPoint(i).id = acquireID();
            }
        } else if (state.getPointCount() >= oldState.getPointCount()) {
            // For each existing touch point, find the closest pending touch
            // point.
            // mappedIndices contains 0 for every unmapped pending touch point
            // index  and 1 for every pending touch point index that has
            // already been mapped to an existing touch point.
            if (mappedIndices.length < state.getPointCount()) {
                mappedIndices = new int[state.getPointCount()];
            } else {
                Arrays.fill(mappedIndices, 0);
            }
            int mappedIndexCount = 0;
            for (int i = 0; i < oldState.getPointCount(); i++) {
                TouchState.Point oldPoint = oldState.getPoint(i);
                int x = oldPoint.x;
                int y = oldPoint.y;
                int closestDistanceSquared = Integer.MAX_VALUE;
                int mappedIndex = -1;
                for (int j = 0; j < state.getPointCount(); j++) {
                    if (mappedIndices[j] == 0) {
                        TouchState.Point newPoint = state.getPoint(j);
                        int distanceX = x - newPoint.x;
                        int distanceY = y - newPoint.y;
                        int distanceSquared = distanceX * distanceX + distanceY * distanceY;
                        if (distanceSquared < closestDistanceSquared) {
                            mappedIndex = j;
                            closestDistanceSquared = distanceSquared;
                        }
                    }
                }
                assert(mappedIndex >= 0);
                state.getPoint(mappedIndex).id = oldPoint.id;
                mappedIndexCount ++;
                mappedIndices[mappedIndex] = 1;
            }
            if (mappedIndexCount < state.getPointCount()) {
                for (int i = 0; i < state.getPointCount(); i++) {
                    if (mappedIndices[i] == 0) {
                        state.getPoint(i).id = acquireID();
                    }
                }
            }
        } else {
            // There are more existing touch points than pending touch points.
            // For each pending touch point, find the closest existing touch
            // point.
            // mappedIndices contains 0 for every unmapped pre-existing touch
            // index and 1 for every pre-existing touch index that has already
            // been mapped to a pending touch point
            if (mappedIndices.length < oldState.getPointCount()) {
                mappedIndices = new int[oldState.getPointCount()];
            } else {
                Arrays.fill(mappedIndices, 0);
            }
            int mappedIndexCount = 0;
            for (int i = 0; i < state.getPointCount()
                    && mappedIndexCount < oldState.getPointCount(); i++) {
                TouchState.Point newPoint = state.getPoint(i);
                int x = newPoint.x;
                int y = newPoint.y;
                int j;
                int closestDistanceSquared = Integer.MAX_VALUE;
                int mappedIndex = -1;
                for (j = 0; j < oldState.getPointCount(); j++) {
                    if (mappedIndices[j] == 0) {
                        TouchState.Point oldPoint = oldState.getPoint(j);
                        int distanceX = x - oldPoint.x;
                        int distanceY = y - oldPoint.y;
                        int distanceSquared = distanceX * distanceX + distanceY * distanceY;
                        if (distanceSquared < closestDistanceSquared) {
                            mappedIndex = j;
                            closestDistanceSquared = distanceSquared;
                        }
                    }
                }
                assert(mappedIndex >= 0);
                state.getPoint(i).id = oldState.getPoint(mappedIndex).id;
                mappedIndexCount ++;
                mappedIndices[mappedIndex] = 1;
            }
        }
        // Release unused IDs. This can only be done after we have finished
        // assigning all new IDs.
        for (int i = 0; i < oldState.getPointCount(); i++) {
            int id = oldState.getPoint(i).id;
            TouchState.Point p = state.getPointForID(id);
            if (p == null) {
                releaseID(id);
            }
        }
        state.copyTo(oldState);
        return false;
    }
1300800
function (gesture, id) {
                if (this._idList[gesture]) {
                    var element = this._idList[gesture][id];
                    if (gesture == "drag" && element && element == this._activeDrag) {
                        // the element being dragged has been disposed,
                        // terminate the drag:
                        this._dragStartPosition = null;
                        disconnectMouseEvents(this);
                        this._candidateForDrag = null;
                        this._activeDrag = null;
                    }
                    delete this._idList[gesture][id];
                }
            }
128144
def toggleLongTouchPoint(self):
        '''
        
        '''
        if not self.isLongTouchingPoint:
            msg = 'Long touching point'
            self.toast(msg, background=Color.GREEN)
            self.statusBar.set(msg)
            self.isLongTouchingPoint = True
            # FIXME: There should be 2 methods DIP & PX
            self.coordinatesUnit = Unit.PX
        else:
            self.toast(None)
            self.statusBar.clear()
            self.isLongTouchingPoint = False
1156537
def hosting_devices_unassigned_from_cfg_agent(self, context, ids, host):
        
        self._host_notification(context,
                                'hosting_devices_unassigned_from_cfg_agent',
                                {'hosting_device_ids': ids}, host)
275104
private void initInstanceFingerprint() {

        Properties properties = System.getProperties();

        int port = 0;

        // get host
        String host = properties.getProperty("VCAP_APP_HOST");
        if (host == null) {

            InetAddress addr;
            try {
                addr = InetAddress.getLocalHost();
                host = addr.getHostName();
            } catch (UnknownHostException e) {
                LOGGER.info("");
            }

        } else {
            // get port
            try {
                port = Integer.parseInt(properties.getProperty("VCAP_APP_HOST"));
            } catch (Exception e) {
                LOGGER.info("");
            }
        }

        instanceFingerprint = new InstanceFingerprint(host, port, UUID.randomUUID().toString());
    }
718765
function createTouchList(mouseEv) {
  var touchList = TouchList();
  touchList.push(new Touch(eventTarget, 1, mouseEv, 0, 0));
  return touchList;
}
715288
protected void setGestureDetector(@Nullable GestureDetector gestureDetector) {
    mGestureDetector = gestureDetector;
    if (mGestureDetector != null) {
      mGestureDetector.setClickListener(this);
    }
  }
849129
public void setDeviceId(String deviceId) throws CouldNotPersistException {
        this.deviceId = deviceId;
        if (deviceId != null && path != null) {
            persistDeviceId();
        }
    }
271409
function handleTouchMove(e, d) {
            dispatcher.call('customTouchMove', e, d, d3Selection.touch(e));
        }
1067759
def touch(self, connection=None):
        
        self.create_marker_table()

        if connection is None:
            connection = self.connect()

        connection.execute_non_query(
            """IF NOT EXISTS(SELECT 1
                            FROM {marker_table}
                            WHERE update_id = %(update_id)s)
                    INSERT INTO {marker_table} (update_id, target_table)
                        VALUES (%(update_id)s, %(table)s)
                ELSE
                    UPDATE t
                    SET target_table = %(table)s
                        , inserted = GETDATE()
                    FROM {marker_table} t
                    WHERE update_id = %(update_id)s
              """.format(marker_table=self.marker_table),
            {"update_id": self.update_id, "table": self.table})

        # make sure update is properly marked
        assert self.exists(connection)
790448
def _set_boutons_interface(self, buttons):
        """"""
        for id_action, f, d, is_active in buttons:
            icon = self.get_icon(id_action)
            action = self.addAction(QIcon(icon), d)
            action.setEnabled(is_active)
            action.triggered.connect(f)
81964
def set_driver_simulated(self):
        """"""
        self._device_dict["servermain.MULTIPLE_TYPES_DEVICE_DRIVER"] = "Simulator"
        if self._is_sixteen_bit:
            self._device_dict["servermain.DEVICE_MODEL"] = 0
        else:
            self._device_dict["servermain.DEVICE_MODEL"] = 1
        self._device_dict["servermain.DEVICE_ID_OCTAL"] = 1
1251668
void assignPrimaryID() {
        if (pointCount == 0) {
            primaryID = -1;
        } else if (primaryID <= 0) {
            // No primary ID is assigned. Assign a new ID arbitrarily.
            primaryID = points[0].id;
        } else {
            for (int i = 0; i < pointCount; i++) {
                if (points[i].id == primaryID) {
                    // The old primary ID is still valid
                    return;
                }
            }
            // assign a new primary ID
            primaryID = points[0].id;
        }
    }
551115
function (e) {
		var originalEvent = e.originalEvent;
		var clientX;
		var clientY;
		if (originalEvent.touches && originalEvent.touches[0] && !this._clickHandled && !this._touchHandled && !this._disableMarkers) {
			clientX = originalEvent.touches[0].clientX;
			clientY = originalEvent.touches[0].clientY;
			this._disableNewMarkers();
			this._touchHandled = true;
			this._startPoint.call(this, clientX, clientY);
			this._endPoint.call(this, clientX, clientY, e);
			this._touchHandled = null;
		}
		this._clickHandled = null;
	}
610473
def set_wheel_mode(self, ids):
        
        self.set_control_mode(dict(zip(ids, itertools.repeat('wheel'))))
284419
function phantomTouchMove(e) {
    if (e.synthetic) return;

    e.preventDefault();
    e.stopPropagation();

    moveFingers(e);

    if (mouseIsDown) {
      fireTouchEvents('touchmove', e);
    }
  }
244314
def touch(self, connection=None):
        
        self.create_marker_table()

        if connection is None:
            # TODO: test this
            connection = self.connect()
            connection.autocommit = True  # if connection created here, we commit it here

        if self.use_db_timestamps:
            connection.cursor().execute(
                """INSERT INTO {marker_table} (update_id, target_table)
                   VALUES (%s, %s)
                """.format(marker_table=self.marker_table),
                (self.update_id, self.table))
        else:
            connection.cursor().execute(
                """INSERT INTO {marker_table} (update_id, target_table, inserted)
                         VALUES (%s, %s, %s);
                    """.format(marker_table=self.marker_table),
                (self.update_id, self.table,
                 datetime.datetime.now()))