[Vm-dev] Primtive 91/primCursorLocPut:

Eliot Miranda eliot.miranda at gmail.com
Mon Dec 23 19:27:53 UTC 2019

Hi Tom, Hi Tim, Hi Ron,

On Sun, Dec 22, 2019 at 10:34 PM Tom Beckmann <tomjonabc at gmail.com> wrote:

> Hey everyone,
> I was looking for a way to set the OS cursor position from Squeak and
> found primitive 91 (see screenshots), which used to do exactly that (also
> according to the blue book). Now it instead returns whether a pixel depth
> is supported by the display.

As Tim says we must remove, or at least reimplement primCursorLockPut: to
say it is moo longer implemented ASAP.

> Has an alternative for setting the cursor position been implemented? If
> not, what would be the correct way of re-adding that functionality? Taking
> over another primitive number? I read that some people resorted to using
> custom FFI, but I feel like it could be worth the effort to properly
> reintegrate the functionality.

Indeed, but not in the default VM. Qwaq/Teleplace/3D ICC extended the

#if TerfVM
    result = ioSetCursorPositionXY(x, y);

and implementationsfor ioSetCursorPositionXY exist in the Term VM source
for some platforms.

iOS :-( platforms//iOS/plugins/HostWindowPlugin/sqMacHostWindow.m

sqInt ioSetCursorPositionXY(long x, long y) {   return -1; }

Unix :-) platforms//unix/vm-display-X11/sqUnixX11.c

static long
display_ioSetCursorPositionXY(long x, long y)
        if (!XWarpPointer(stDisplay, None, DefaultRootWindow(stDisplay),
                                          0, 0, 0, 0, x, y))
                return -1;
        return 0;

Windows :-) (but only in the Term VM sources in
platforms/win32/plugins/HostWindowPlugin/sqWin32HostWindowPlugin.c).  This
needs to be ported).

#if TerfVM
sqInt ioSetCursorPositionXY(sqInt x, sqInt y) { return SetCursorPos(x,y) ?
0  : -1; }

I'm pretty sure Ron has no issues with the Perf VM code getting
integrated.  And I think all those #if TermVM qualifiers can (and should)
be discarded.

So what we really need are

a) an implementation for iOS Cocoa, and
b) someone to put the energy into integrating the code, given that Vincent
Blondeau extended HostWin dowPlugin with support for setting the window
icon.  SO the Term and opensmalltalk code has diverged a little.

> Usecases: for example in Photoshop you often have number inputs on the far
> right side of your monitor. These support clicking and dragging for
> changing the value. However, the cursor will almost immediately hit the
> right edge of the screen. To prevent this, the cursor position will keep
> being reset to the center of the slider element while the user is dragging.
> Further, games often use mouse input as a relative number, rather than
> absolute, by forcing the cursor to the center of screen after each frame
> and only taking the movement between each frame. This is most commonly seen
> in games with first person perspective.

You don't have to justify.  primCursorLocPut: is essential GUi

> Thank you for any pointers!
> Best,
> Tom

best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20191223/95474dbe/attachment.html>

More information about the Vm-dev mailing list