[Vm-dev] Primtive 91/primCursorLocPut:

Eliot Miranda eliot.miranda at gmail.com
Mon Dec 23 22:34:11 UTC 2019


Hi Tom,

On Mon, Dec 23, 2019 at 11:56 AM Tom Beckmann <tomjonabc at gmail.com> wrote:

>
> Dear Elliot, dear all,
>
> do you have some insights or docs pages on how the HostWindowPlugin fits
> into the big picture at the moment? Trying DisplayHostWindow>>#examplePaint
> in Squeak trunk primtiveError's for me at the moment and I don't know what
> it should do exactly either. I always assumed it was meant to spawn
> additional windows, but never actually saw that in action.
>

The HostWindowPlugin is an internal plugin in the Squeak and Pharo VMs (at
theist the opensmalltalk Pharo VMs).  So one can  rely on it being present.

The HostWIndowPlugin is not the same as a host window facility where
Morphic windows can be launched in native windows.  Instead the
HostWindowPlugin gives access to the host window in which the main Squeak
desktop runs.  For example, Terf uses it at login to resize the window into
a login dialog sized window.


> Only knowing the unix platform opensmalltalk code a little, my gut feeling
> would have led me to place primCursorLocPut: implementations in there, in
> one of the display plugins. To my understanding this would mean that we
> would have to occupy a new numbered VM primitive, as it used to be. Is that
> correct?
>

No.  The plumbing for the various display plugins on Unix is via a struct
that includes functions such as ioSetCursorPositionXY.  See SqDisplay.h.
So the issue is independent of needing a primitive number.  I like to use
primitive numbers for core Smalltalk and VM facilities and think that using
HostWindowPliugin is entirely appropriate for primCursorLocPut:
functionality.


Is this the desirable way? Or is the purpose of the HostWindowPlugin to
> supersede the platform's own window code?
>

As I understand it, the HostWindowPlugin's role is in providing additional
control beyond e.g. the beDisplay primitive.


> Thank you for the insights!
> Tom
>
> On Mon, Dec 23, 2019 at 8:28 PM Eliot Miranda <eliot.miranda at gmail.com>
> wrote:
>
>>
>> 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
>> HostWindowPlugin:
>>
>> primitiveSetCursorPositionX:Y:
>> #if TerfVM
>> EXPORT(sqInt)
>> primitiveSetCursorPosition(void)
>> {
>>    ...
>>     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;
>>         XFlush(stDisplay);
>>         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
>> functionality.
>>
>>
>>>
>>> Thank you for any pointers!
>>>
>>> Best,
>>> Tom
>>>
>>
>> _,,,^..^,,,_
>> best, Eliot
>>
>

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


More information about the Vm-dev mailing list