diff --git a/3rdparty/ext_qt/0001-Android-Fix-incorrect-handling-of-window-modality.patch b/3rdparty/ext_qt/0001-Android-Fix-incorrect-handling-of-window-modality.patch new file mode 100644 index 0000000000000000000000000000000000000000..fbf120383a4b709abec5d6c21a0032b01bde795b --- /dev/null +++ b/3rdparty/ext_qt/0001-Android-Fix-incorrect-handling-of-window-modality.patch @@ -0,0 +1,115 @@ +From 03fea83a0520bc99e2d6a569facfde73537baec1 Mon Sep 17 00:00:00 2001 +From: Sharaf Zaman +Date: Tue, 19 Jul 2022 08:50:25 +0000 +Subject: [PATCH] Android: Fix incorrect handling of window modality + +Before this, we used to ignore the modality in the "topWindowAt" API +which made us rely on window modality handling somewhere down the line. +This resulted in a problem where even though the modal window should be +able to receive the events, it didn't because the point didn't exist in +its boundingRect (and we could shift focus to windows whose modality +wasn't properly handled downstream). + +With current implementation. If the dialog is a popup and the point is +in its bounding rect, then we return it (this ignores modality rules, +but should be safe enough -- because it is a popup?). + +Then we check if the window is modal, if it is we should send all the +events to it, unless the window has a window manager. In that case if we +touch the window manager's frame, it should get the events instead. +--- + .../android/qandroidplatformscreen.cpp | 20 ++++++++++++++----- + .../android/qandroidplatformwindowmanager.cpp | 11 ++++++++++ + .../android/qandroidplatformwindowmanager.h | 16 +++++++++++++++ + 3 files changed, 42 insertions(+), 5 deletions(-) + +diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp +index f1f936850a..8152523ba3 100644 +--- a/src/plugins/platforms/android/qandroidplatformscreen.cpp ++++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp +@@ -139,9 +139,20 @@ QWindow *QAndroidPlatformScreen::topLevelAt(const QPoint &p) const + // These are the types of widgets which are usually kept on top by the + // compositor. But since there is none for SurfaceView, we try our best to + // give them the first preference. +- for (QAndroidPlatformWindow *w : m_windowStack) { +- if (isPopup(w) && w->geometry().contains(p, false) && w->window()->isVisible()) { +- return w->window(); ++ for (QAndroidPlatformWindow *platformWindow : m_windowStack) { ++ if (isPopup(platformWindow) && platformWindow->geometry().contains(p, false) ++ && platformWindow->window()->isVisible()) { ++ return platformWindow->window(); ++ } ++ ++ if (platformWindow->window()->isModal() && platformWindow->window()->isVisible()) { ++ // check if the platformWindow doesn't have a window manager and if it does, then check ++ // if the point p isn't in the bounds of window manager, if it is, then we should just ++ // let it (the window manager) handle it. ++ if (!m_windowManagers.contains(platformWindow->winId()) ++ || !m_windowManagers[platformWindow->winId()]->contains(p, true)) { ++ return platformWindow->window(); ++ } + } + } + for (QAndroidPlatformWindow *w : m_windowStack) { +@@ -166,8 +177,7 @@ void QAndroidPlatformScreen::addWindow(QAndroidPlatformWindow *window) + if (window->parent() && window->isRaster()) + return; + +- if ((window->window()->type() == Qt::Dialog || window->window()->type() == Qt::Tool) +- && (window->window()->flags() & Qt::FramelessWindowHint) == 0) { ++ if (QAndroidPlatformWindowManager::needsWindowManager(window->window())) { + // we will manage memory ourselves, because our parent is always + // MainWindow + QAndroidPlatformWindowManager *wm = new QAndroidPlatformWindowManager(window); +diff --git a/src/plugins/platforms/android/qandroidplatformwindowmanager.cpp b/src/plugins/platforms/android/qandroidplatformwindowmanager.cpp +index 4e896eab3c..4bad4b6553 100644 +--- a/src/plugins/platforms/android/qandroidplatformwindowmanager.cpp ++++ b/src/plugins/platforms/android/qandroidplatformwindowmanager.cpp +@@ -53,6 +53,17 @@ void QAndroidPlatformWindowManager::lowerRealWindow() + m_realWindow->lower(); + } + ++bool QAndroidPlatformWindowManager::contains(QPoint point, bool inNativeUnits) ++{ ++ if (inNativeUnits) { ++ point = QHighDpi::fromNativePixels(point, this); ++ } ++ const QRegion wmGeom = geometry(); ++ const QRegion childGeom = m_realWindow->window()->geometry(); ++ ++ return wmGeom.subtracted(childGeom).contains(point); ++} ++ + void QAndroidPlatformWindowManager::mousePressEvent(QMouseEvent *event) + { + m_startingPoint = event->globalPos(); +diff --git a/src/plugins/platforms/android/qandroidplatformwindowmanager.h b/src/plugins/platforms/android/qandroidplatformwindowmanager.h +index f78cdc0725..a548f3dd44 100644 +--- a/src/plugins/platforms/android/qandroidplatformwindowmanager.h ++++ b/src/plugins/platforms/android/qandroidplatformwindowmanager.h +@@ -30,6 +30,22 @@ public: + void lowerRealWindow(); + QAndroidPlatformWindow *realWindow() { return m_realWindow; } + ++ /** ++ * return true of the window type needs a window manager. ++ */ ++ static bool needsWindowManager(QWindow *window) ++ { ++ return ((window->type() == Qt::Dialog || window->type() == Qt::Tool) ++ && (window->flags() & Qt::FramelessWindowHint) == 0); ++ } ++ ++ /** ++ * Returns true if point is in the window manager bounds, but not in the bounds of its ++ * child/real window. If the point is in native units, inNativeUnits should be set to true for ++ * valid calulcations. ++ */ ++ bool contains(QPoint point, bool inNativeUnits = false); ++ + protected: + void resizeEvent(QResizeEvent *event) override; + void showEvent(QShowEvent *event) override; +-- +2.37.0 + diff --git a/3rdparty/ext_qt/0001-Android-Make-window-which-is-clicked-on-the-activate.patch b/3rdparty/ext_qt/0001-Android-Make-window-which-is-clicked-on-the-activate.patch index 47dc949d3e8b4a5af99362794ea8832b296096c5..60bd6868afb6192a639e045542fb35590aa827df 100644 --- a/3rdparty/ext_qt/0001-Android-Make-window-which-is-clicked-on-the-activate.patch +++ b/3rdparty/ext_qt/0001-Android-Make-window-which-is-clicked-on-the-activate.patch @@ -1,4 +1,4 @@ -From 4394338d534a33d249f79e815b7d62ea92a78e40 Mon Sep 17 00:00:00 2001 +From 0a2f068d34cf3c15a5f6aed28420b4888bf2068b Mon Sep 17 00:00:00 2001 From: Sharaf Zaman Date: Thu, 27 Jan 2022 11:46:29 +0000 Subject: [PATCH] Android: Make window which is clicked on the activated window @@ -22,7 +22,7 @@ z-order can changed. 4 files changed, 70 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp -index 257d013fa8..363ec8eab6 100644 +index 257d013fa8..a4bb8ae1a7 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -46,11 +46,13 @@ @@ -46,7 +46,7 @@ index 257d013fa8..363ec8eab6 100644 + static void checkAndSetTopLevelWindow(QWindow *window) + { + QWindow *focusWindow = QGuiApplication::focusWindow(); -+ if (focusWindow == window || (window->flags() & Qt::WindowDoesNotAcceptFocus)) { ++ if (focusWindow == window || (window && window->flags() & Qt::WindowDoesNotAcceptFocus)) { + return; + } + @@ -192,5 +192,5 @@ index 0688a75794..f78cdc0725 100644 protected: void resizeEvent(QResizeEvent *event) override; -- -2.35.1 +2.37.0 diff --git a/3rdparty/ext_qt/CMakeLists.txt b/3rdparty/ext_qt/CMakeLists.txt index fcd0e1337a8c1c2577b7fe6c8e5326b38a299e57..bf37ad8a6e0efd453c2e4b836ddf24be15dde3f0 100644 --- a/3rdparty/ext_qt/CMakeLists.txt +++ b/3rdparty/ext_qt/CMakeLists.txt @@ -306,6 +306,7 @@ elseif (ANDROID) COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0001-Android-Make-window-which-is-clicked-on-the-activate.patch COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0001-Android-Make-window-manager-a-bit-more-distinguishab.patch COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0001-Android-setBackingStore-of-a-window-if-the-platformW.patch + COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0001-Android-Fix-incorrect-handling-of-window-modality.patch COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0111-Fix-unbalanced-KeyPress-Release-events-in-children-o.patch COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0112-Fix-shortcuts-assigned-to-special-keys-on-non-latin-.patch diff --git a/libs/widgets/KisDlgInternalColorSelector.h b/libs/widgets/KisDlgInternalColorSelector.h index 26b6df0857b3f94a99c8c45441a8f752c8579248..a05c3064e48e4d9165e4d8cc8fd030d9c35fd191 100644 --- a/libs/widgets/KisDlgInternalColorSelector.h +++ b/libs/widgets/KisDlgInternalColorSelector.h @@ -41,11 +41,7 @@ public: struct Config { Config() : -#ifdef Q_OS_ANDROID - modal(false), -#else modal(true), -#endif visualColorSelector(true), paletteBox(true), screenColorSampler(true),