From 83e308c8ebb47366ab7342eb5d0bd45a0adf7998 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Mon, 29 Mar 2021 11:23:55 +0200 Subject: [PATCH] Gui: Enable compression of tablet motion events By default (on platforms that support it, X11 and Windows currently) QT applies compression for high frequency events (mouse move, touch, window resizes) to keep things smooth even when handling the event takes a while (e.g. to calculate snapping). However, tablet pen move events (and mouse move events synthesised from those, which is what FreeCAD uses) are not compressed by default (to allow maximum precision when e.g. hand-drawing curves), leading to unacceptable slowdowns using a tablet pen. This commit enable compression for tablet events here to solve that and make use of a tablet just as smooth as a mouse with FreeCAD. This can (and likely will) lead to some movement events being dropped, but since there is no freeform curve drawing tool, that should not be problematic (and if it is ever added, it could still work without compression if the mouse movement event handler is written to be fast enough). --- src/Gui/Application.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 068da2597b..7d76a7be9a 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -1957,6 +1957,20 @@ void Application::runApplication(void) } #endif // QT_VERSION >= 0x050400 + #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) + // By default (on platforms that support it, see docs for + // Qt::AA_CompressHighFrequencyEvents) QT applies compression + // for high frequency events (mouse move, touch, window resizes) + // to keep things smooth even when handling the event takes a + // while (e.g. to calculate snapping). + // However, tablet pen move events (and mouse move events + // synthesised from those) are not compressed by default (to + // allow maximum precision when e.g. hand-drawing curves), + // leading to unacceptable slowdowns using a tablet pen. Enable + // compression for tablet events here to solve that. + QCoreApplication::setAttribute(Qt::AA_CompressTabletEvents); + #endif + // A new QApplication Base::Console().Log("Init: Creating Gui::Application and QApplication\n");