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++
Refactor detection the presence of custom Qt patches
Dmitry Kazakov8af77896f650
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 8ff81e0359..6348f4fd75 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -394,6 +394,7 @@ include(ECMInstallIcons)include(CMakePackageConfigHelpers)include(WriteBasicConfigVersionFile)include(CheckFunctionExists)+include(CheckCXXSymbolExists)if (QT_MAJOR_VERSION STREQUAL "6")set (KDE_COMPILERSETTINGS_LEVEL "5.0")@@ -497,7 +498,35 @@ if (QT_MAJOR_VERSION STREQUAL "6"))endif()+#+# Check for the presence of custom patches in Qt+#+set(CMAKE_REQUIRED_INCLUDES ${Qt${QT_MAJOR_VERSION}Gui_INCLUDE_DIRS})+set(CMAKE_REQUIRED_LIBRARIES ${Qt${QT_MAJOR_VERSION}Gui_LIBRARIES})++check_cxx_symbol_exists(QT_HAS_ENTER_LEAVE_PATCH "QtGui/qevent.h" KRITA_QT_HAS_ENTER_LEAVE_PATCH)++if (QT_MAJOR_VERSION STREQUAL "5")+ # in Qt5 we didn't have a separate definition for key-press/release patch+ set(KRITA_QT_HAS_UNBALANCED_KEY_PRESS_RELEASE_PATCH ${KRITA_QT_HAS_ENTER_LEAVE_PATCH})+else()+ check_cxx_symbol_exists(QT_HAS_UNBALANCED_KEY_PRESS_RELEASE_PATCH "QtGui/qevent.h" KRITA_QT_HAS_UNBALANCED_KEY_PRESS_RELEASE_PATCH)+endif()+unset(CMAKE_REQUIRED_INCLUDES)+unset(CMAKE_REQUIRED_LIBRARIES)++option(KRITA_QT_HAS_ENTER_LEAVE_PATCH "Qt has a custom patch for unbalanced enter/leave events" ON)+add_feature_info("Qt: Unbalanced Enter/Leave patch" KRITA_QT_HAS_ENTER_LEAVE_PATCH "Krita will disable internal workarounds for unbalanced Enter/Leave")++option(KRITA_QT_HAS_UNBALANCED_KEY_PRESS_RELEASE_PATCH "Qt has a custom patch for unbalanced KeyPress/KeyRelease events in non-latin layouts" ON)+add_feature_info("Qt: Unbalanced KeyPress/KeyRelease in non-latin layout patch" KRITA_QT_HAS_UNBALANCED_KEY_PRESS_RELEASE_PATCH "Krita will disable internal workarounds for unbalanced KeyPress/KeyRelease events")++configure_file(config-qt-patches-present.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-qt-patches-present.h)++#+# Check for the presence the Wintab switch in Qt5+#if (WIN32 AND QT_MAJOR_VERSION STREQUAL "5")set(CMAKE_REQUIRED_INCLUDES ${Qt5Core_INCLUDE_DIRS})set(CMAKE_REQUIRED_LIBRARIES ${Qt5Core_LIBRARIES})diff --git a/config-qt-patches-present.h.cmake b/config-qt-patches-present.h.cmakenew file mode 100644index 0000000000..93ade580c0--- /dev/null+++ b/config-qt-patches-present.h.cmake@@ -0,0 +1,2 @@+#cmakedefine01 KRITA_QT_HAS_ENTER_LEAVE_PATCH+#cmakedefine01 KRITA_QT_HAS_UNBALANCED_KEY_PRESS_RELEASE_PATCHdiff --git a/libs/ui/input/kis_input_manager.cpp b/libs/ui/input/kis_input_manager.cppindex 4e8333fb0a..d985e04a08 100644--- a/libs/ui/input/kis_input_manager.cpp+++ b/libs/ui/input/kis_input_manager.cpp@@ -52,6 +52,8 @@#include "kis_extended_modifiers_mapper.h"#include "kis_input_manager_p.h"#include "kis_algebra_2d.h"+#include "config-qt-patches-present.h"+template <typename T>uint qHash(QPointer<T> value) {@@ -623,7 +625,7 @@ bool KisInputManager::eventFilterImpl(QEvent * event)d->resetCompressor();-#if defined Q_OS_LINUX && !defined QT_HAS_ENTER_LEAVE_PATCH+#if defined Q_OS_LINUX && !KRITA_QT_HAS_ENTER_LEAVE_PATCH// remove this hack when this patch is integrated:// https://codereview.qt-project.org/#/c/255384/event->setAccepted(false);@@ -657,7 +659,7 @@ bool KisInputManager::eventFilterImpl(QEvent * event)*/d->blockMouseEvents();-#if defined Q_OS_LINUX && !defined QT_HAS_ENTER_LEAVE_PATCH+#if defined Q_OS_LINUX && !KRITA_QT_HAS_ENTER_LEAVE_PATCH// remove this hack when this patch is integrated:// https://codereview.qt-project.org/#/c/255384/event->setAccepted(false);@@ -677,7 +679,7 @@ bool KisInputManager::eventFilterImpl(QEvent * event)retval = true;event->setAccepted(true);-#if defined Q_OS_LINUX && !defined QT_HAS_ENTER_LEAVE_PATCH+#if defined Q_OS_LINUX && !KRITA_QT_HAS_ENTER_LEAVE_PATCH// remove this hack when this patch is integrated:// https://codereview.qt-project.org/#/c/255384/event->setAccepted(false);diff --git a/libs/ui/input/kis_input_manager_p.cpp b/libs/ui/input/kis_input_manager_p.cppindex e365545fa6..b4388d5df7 100644--- a/libs/ui/input/kis_input_manager_p.cpp+++ b/libs/ui/input/kis_input_manager_p.cpp@@ -25,6 +25,8 @@#include "kis_zoom_and_rotate_action.h"#include "kis_popup_palette.h"+#include "config-qt-patches-present.h"+/*** This hungry class EventEater encapsulates event masking logic.@@ -229,7 +231,7 @@ KisInputManager::Private::Private(KisInputManager *qq)* In Linux distributions Qt is not patched, so we should* use workaround for them*/-#if defined Q_OS_LINUX && !defined QT_HAS_ENTER_LEAVE_PATCH+#if defined Q_OS_LINUX && !KRITA_QT_HAS_UNBALANCED_KEY_PRESS_RELEASE_PATCHuseUnbalancedKeyPressEventWorkaround = true;#endif