codefrau / SqueakJS

A Squeak Smalltalk VM in Javascript
https://squeak.js.org
MIT License
371 stars 76 forks source link

Cannot use mouse wheel to scroll in Squeak 5.3 #109

Closed LinqLover closed 4 months ago

LinqLover commented 4 years ago

System

Steps to reproduce

Expected behavior

The text morph is scrolled as if you were using OSVM.

Actual behavior

Nothing happens. The mouse wheel is ignored.

codefrau commented 4 years ago

This should be fairly easy to implement. Add a wheel event handler https://github.com/codefrau/SqueakJS/blob/6112298dae73b05d453d7277894669bf31518659/squeak.js#L430 that uses fakeCmdOrCtrlKey() to generate an up/down event (squeak key code 30/31) with the ctrl/cmd modifiers set. Pull requests welcome :)

LinqLover commented 4 years ago

This does not sound uninteresting to implement, but I won't be able before August :-)

Hm ... Wouldn't it be more convenient to generate full-featured MouseWheelEvents rather than fake keyboard events?

codefrau commented 4 years ago

Modifier-up/down is what older images expect.

I didn't know we changed the VM interface to support actual MouseWheelEvents. Is there documentation for that?

If so, then supporting that would make sense in addition to the keyboard-based scrolling interface.

LinqLover commented 4 years ago

The best documentation for this feature I now is "A MouseWheelEvent is xxxxxxxxx." ;-)

Seriously, I've only been following these changes with half an eye, but afaik, @nicolas-cellier-aka-nice improved support for this feature recently. See http://forum.world.st/The-Trunk-Morphic-nice-1616-mcz-td5113016.html, OpenSmalltalk/opensmalltalk-vm#41, and all the nested references. At the moment I don't know further details about it.

codefrau commented 3 years ago

This seems relevant:

vmAttribute 48: various properties stored in the image header (that instruct the VM) as an integer encoding an array of bit flags. Bit 0: tells the VM that the image's Process class has threadId as its 5th inst var (after nextLink, suspendedContext, priority & myList) Bit 1: on Cog JIT VMs asks the VM to set the flag bit in interpreted methods Bit 2: if set, preempting a process puts it to the head of its run queue, not the back, i.e. preempting a process by a higher priority one will not cause the preempted process to yield to others at the same priority. Bit 3: in a muilt-threaded VM, if set, the Window system will only be accessed from the first VM thread Bit 4: in a Spur vm, if set, causes weaklings and ephemerons to be queued individually for finalization Bit 5: if set, implies wheel events will be delivered as such and not mapped to arrow key events Bit 6: if set, implies arithmetic primitives will fail if given arguments of different types (float vs int)

Does Squeak look at that flag ever? Does it still support cmd-arrow mouse events?

In any case we should emulate this I guess, and also read/store this word in the image header.

codefrau commented 7 months ago

I implemented wheel handling in 4c19c74f7758259f1469a727483b7a6ee9d29076

I did not implement vm parameter 48 handling yet. It simply defaults to wheel events if on spur.

codefrau commented 4 months ago

appears to work