Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

improve tablet response

shun-iwasawad75cc49aad67
diff --git a/toonz/sources/toonz/main.cpp b/toonz/sources/toonz/main.cpp
index adf799145..96048cd08 100644
--- a/toonz/sources/toonz/main.cpp
+++ b/toonz/sources/toonz/main.cpp
@@ -399,6 +399,12 @@ int main(int argc, char *argv[]) {
// Enable to render smooth icons on high dpi monitors
a.setAttribute(Qt::AA_UseHighDpiPixmaps);
+#if defined(_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
+ // Compress tablet events with application attributes instead of implementing
+ // the delay-timer by ourselves
+ a.setAttribute(Qt::AA_CompressHighFrequencyEvents);
+ a.setAttribute(Qt::AA_CompressTabletEvents);
+#endif
// Set the app's locale for numeric stuff to standard C. This is important for
// atof() and similar
diff --git a/toonz/sources/toonz/sceneviewerevents.cpp b/toonz/sources/toonz/sceneviewerevents.cpp
index 088b7eb45..66788d7fa 100644
--- a/toonz/sources/toonz/sceneviewerevents.cpp
+++ b/toonz/sources/toonz/sceneviewerevents.cpp
@@ -357,6 +357,13 @@ void SceneViewer::tabletEvent(QTabletEvent *e) {
}
#endif
QPointF curPos = e->posF() * getDevPixRatio();
+#if defined(_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
+ // Use the application attribute Qt::AA_CompressTabletEvents instead of the
+ // delay timer
+ if (curPos != m_lastMousePos) {
+ TMouseEvent mouseEvent;
+ initToonzEvent(mouseEvent, e, height(), m_pressure, getDevPixRatio());
+#else
// It seems that the tabletEvent is called more often than mouseMoveEvent.
// So I fire the interval timer in order to limit the following process
// to be called in 50fps in maximum.
@@ -365,6 +372,8 @@ void SceneViewer::tabletEvent(QTabletEvent *e) {
TMouseEvent mouseEvent;
initToonzEvent(mouseEvent, e, height(), m_pressure, getDevPixRatio());
QTimer::singleShot(20, this, SLOT(releaseBusyOnTabletMove()));
+#endif
+
// cancel stroke to prevent drawing while floating
// 23/1/2018 There is a case that the pressure becomes zero at the start
// and the end of stroke. For such case, stroke should not be cancelled.