Skip to content

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

C

Add input event compression preference

Rodney33fc70bc0e36
diff --git a/toonz/sources/include/toonz/preferencesitemids.h b/toonz/sources/include/toonz/preferencesitemids.h
index c50927bc1..a50d26702 100644
--- a/toonz/sources/include/toonz/preferencesitemids.h
+++ b/toonz/sources/include/toonz/preferencesitemids.h
@@ -128,6 +128,7 @@ enum PreferencesItemId {
useStrokeEndCursor,
clickTwiceToCreateArcs,
tempToolSwitchTimer,
+ compressInputEvents,
animateToolHandleSize,
animateToolColor,
defaultStartupTool,
diff --git a/toonz/sources/toonz/main.cpp b/toonz/sources/toonz/main.cpp
index 0cf23bb43..b5f0a2957 100644
--- a/toonz/sources/toonz/main.cpp
+++ b/toonz/sources/toonz/main.cpp
@@ -411,12 +411,6 @@ int main(int argc, char *argv[]) {
// Enable to render smooth icons on high dpi monitors
a.setAttribute(Qt::AA_UseHighDpiPixmaps);
-#if defined(_WIN32)
- // 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
#ifdef _WIN32
// BUG_WORKAROUND: #20230627
@@ -512,6 +506,20 @@ int main(int argc, char *argv[]) {
// Toonz environment
initToonzEnv(argumentPathValues);
+ // Read the saved preference only after the Toonz environment is initialized.
+ // Preserve existing platform defaults when enabled; disabling also prevents
+ // tablet compression, which depends on high-frequency event compression.
+ if (!Preferences::instance()->getBoolValue(compressInputEvents)) {
+ a.setAttribute(Qt::AA_CompressHighFrequencyEvents, false);
+ a.setAttribute(Qt::AA_CompressTabletEvents, false);
+ }
+#if defined(_WIN32)
+ else {
+ a.setAttribute(Qt::AA_CompressHighFrequencyEvents, true);
+ a.setAttribute(Qt::AA_CompressTabletEvents, true);
+ }
+#endif
+
// prepare for 30bit display
if (Preferences::instance()->is30bitDisplayEnabled()) {
QSurfaceFormat sFmt = QSurfaceFormat::defaultFormat();
diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp
index 3815ec251..7742ebf47 100644
--- a/toonz/sources/toonz/preferencespopup.cpp
+++ b/toonz/sources/toonz/preferencespopup.cpp
@@ -1385,6 +1385,7 @@ QString PreferencesPopup::getUIString(PreferencesItemId id) {
tr("Use higher DPI for calculations - Slower but more accurate")},
// Tools
+ {compressInputEvents, tr("Compress Input Events*")},
// {dropdownShortcutsCycleOptions, tr("Dropdown Shortcuts:")}, //
// removed
{FillOnlysavebox,
@@ -2269,6 +2270,15 @@ QWidget* PreferencesPopup::createToolsPage() {
insertUI(useCtrlAltToResizeBrush, lay);
insertUI(clickTwiceToCreateArcs, lay);
insertUI(tempToolSwitchTimer, lay);
+ insertUI(compressInputEvents, lay);
+ getUI<CheckBox*>(compressInputEvents)
+ ->setToolTip(
+ tr("Combines frequent input events to reduce processing load. "
+ "Disabling may improve stroke tracking but can affect "
+ "responsiveness and brush behavior. Support varies by platform; "
+ "ordinary mouse movement on Windows is unaffected. "
+ "Separate tool-level input limits remain in effect. "
+ "Changes take effect after restarting OpenToonz."));
QGridLayout* animateToolLay = insertGroupBox(tr("Animate Tool"), lay);
{
diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp
index 8d4d2e2cf..f054ea95f 100644
--- a/toonz/sources/toonzlib/preferences.cpp
+++ b/toonz/sources/toonzlib/preferences.cpp
@@ -556,6 +556,7 @@ void Preferences::definePreferenceItems() {
QMetaType::Bool, false);
// Tools
+ define(compressInputEvents, "compressInputEvents", QMetaType::Bool, true);
define(FillOnlysavebox, "FillOnlysavebox", QMetaType::Bool, false);
define(DefRegionWithPaint, "FillDefRegionWithPaint", QMetaType::Bool, true);
define(ReferFillPrevailing, "ReferFillPrevailing", QMetaType::Bool, false);