~eliasnaur/gio

3 2

Fwd: Support Pinch

Details
Message ID
<CABN121jYNN3rcJNQKaYdWui33hq292ELtWoPdKjaMYpNNxcmFA@mail.gmail.com>
DKIM signature
missing
Download raw message
forward my own msg

---------- Forwarded message ---------
From: Werner Laurensse <werner@alman.ax>
Date: Fri, Mar 5, 2021 at 3:36 PM
Subject: Re: Support Pinch
To: Elias Naur <mail@eliasnaur.com>


In case of a touch screen yes, but a trackpad has no 1 tot 1 mapping
to your screen(s).
The pointer doesn't even move when you do a two finger scroll.
On osx the way you can get the magnitude is by unpacking a ns event
into ns touch and for each
touch you get the normalised position (a tuple with range 0-1 for your
finger position) and the device size
of the detecting instrument (your trackpad).
You could do this hackish thing where you offset the position of each
pointer event based, but I dont think this works well because you get
into situations where the fake position is negative while the pointer
sits in the middle of the app window.
How, in this case, would you actually distinguish between a faked
touch and a touch from a touch screen connected to your mac like a
wacom tablet? Maybe set the source of the event to mouse in case of a
trackpad event.

I have not tested it but I suspect my proposed solution already works
this way in gio for js and windows.
Windows started to set the ctrl key and set the scroll on pich
gesture, for backward compatibility,
after which browser adopted the same behaviour. My suggestion is to do
the same thing for osx.
It remains a hack but probably easier to document and works the same
way for each platform.

On Fri, Mar 5, 2021 at 11:50 AM Elias Naur <mail@eliasnaur.com> wrote:
>
> On Fri Mar 5, 2021 at 06:18, Werner Laurensse wrote:
> > There is another way to support the pinch gesture on trackpads without
> > adding any extra fields to pointer.Event by adding the key.ModCtrl to
> > the Modifiers field and setting Scroll X and Y to equal to
> > magnification.
> >
> > This is also the way most browsers support this functionality in
> > javascript without having access to the trackpad touch events [1] [2]
> > and works on both OSX and Windows.
> >
> > The problem with proving this functionality through a trackpad is that
> > it's touch events don't map directly to the screen and to calculate
> > the magnification there is still a need to track the position of the
> > fingers and the size of the trackpad [3] [4].
> >
> > Then gesture.Pinch can be implemented as a higher level multi touch
> > event without having to stuff the pointer.Event with extra field
> > rarely needed.
> >
> > [1] https://kenneth.io/post/detecting-multi-touch-trackpad-gestures-in-javascript
> > [2] https://bugzilla.mozilla.org/show_bug.cgi?id=1052253
> > [3] https://stackoverflow.com/questions/3573276/know-the-position-of-the-finger-in-the-trackpad-under-mac-os-x
> > [4] https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/HandlingTouchEvents/HandlingTouchEvents.html
>
> I'm not sure what you're proposing. Perhaps I'm being too simplistic,
> but it seems to me that if you can map the fingers to a pixel positions
> inside Gio's widgets, you can compute the implied rotation and scale
> when the fingers move. If so, why do we need to pack the pointer events
> with extra fields or special scroll events?
>
> Elias
Details
Message ID
<C9QBOQLK9JFS.3G28NK5P28BLF@themachine>
In-Reply-To
<CABN121jYNN3rcJNQKaYdWui33hq292ELtWoPdKjaMYpNNxcmFA@mail.gmail.com> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
On Fri Mar 5, 2021 at 15:38, Werner Laurensse wrote:
> In case of a touch screen yes, but a trackpad has no 1 tot 1 mapping
> to your screen(s).
> The pointer doesn't even move when you do a two finger scroll.
> On osx the way you can get the magnitude is by unpacking a ns event
> into ns touch and for each
> touch you get the normalised position (a tuple with range 0-1 for your
> finger position) and the device size
> of the detecting instrument (your trackpad).
> You could do this hackish thing where you offset the position of each
> pointer event based, but I dont think this works well because you get
> into situations where the fake position is negative while the pointer
> sits in the middle of the app window.
> How, in this case, would you actually distinguish between a faked
> touch and a touch from a touch screen connected to your mac like a
> wacom tablet? Maybe set the source of the event to mouse in case of a
> trackpad event.
>

I see, thanks for elaborating the issue for me. You've convinced me that
pinch gestures on trackpads belong in pointer.Event, just as two-finger
scroll does.

I propose we keep it simple and not introduce new pointer.Types; rather,
can we emit pinch events with as pointer.Moves? Then we avoid changing
input routing, and only need to add one or more fields to pointer.Event.

> I have not tested it but I suspect my proposed solution already works
> this way in gio for js and windows.
> Windows started to set the ctrl key and set the scroll on pich
> gesture, for backward compatibility,
> after which browser adopted the same behaviour. My suggestion is to do
> the same thing for osx.
> It remains a hack but probably easier to document and works the same
> way for each platform.
>

I don't think Gio programs need backwards compatibility in this regard.
Additional pointer.Event field should be ok.

> On Fri, Mar 5, 2021 at 11:50 AM Elias Naur <mail@eliasnaur.com> wrote:
> >
> > On Fri Mar 5, 2021 at 06:18, Werner Laurensse wrote:
> > > There is another way to support the pinch gesture on trackpads without
> > > adding any extra fields to pointer.Event by adding the key.ModCtrl to
> > > the Modifiers field and setting Scroll X and Y to equal to
> > > magnification.
> > >
> > > This is also the way most browsers support this functionality in
> > > javascript without having access to the trackpad touch events [1] [2]
> > > and works on both OSX and Windows.
> > >
> > > The problem with proving this functionality through a trackpad is that
> > > it's touch events don't map directly to the screen and to calculate
> > > the magnification there is still a need to track the position of the
> > > fingers and the size of the trackpad [3] [4].
> > >
> > > Then gesture.Pinch can be implemented as a higher level multi touch
> > > event without having to stuff the pointer.Event with extra field
> > > rarely needed.
> > >
> > > [1] https://kenneth.io/post/detecting-multi-touch-trackpad-gestures-in-javascript
> > > [2] https://bugzilla.mozilla.org/show_bug.cgi?id=1052253
> > > [3] https://stackoverflow.com/questions/3573276/know-the-position-of-the-finger-in-the-trackpad-under-mac-os-x
> > > [4] https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/HandlingTouchEvents/HandlingTouchEvents.html
> >
> > I'm not sure what you're proposing. Perhaps I'm being too simplistic,
> > but it seems to me that if you can map the fingers to a pixel positions
> > inside Gio's widgets, you can compute the implied rotation and scale
> > when the fingers move. If so, why do we need to pack the pointer events
> > with extra fields or special scroll events?
> >
> > Elias
Details
Message ID
<CABN121jm9Csb6DZjsSCP_8wzvMarsgp3jA8ap2K1mPahFiqTXg@mail.gmail.com>
In-Reply-To
<C9QBOQLK9JFS.3G28NK5P28BLF@themachine> (view parent)
DKIM signature
missing
Download raw message
To clarify, you want Gio to emit a pointer.Event of type pointer.Move
and set a Magnification field.
Why would an extra type make the routing more complicated, it works
for me without modifying it.
If, a pinch is a move, then we always need to check if magnification
is zero to know it is a real move.

On Sat, Mar 6, 2021 at 3:03 PM Elias Naur <mail@eliasnaur.com> wrote:
>
> On Fri Mar 5, 2021 at 15:38, Werner Laurensse wrote:
> > In case of a touch screen yes, but a trackpad has no 1 tot 1 mapping
> > to your screen(s).
> > The pointer doesn't even move when you do a two finger scroll.
> > On osx the way you can get the magnitude is by unpacking a ns event
> > into ns touch and for each
> > touch you get the normalised position (a tuple with range 0-1 for your
> > finger position) and the device size
> > of the detecting instrument (your trackpad).
> > You could do this hackish thing where you offset the position of each
> > pointer event based, but I dont think this works well because you get
> > into situations where the fake position is negative while the pointer
> > sits in the middle of the app window.
> > How, in this case, would you actually distinguish between a faked
> > touch and a touch from a touch screen connected to your mac like a
> > wacom tablet? Maybe set the source of the event to mouse in case of a
> > trackpad event.
> >
>
> I see, thanks for elaborating the issue for me. You've convinced me that
> pinch gestures on trackpads belong in pointer.Event, just as two-finger
> scroll does.
>
> I propose we keep it simple and not introduce new pointer.Types; rather,
> can we emit pinch events with as pointer.Moves? Then we avoid changing
> input routing, and only need to add one or more fields to pointer.Event.
>
> > I have not tested it but I suspect my proposed solution already works
> > this way in gio for js and windows.
> > Windows started to set the ctrl key and set the scroll on pich
> > gesture, for backward compatibility,
> > after which browser adopted the same behaviour. My suggestion is to do
> > the same thing for osx.
> > It remains a hack but probably easier to document and works the same
> > way for each platform.
> >
>
> I don't think Gio programs need backwards compatibility in this regard.
> Additional pointer.Event field should be ok.
>
> > On Fri, Mar 5, 2021 at 11:50 AM Elias Naur <mail@eliasnaur.com> wrote:
> > >
> > > On Fri Mar 5, 2021 at 06:18, Werner Laurensse wrote:
> > > > There is another way to support the pinch gesture on trackpads without
> > > > adding any extra fields to pointer.Event by adding the key.ModCtrl to
> > > > the Modifiers field and setting Scroll X and Y to equal to
> > > > magnification.
> > > >
> > > > This is also the way most browsers support this functionality in
> > > > javascript without having access to the trackpad touch events [1] [2]
> > > > and works on both OSX and Windows.
> > > >
> > > > The problem with proving this functionality through a trackpad is that
> > > > it's touch events don't map directly to the screen and to calculate
> > > > the magnification there is still a need to track the position of the
> > > > fingers and the size of the trackpad [3] [4].
> > > >
> > > > Then gesture.Pinch can be implemented as a higher level multi touch
> > > > event without having to stuff the pointer.Event with extra field
> > > > rarely needed.
> > > >
> > > > [1] https://kenneth.io/post/detecting-multi-touch-trackpad-gestures-in-javascript
> > > > [2] https://bugzilla.mozilla.org/show_bug.cgi?id=1052253
> > > > [3] https://stackoverflow.com/questions/3573276/know-the-position-of-the-finger-in-the-trackpad-under-mac-os-x
> > > > [4] https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/HandlingTouchEvents/HandlingTouchEvents.html
> > >
> > > I'm not sure what you're proposing. Perhaps I'm being too simplistic,
> > > but it seems to me that if you can map the fingers to a pixel positions
> > > inside Gio's widgets, you can compute the implied rotation and scale
> > > when the fingers move. If so, why do we need to pack the pointer events
> > > with extra fields or special scroll events?
> > >
> > > Elias
>
Details
Message ID
<C9SAA6O1TVA0.3QJGGML7BZKM5@testmac>
In-Reply-To
<CABN121jm9Csb6DZjsSCP_8wzvMarsgp3jA8ap2K1mPahFiqTXg@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
On Mon Mar 8, 2021 at 21:21 CET, Werner Laurensse wrote:
> To clarify, you want Gio to emit a pointer.Event of type pointer.Move
> and set a Magnification field.

Yes.

> Why would an extra type make the routing more complicated, it works
> for me without modifying it.

When I say routing, I mean gioui.org/io/router.Router. Specifically, how
will pinch gestures be delivered to widgets, not just the main event
loop?

> If, a pinch is a move, then we always need to check if magnification
> is zero to know it is a real move.
>

I expect Zoom/Magnification to be 1 for ordinary moves. Why do you need
to disinguish? Can't you just apply both movement and/or zoom on every
pointer.Move?

Besides, it seems to me that pinch gestures can report moves as well.
Consider two fingers that move in parallel; they should be reported as a
move (of the pinch center). I don't know about macOS, but I'm pretty
sure that's how Android does it.

> On Sat, Mar 6, 2021 at 3:03 PM Elias Naur <mail@eliasnaur.com> wrote:
> >
> > On Fri Mar 5, 2021 at 15:38, Werner Laurensse wrote:
> > > In case of a touch screen yes, but a trackpad has no 1 tot 1 mapping
> > > to your screen(s).
> > > The pointer doesn't even move when you do a two finger scroll.
> > > On osx the way you can get the magnitude is by unpacking a ns event
> > > into ns touch and for each
> > > touch you get the normalised position (a tuple with range 0-1 for your
> > > finger position) and the device size
> > > of the detecting instrument (your trackpad).
> > > You could do this hackish thing where you offset the position of each
> > > pointer event based, but I dont think this works well because you get
> > > into situations where the fake position is negative while the pointer
> > > sits in the middle of the app window.
> > > How, in this case, would you actually distinguish between a faked
> > > touch and a touch from a touch screen connected to your mac like a
> > > wacom tablet? Maybe set the source of the event to mouse in case of a
> > > trackpad event.
> > >
> >
> > I see, thanks for elaborating the issue for me. You've convinced me that
> > pinch gestures on trackpads belong in pointer.Event, just as two-finger
> > scroll does.
> >
> > I propose we keep it simple and not introduce new pointer.Types; rather,
> > can we emit pinch events with as pointer.Moves? Then we avoid changing
> > input routing, and only need to add one or more fields to pointer.Event.
> >
> > > I have not tested it but I suspect my proposed solution already works
> > > this way in gio for js and windows.
> > > Windows started to set the ctrl key and set the scroll on pich
> > > gesture, for backward compatibility,
> > > after which browser adopted the same behaviour. My suggestion is to do
> > > the same thing for osx.
> > > It remains a hack but probably easier to document and works the same
> > > way for each platform.
> > >
> >
> > I don't think Gio programs need backwards compatibility in this regard.
> > Additional pointer.Event field should be ok.
> >
> > > On Fri, Mar 5, 2021 at 11:50 AM Elias Naur <mail@eliasnaur.com> wrote:
> > > >
> > > > On Fri Mar 5, 2021 at 06:18, Werner Laurensse wrote:
> > > > > There is another way to support the pinch gesture on trackpads without
> > > > > adding any extra fields to pointer.Event by adding the key.ModCtrl to
> > > > > the Modifiers field and setting Scroll X and Y to equal to
> > > > > magnification.
> > > > >
> > > > > This is also the way most browsers support this functionality in
> > > > > javascript without having access to the trackpad touch events [1] [2]
> > > > > and works on both OSX and Windows.
> > > > >
> > > > > The problem with proving this functionality through a trackpad is that
> > > > > it's touch events don't map directly to the screen and to calculate
> > > > > the magnification there is still a need to track the position of the
> > > > > fingers and the size of the trackpad [3] [4].
> > > > >
> > > > > Then gesture.Pinch can be implemented as a higher level multi touch
> > > > > event without having to stuff the pointer.Event with extra field
> > > > > rarely needed.
> > > > >
> > > > > [1] https://kenneth.io/post/detecting-multi-touch-trackpad-gestures-in-javascript
> > > > > [2] https://bugzilla.mozilla.org/show_bug.cgi?id=1052253
> > > > > [3] https://stackoverflow.com/questions/3573276/know-the-position-of-the-finger-in-the-trackpad-under-mac-os-x
> > > > > [4] https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/HandlingTouchEvents/HandlingTouchEvents.html
> > > >
> > > > I'm not sure what you're proposing. Perhaps I'm being too simplistic,
> > > > but it seems to me that if you can map the fingers to a pixel positions
> > > > inside Gio's widgets, you can compute the implied rotation and scale
> > > > when the fingers move. If so, why do we need to pack the pointer events
> > > > with extra fields or special scroll events?
> > > >
> > > > Elias
> >
Reply to thread Export thread (mbox)