-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add persistentDeviceId to PointerEvent #495
base: gh-pages
Are you sure you want to change the base?
Conversation
This change proposes the introduction of a new attribute to the PointerEvent interface - deviceId. See: https://github.com/WICG/pointer-event-extensions/blob/main/pointer-event-device-id-explainer.md
Worth adding, for context, #353 |
Happy to take any comments on the changes. The idea is based on that of pointer id; -1 is reserved for invalid ids. In Chromium, 1 is reserved for the mouse pointer (0 is unused); but I left the wording to be similar to the pointerId definition. As long as the deviceId is unique for each device, web devs should not have a problem. |
Made changes to introduce deviceProperties rather than having deviceId on PointerEvent. Rough draft- feedback appreciated |
This change replaces deviceId on the PointerEvent interface with a new interface, deviceProperties. DeviceProperties contains one member, uniqueId, which functionally behaves the same as the outgoing deviceId. Spec: w3c/pointerevents#495 This change also removes the setting of deviceId when creating a PointerCancel event, as there is no current application for device/unique id for a PointerCancel. Bug: 330760871 Change-Id: I0f1a9f7d5589f790d94f498a38bfdf55b6f51073
This change replaces deviceId on the PointerEvent interface with a new interface, deviceProperties. DeviceProperties contains one member, uniqueId, which functionally behaves the same as the outgoing deviceId. Spec: w3c/pointerevents#495 This change also removes the setting of deviceId when creating a PointerCancel event, as there is no current application for device/unique id for a PointerCancel. Bug: 330760871 Change-Id: I0f1a9f7d5589f790d94f498a38bfdf55b6f51073
This change replaces deviceId on the PointerEvent interface with a new interface, deviceProperties. DeviceProperties contains one member, uniqueId, which functionally behaves the same as the outgoing deviceId. Spec: w3c/pointerevents#495 This change also removes the setting of deviceId when creating a PointerCancel event, as there is no current application for device/unique id for a PointerCancel. Bug: 330760871 Change-Id: I0f1a9f7d5589f790d94f498a38bfdf55b6f51073
I guess I don't understand what @flackr means with optional there. These wouldn't be supported by everyone? |
I believe @smaug---- had concerns with growing the PointerEvent structure with a bunch of one-off "optional" attributes, noting the penCustomizationDetails as another one that may be added in the future, and so we reached a consensus on Jan 31st to have @sahirv suggest a representative structure for these special device capabilities. @smaug----, I couldn't find notes covering the concerns you raised in some of the meetings about this, perhaps you could elaborate? I believe @patrickhlauke may have had thoughts as well.
My understanding is this particular API is, at least presently, for a limited set of devices for which the particular pen you are using reports extra data so that it is uniquely identifiable from other pens used on the same touchscreen (see Limitations of Current Hardware. Similarly, the penCustomizationDetails api would have limited hardware devices which provides particular pen customization information. So by "optional" what was meant is likely to be unreported by the majority of hardware. It's of course entirely possible that at some point most new devices will support some of these concepts, and it is certainly also the case that many current devices don't support properties like tangentialPressure, so personally I don't strongly feel that it can't stay flat, however it would also be nice to avoid churn for @sahirv as to where this property belongs. |
I don't think it was just me thinking about having a separate object. But the concern is to have various somewhat similar IDs in the main event interface. That makes the API harder to understand. And conceptually the new ID isn't about the event but about the device. |
But then just prefix them with |
But the point is that it isn't namespacing. The id is about device. It is like element.style.color. That color could live in element, but we have decided to not have it here. |
I think that's a little different as there are many objects that can return |
I don't feel super strongly either, but there just is the risk that adding more and more device specific properties to the event interface itself will make it eventually rather hard to understand, and using it in cases when relevant devices aren't available may be confusing. |
What wasn't quite captured in the minutes was that I suggested a separate struct as a response to the concern which had been raised prior :-). I'm not sure when it was discussed to find the minutes of. I wanted to find something we could agree on.
To clarify, the "device" in this context is the pen, not the touchscreen "device" which itself can sense multiple different pen's each having their own id's (and possibly style in the future). I do think if we were to go back it could be an interesting separation to consistently put the properties which are about the pointer generally rather than its current location in a separate structure, e.g. pointerType, pointerId. You could also argue that coalesced events and predicted events are separate structures, that are just behind functions instead. |
One of the issues I have with this type of design is that |
I don't want to force My humble 2 cents: Could we mandate in the spec that |
@sahirv it's probably possible to do that, but I'm pretty sure https://dom.spec.whatwg.org/#constructing-events doesn't directly support it today. |
…roperties in PointerEventInit, a=testonly Automatic update from web-platform-tests Set null as the default value of deviceProperties in PointerEventInit Previously, the default for deviceProperties in PointerEventInit was undefined; although in chromium a value was set using the default constructor. This CL changes this behaviour such that the default value for deviceProperties is null. The corresponding WPT is updated as well. For further context, please see the discussion here: w3c/pointerevents#495 (comment) Bug: 330760871 Change-Id: I5becf25f76e8b8c4572a783bfba8c1c4f36f8a74 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5526091 Commit-Queue: Sahir Vellani <[email protected]> Reviewed-by: Robert Flack <[email protected]> Cr-Commit-Position: refs/heads/main@{#1298623} -- wpt-commits: aec353e3b1cae190e1c0485b1406ea522f38e661 wpt-pr: 46174
We were discussing this today and one approach which gets rid of the id altogether and also handles the example in the current pr without need to have explicit hashtable around is to have basically an empty DeviceProperties interface (or perhaps it should be called something else), but it is guaranteed that the same object is returned from .deviceProperties for the same device. The value would be null if there isn't a relevant device. Now the web site could attach random properties directly to that object, for example event.deviceProperties?.myFrameworkColor = "#FFFFFFFF"; and that property would stay there, since the deviceProperties object is kept alive. |
@smaug---- Using .deviceProperties to identify a device is a smart idea. But I'm worried that we might need to retrieve more hardware details in future, and that would mean we have to create a new interface for them. WDYT? |
We would just add those properties to the interface. |
My understanding is that .deviceProperties will only be created for the devices with persistent IDs. It's possible that we'll need to collect other hardware properties from the devices that don't have persistent IDs, and as a result, they won't have .deviceProperties instantiated. Is there something I'm overlooking? |
…roperties in PointerEventInit, a=testonly Automatic update from web-platform-tests Set null as the default value of deviceProperties in PointerEventInit Previously, the default for deviceProperties in PointerEventInit was undefined; although in chromium a value was set using the default constructor. This CL changes this behaviour such that the default value for deviceProperties is null. The corresponding WPT is updated as well. For further context, please see the discussion here: w3c/pointerevents#495 (comment) Bug: 330760871 Change-Id: I5becf25f76e8b8c4572a783bfba8c1c4f36f8a74 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5526091 Commit-Queue: Sahir Vellani <[email protected]> Reviewed-by: Robert Flack <[email protected]> Cr-Commit-Position: refs/heads/main@{#1298623} -- wpt-commits: aec353e3b1cae190e1c0485b1406ea522f38e661 wpt-pr: 46174
While discussing the concerns, this seemed like a neat way to avoid having a second identifier with slightly different semantics and a convenient way for developers to use it without having to create a map of their own.
@ogerchikov Yes, that's correct.
If this information is not associated with a uniquely identifiable pointer, then it wouldn't belong in deviceProperties. If it is, then presumably it wouldn't be known until the persistent id was also known, right? |
@annevk how does this proposal look to you? I've just got one question. I'm wondering if there may be properties that will be added in the future that are hardware specific but not dependent on the presence of a hardware id. I don't have access to the USI spec, but what if certain styluses have the capability to support customization but not supply a hardware id? For example, the pointing device may be identified and communicated with based on the pointer id of that stroke. I hope I'm not inventing a problem where there is none; but it just seems like this has the potential to not serve the initial purpose of this pivot - which was housing all device specific properties. |
I'm not sure how it changed since I last commented? I suspect you need to figure out what changes to event construction this requires, but it's prolly doable. It still strikes me as quite a bit of complexity for what is essentially expressible through a getter (and multiple thereof in the future). |
I discussed this with our partners, and they will still need to create an identifier and add it to There are some more hardware specific attribute proposals that would be good candidates for being under @flackr @smaug---- Would love your thoughts :) |
I'm okay with having a property directly on the PointerEvent, but would suggest some better differentiation from |
How does
|
That is quite reasonable. It is long and perhaps weird enough that one wouldn't likely mix that with pointerId. |
@annevk @flackr @mustaqahmed Are you all good with this suggestion and the overall direction we're taking here? |
… 0, a=testonly Automatic update from web-platform-tests Set Invalid DeviceProperties.uniqueId to 0 Replace -1 with 0 for the invalid uniqueId as per recent spec consensus. Spec: w3c/pointerevents#495 Bug: 330760871 Change-Id: I063515535ee0510c89942f16098c6211bafb480c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5463741 Reviewed-by: Robert Flack <[email protected]> Reviewed-by: Mustaq Ahmed <[email protected]> Commit-Queue: Sahir Vellani <[email protected]> Reviewed-by: Olga Gerchikov <[email protected]> Cr-Commit-Position: refs/heads/main@{#1290720} -- wpt-commits: a2bf027ec76e7f183c4f7e3fdcd62d5a0e818598 wpt-pr: 45765
@smaug---- @flackr @mustaqahmed I have updated this PR to introduce |
This change proposes the introduction of a new attribute to the PointerEvent interface - persistentDeviceId. See: https://github.com/WICG/pointer-event-extensions/blob/main/pointer-event-device-id-explainer.md
This pull request is expected to make the 4th iteration of the PointerEvent specification.
Preview | Diff