linux-surface / iptsd

Userspace daemon for Intel Precise Touch & Stylus
GNU General Public License v2.0
86 stars 39 forks source link

d3-zoom won't work #117

Closed danielzgtg closed 1 year ago

danielzgtg commented 1 year ago

My issue there is at https://github.com/d3/d3-zoom/issues/260 .

So xinput list --long shows a non-zero number of touch points. The number might be wrong, but it's not zero:

⎜   ↳ xwayland-touch:12                         id=10   [slave  pointer  (2)]
        Reporting 4 classes:
                Class originated from: 10. Type: XIButtonClass
                Buttons supported: 1
                Button labels: None
                Button state:
                Class originated from: 10. Type: XIValuatorClass
                Detail for Valuator 0:
                  Label: Abs MT Position X
                  Range: 0.000000 - 65535.000000
                  Resolution: 10000 units/m
                  Mode: absolute
                  Current value: 58900.060307
                Class originated from: 10. Type: XIValuatorClass
                Detail for Valuator 1:
                  Label: Abs MT Position Y
                  Range: 0.000000 - 65535.000000
                  Resolution: 10000 units/m
                  Mode: absolute
                  Current value: 25833.149671
                Class originated from: 10. Type: XITouchClass
                Touch mode: direct
                Max number of touches: 20

Both Firefox and Chrome in both Wayland and Xwayland show navigator.maxtouchpoints === 0. That is what d3-zoom reads to enable itself. I don't know if this needs to be fixed in d3-zoom, Firefox, kwin, or iptsd.

StollD commented 1 year ago

Based on a quick grep over the firefox sourcecode, that property doesn't seem to be implemented for linux so it defaults to 0.

A possible solution could be to check for 'ontouchstart' in window, this returns true on my surface and false on my desktop.

StollD commented 1 year ago

Ok, looked a bit deeper, it seems that ontouchstart is a legacy API and firefox will hide it for every address other than chrome://browser/content/blanktab.html.

You can manually enable it by setting dom.w3c_touch_events.legacy_apis.enabled to true, but this actually doesn't do autodetection, it just unconditionally enables the properties as far as I can tell. But it should at least solve your issue with d3-zoom, since it already checks for ontouchstart.

danielzgtg commented 1 year ago

Thank you, setting dom.w3c_touch_events.legacy_apis.enabled = true works. It fixed the problem for me.

I'm also thinking about the other users that will use d3-zoom websites. I don't know whether they will eventually find this information here. For my own websites, I tried window.ontouchstart = null, but seems like one needs to do that for the specific element that d3-zoom uses instead.

The proper solution seems like implementing this navigator.maxtouchpoints for Firefox and Chromium.

StollD commented 1 year ago

Closing this since a workaround has been found and it is not an iptsd issue.