[Vm-dev] [OpenSmalltalk/opensmalltalk-vm] Fix timestamps for DragDrop events on Windows (#518)

Christoph Thiede notifications at github.com
Wed Sep 2 16:22:48 UTC 2020


Before this patch, the timestamps recorded for DragDrop events in the win32 implementation were not comparable to the timestamps recorded for regular mouse or keyboard events. This was the case because it used `ioMicroMSecs()` which returns the milliseconds elapsed since the VM was started (see `sqWin32Heartbeat.c`). However, for other events, the timestamp is retrieved from the `MSG` structure where the time is counted since the *system* start.

In the DnD module (see `sqWin32DragDrop.c`), no `MSG` instances are retrieved because it is implemented based on the [`IDropTarget` interface](https://docs.microsoft.com/en-us/windows/win32/api/oleidl/nn-oleidl-idroptarget) from the `ole2.h` header instead of `Winuser.h`. Nevertheless, we can get the required timestamp using the [`GetTickCount()`](https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-gettickcount) function from `sysinfoapi.h` which returns the milliseconds elapsed since the system start as well. By the way, it is already used for recording window events (see `recordWindowEvent()`, however, as far as I see, its use would not even have been necessary in this case because the single caller of that function could also have passed `messageTouse->time` to it).

Closes #509.

## How can I test this?

For observing the consequences of this PR, please install [this changeset](https://github.com/OpenSmalltalk/opensmalltalk-vm/files/5163502/test-fix-win-evt-timestamps.1.cs.zip) into both an unpatched and patched VM and watch the outputs in the Transcript window while moving your mouse and dragging files from your Win32 host system over/into the image (works best when disabling the 'TranscriptStream forceUpdate' preference).

## Merger notes

Please review!
And please squash this PR when merging. :-)
You can view, comment on, or merge this pull request online at:

  https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/518

-- Commit Summary --

  * Early WIP
  * Merge branch 'Cog' into fix-win-evt-timestamps
  * Fix timestamps for DragDrop events on Windows
  * Use GetTickCount() instead of GetMessageTime().
  * [skip-ci] Improve comment

-- File Changes --

    M .gitignore (4)
    M platforms/win32/vm/sqWin32Window.c (3)

-- Patch Links --

https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/518.patch
https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/518.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/518
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20200902/343fc575/attachment-0001.html>


More information about the Vm-dev mailing list