From fdc6890f4e86f52632d3f49def8d4cc682f7aa07 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 e22e1d46ae..d59831672b 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -1833,6 +1833,20 @@ void Application::runApplication(void) QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL); } + #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");