Commit d684bc55 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Add workaround for handling table press correctly in WinInk mode

Original problem: widgets do not get synthesized mouse-down and
mouse-press events until the stylus is released

Reason: if the app accepts the event, WndProc should report
that to the system (by returning true). This is the only way to
prevent Windows from starting some system-wide gestures, like
click+hold -> right button click. If we ignore the event, then
OS postpones all synthesized mouse events until the entire gesture
is completed.

The patch implements a "hackish" workaround for the original problem
by using the following rules:

1) All tablet-move events are ignored (without synthesized mouse events
   OS doesn't generate any Enter/Leave events)

2) All not-accepted tablet press- and release-events and also reported as
   ignored (without it D&D doesn't work).

3) All accepted tablet press- and release-events are reported as "accepted",
   **but** we artificially synthesize mouse events for them.

TODO: there are still two problems:

1) Perhaps this synthesizeMouseEvent() is not needed at all. But we should
   first check if Qt relies on these synthesized messages anywhere in the
   code or not.

2) If we still keep synthesizeMouseEvent(), then it should fetch actual
   tablet buttons from QGuiApplicationPrivate::tabletDevicePoint(). Right
   now it always synthesizes left-click, whatever the button was pressed/

parent 8dd4d8b9
......@@ -57,6 +57,7 @@ if (WIN32)
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0027-Switch-stylus-pointer-type-when-the-tablet-is-in-the.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0028-Fix-updating-tablet-pressure-resolution-on-every-pro.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0050-Fix-using-tablet-on-QML-widgets.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0051-Add-workaround-for-handling-table-press-correctly-in.patch
set(ext_qt_PATCH_COMMAND ${ext_qt_PATCH_COMMAND}
......@@ -329,6 +329,23 @@ void TouchDockerDock::changeEvent(QEvent *event)
void TouchDockerDock::tabletEvent(QTabletEvent *event)
#ifdef Q_OS_WIN
* On Windows (only in WinInk mode), unless we accept the tablet event,
* OS will start windows gestures, like click+hold for right click.
* It will block any mouse events generation.
* In our own (hacky) implementation, if we accept the event, we block
* the gesture, but still generate a fake mouse event.
KoDialog *TouchDockerDock::createDialog(const QString qml)
KoDialog *dlg = new KoDialog(this);
......@@ -76,6 +76,8 @@ private:
void showFileSaveAsDialog();
void changeEvent(QEvent* event) override;
void tabletEvent(QTabletEvent *event) override;
KoDialog *createDialog(const QString qml);
QPointer<KisCanvas2> m_canvas;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment