Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

[android] Enable OnePlus middle click workaround

Carsten Hartenfelsd2d66147babe
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2d6cf99410..afedf23911 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -806,6 +806,15 @@ QCoreApplication::setKritaAttribute(KRITA_QATTRIBUTE_ANDROID_IGNORE_HISTORIC_TAB
KRITA_QT_HAS_ANDROID_IGNORE_HISTORIC_TABLET_EVENTS
)
+CHECK_CXX_SOURCE_COMPILES("
+#include <QCoreApplication>
+int main(int argc, char *argv[]) {
+QCoreApplication::setKritaAttribute(KRITA_QATTRIBUTE_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_HIGH_FUNCTION_KEYS);
+}
+"
+KRITA_QT_HAS_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_HIGH_FUNCTION_KEYS
+)
+
CHECK_CXX_SOURCE_COMPILES("
#include <QScroller>
#ifndef KRITA_QSCROLLER_PATCH
diff --git a/config-qt-patches-present.h.cmake b/config-qt-patches-present.h.cmake
index 241d47a8c2..b78d609da0 100644
--- a/config-qt-patches-present.h.cmake
+++ b/config-qt-patches-present.h.cmake
@@ -2,5 +2,6 @@
#cmakedefine01 KRITA_QT_HAS_UNBALANCED_KEY_PRESS_RELEASE_PATCH
#cmakedefine01 KRITA_QT_HAS_UPDATE_COMPRESSION_PATCH
#cmakedefine01 KRITA_QT_HAS_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_PAGE_UP_DOWN
+#cmakedefine01 KRITA_QT_HAS_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_HIGH_FUNCTION_KEYS
#cmakedefine01 KRITA_QT_HAS_ANDROID_IGNORE_HISTORIC_TABLET_EVENTS
#cmakedefine01 KRITA_QT_HAS_QSCROLLER_FILTER
diff --git a/libs/ui/KisApplication.cpp b/libs/ui/KisApplication.cpp
index 3275c68ca2..c5743c64e7 100644
--- a/libs/ui/KisApplication.cpp
+++ b/libs/ui/KisApplication.cpp
@@ -662,6 +662,16 @@ bool KisApplication::start(const KisApplicationArguments &args)
setPageUpDownMouseButtonEmulationWorkaround(cfg.usePageUpDownMouseButtonEmulationWorkaround());
#endif
+ // OnePlus workaround: their stylus inexplicably inputs the F21 key when
+ // pressing the stylus button. This flag causes the Android platform
+ // integration to turn it into middle clicks instead. Currently
+ // unconditional because a setting requires translation-relevant text
+ // changes, but later versions of Krita let you toggle it like the Xiaomi
+ // workarounds above.
+#if KRITA_QT_HAS_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_HIGH_FUNCTION_KEYS
+ QCoreApplication::setKritaAttribute(KRITA_QATTRIBUTE_ANDROID_EMULATE_MOUSE_BUTTONS_FOR_HIGH_FUNCTION_KEYS, true);
+#endif
+
// Xiaomi workaround: historic tablet motion events are garbage, they just
// connect the actual points that the tablet sampled with a straight line
// and no pressure emulation, leading to jagged curves that don't get