diff --git a/libs/ui/CMakeLists.txt b/libs/ui/CMakeLists.txt --- a/libs/ui/CMakeLists.txt +++ b/libs/ui/CMakeLists.txt @@ -13,6 +13,7 @@ if (APPLE) find_library(FOUNDATION_LIBRARY Foundation) + find_library(APPKIT_LIBRARY AppKit) endif () set(kritaui_LIB_SRCS @@ -424,6 +425,12 @@ endif() endif() +if(APPLE) + set(kritaui_LIB_SRCS + ${kritaui_LIB_SRCS} + osx.mm + ) +endif() ki18n_wrap_ui(kritaui_LIB_SRCS widgets/KoFillConfigWidget.ui @@ -526,6 +533,7 @@ if(APPLE) target_link_libraries(kritaui ${FOUNDATION_LIBRARY}) + target_link_libraries(kritaui ${APPKIT_LIBRARY}) endif () diff --git a/libs/ui/input/kis_input_manager.cpp b/libs/ui/input/kis_input_manager.cpp --- a/libs/ui/input/kis_input_manager.cpp +++ b/libs/ui/input/kis_input_manager.cpp @@ -62,6 +62,10 @@ #include "kis_extended_modifiers_mapper.h" #include "kis_input_manager_p.h" +#ifdef Q_OS_OSX +#include "osx.h" +#endif + template uint qHash(QPointer value) { return reinterpret_cast(value.data()); @@ -79,6 +83,10 @@ QApplication::instance()-> installEventFilter(new Private::ProximityNotifier(d, this)); + +#ifdef Q_OS_OSX + setMouseCoalescingEnabled(false); +#endif } KisInputManager::~KisInputManager() @@ -244,6 +252,10 @@ bool KisInputManager::eventFilterImpl(QEvent * event) { +#ifdef DEBUG_TABLET_MOVE_DT + static int tabletMoveDtZ = 0; +#endif + bool retval = false; if (event->type() != QEvent::Wheel) { @@ -441,6 +453,10 @@ //Reset signal compressor to prevent processing events before press late d->resetCompressor(); d->eatOneMousePress(); + +#ifdef DEBUG_TABLET_MOVE_DT + tabletMoveDtZ = 0; +#endif break; } case QEvent::TabletMove: { @@ -449,6 +465,24 @@ QTabletEvent *tabletEvent = static_cast(event); retval = compressMoveEventCommon(tabletEvent); +#ifdef DEBUG_TABLET_MOVE_DT + static int tabletMoveDt[64]; + static long lastTimestamp = 0; + const long timestamp = tabletEvent->timestamp(); + tabletMoveDt[tabletMoveDtZ] = timestamp - lastTimestamp; + lastTimestamp = timestamp; + tabletMoveDtZ = (tabletMoveDtZ + 1) % 64; + if (tabletMoveDtZ == 0) { + int maxDt = 0; + for (int i = 0; i < 64; i++) { + if (tabletMoveDt[i] > maxDt) { + maxDt = tabletMoveDt[i]; + } + } + qDebug() << "max tablet move dt: " << maxDt; + } +#endif + /** * The flow of tablet events means the tablet is in the * proximity area, so activate it even when the diff --git a/libs/ui/osx.h b/libs/ui/osx.h new file mode 100644 --- /dev/null +++ b/libs/ui/osx.h @@ -0,0 +1,4 @@ +extern "C" { + bool isMouseCoalescingEnabled(); + void setMouseCoalescingEnabled(bool enabled); +} diff --git a/libs/ui/osx.mm b/libs/ui/osx.mm new file mode 100644 --- /dev/null +++ b/libs/ui/osx.mm @@ -0,0 +1,14 @@ +#import + +extern "C" { + bool isMouseCoalescingEnabled(); + void setMouseCoalescingEnabled(bool enabled); +} + +bool isMouseCoalescingEnabled() { + return NSEvent.isMouseCoalescingEnabled; +} + +void setMouseCoalescingEnabled(bool enabled) { + NSEvent.mouseCoalescingEnabled = enabled; +}