Bug 437196 - Touch docker commands sometimes gets triggered twice
Summary: Touch docker commands sometimes gets triggered twice
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Dockers (show other bugs)
Version: 4.4.3
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL: https://bugreports.qt.io/browse/QTBUG...
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-16 11:01 UTC by Alvin Wong
Modified: 2021-07-19 08:38 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alvin Wong 2021-05-16 11:01:08 UTC
SUMMARY

When clicking on touch docker commands with touch input, the command sometimes gets triggered twice. This seems to happen only immediately after drawing with stylus (but I'm not certain about this).

STEPS TO REPRODUCE
1. Draw two separate strokes
2. Click "undo" on the touch docker with touch input
3. Draw one new stroke and repeat the last step

OBSERVED RESULT

Sometimes both the last stroke and the first stroke disappear (gets undone) when clicking undo. Pressing "redo" will then revert the first stroke.


EXPECTED RESULT

Only the last stroke shall disappear (gets undone) when clicking undo.


SOFTWARE/OS VERSIONS
Windows: 10

ADDITIONAL INFORMATION

- Using pointer input (winink) on MS Surface Pro 5
Comment 1 Alvin Wong 2021-07-08 05:55:48 UTC
@Dmitry:

I traced the window messages and seem to have found a pattern. This is how the messages seem to arrive:

1. When drawing a stroke, WM_POINTERDOWN / WM_POINTERUPDATE / WM_POINTERUP are received for the pen input.
2. Synthesized WM_LBUTTONDOWN / WM_MOUSEMOVE / WM_LBUTTONUP are also received.
3. As the pen is released and the touch docker is touched, WM_POINTERDOWN / WM_POINTERUPDATE / WM_POINTERUP are received for the touch point.
4. Synthesized WM_TOUCH messages are also received.
5. Finally, synthesized WM_LBUTTONDOWN / WM_LBUTTONUP are received.

Whenever the command gets triggered twice, however, the window received extra WM_PINTERUPDATE messages generated from the pen moving, in between item 3 and 5.

Effectively, you don't need to draw on the canvas to trigger the bug. Simply shaking the pen hovering on the canvas and touching the touch docker buttons at the same time can trigger the bug.

I suspect this to be the culprit:
https://invent.kde.org/qt/qt/qtbase/-/commit/786c58817187bb18552934c807ba7a7ea845f49e#5fba19dc9f238dadbe8c1589df5a5f8c5c8a8537_732_734

I'm not sure if it is safe to just revert that commit though, since it does mention Qt Quick relies on this. What do you think?

P.S. the code comment states that "using the bit 7 of the extra msg info for checking if synthesized for touch does not work", but I suspect it is related to the thing where Windows starts synthesizing touch events from pen input since 1709.
Comment 2 Alvin Wong 2021-07-08 10:55:12 UTC
Opened upstream bug https://bugreports.qt.io/browse/QTBUG-95058
Comment 3 Bug Janitor Service 2021-07-12 14:03:52 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/952
Comment 4 Dmitry Kazakov 2021-07-19 08:37:01 UTC
Git commit 5207263943ae93e7098db0f33b57cfb0c92d7bff by Dmitry Kazakov, on behalf of Alvin Wong.
Committed on 19/07/2021 at 08:36.
Pushed by dkazakov into branch 'master'.

win: Work around touch docker buttons triggering twice

Hack around the issue by blocking certain mouse events in the touch
docker.

See also: https://bugreports.qt.io/browse/QTBUG-95058

M  +6    -0    plugins/dockers/touchdocker/CMakeLists.txt
M  +8    -0    plugins/dockers/touchdocker/TouchDockerDock.cpp
A  +93   -0    plugins/dockers/touchdocker/TouchDockerQQuickWidget.cpp     [License: GPL(v3.0+)]
A  +40   -0    plugins/dockers/touchdocker/TouchDockerQQuickWidget.h     [License: GPL(v3.0+)]

https://invent.kde.org/graphics/krita/commit/5207263943ae93e7098db0f33b57cfb0c92d7bff
Comment 5 Dmitry Kazakov 2021-07-19 08:38:23 UTC
Git commit d76fe492bf0b883f0d2b9d3bd70ef161af2a29c7 by Dmitry Kazakov, on behalf of Alvin Wong.
Committed on 19/07/2021 at 08:38.
Pushed by dkazakov into branch 'krita/5.0'.

win: Work around touch docker buttons triggering twice

Hack around the issue by blocking certain mouse events in the touch
docker.

See also: https://bugreports.qt.io/browse/QTBUG-95058

M  +6    -0    plugins/dockers/touchdocker/CMakeLists.txt
M  +8    -0    plugins/dockers/touchdocker/TouchDockerDock.cpp
A  +93   -0    plugins/dockers/touchdocker/TouchDockerQQuickWidget.cpp     [License: GPL(v3.0+)]
A  +40   -0    plugins/dockers/touchdocker/TouchDockerQQuickWidget.h     [License: GPL(v3.0+)]

https://invent.kde.org/graphics/krita/commit/d76fe492bf0b883f0d2b9d3bd70ef161af2a29c7