summaryrefslogtreecommitdiffstats
path: root/src/android
diff options
context:
space:
mode:
authorPekka Gehör <pekka.gehor@qt.io>2022-06-14 13:43:37 +0300
committerPekka Gehör <pekka.gehor@qt.io>2022-06-29 16:02:55 +0300
commitc27cca5c3421b08253535cfcfb9dd414986c7653 (patch)
tree4c8e4af611e099cc17aadcb9501754c6f205dff8 /src/android
parent526d62ee90d549177920eb567cb951c4b553c630 (diff)
Android: fix wrong position of cursor handle and editpopup menu in split screen
Use activity location in the Window to handling a cursor handle and editpopup menu in Multi-Window mode. No effect when using full screen. Fixes: QTBUG-58503 Pick-to: 5.15 6.2 6.3 6.4 Change-Id: I17f3119be4c3dda2fca50156bf62c1260c2ea1f6 Reviewed-by: Samuel Mira <samuel.mira@qt.io> Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/android')
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/CursorHandle.java6
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/EditPopupMenu.java16
2 files changed, 16 insertions, 6 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/CursorHandle.java b/src/android/jar/src/org/qtproject/qt/android/CursorHandle.java
index 0b64f81335..b6d054d600 100644
--- a/src/android/jar/src/org/qtproject/qt/android/CursorHandle.java
+++ b/src/android/jar/src/org/qtproject/qt/android/CursorHandle.java
@@ -126,12 +126,14 @@ public class CursorHandle implements ViewTreeObserver.OnPreDrawListener
final int[] layoutLocation = new int[2];
m_layout.getLocationOnScreen(layoutLocation);
- // This value is used for handling split screen case
+ // These values are used for handling split screen case
final int[] activityLocation = new int[2];
+ final int[] activityLocationInWindow = new int[2];
m_activity.getWindow().getDecorView().getLocationOnScreen(activityLocation);
+ m_activity.getWindow().getDecorView().getLocationInWindow(activityLocationInWindow);
int x2 = x + layoutLocation[0] - activityLocation[0];
- int y2 = y + layoutLocation[1] + m_yShift - activityLocation[1];
+ int y2 = y + layoutLocation[1] + m_yShift + (activityLocationInWindow[1] - activityLocation[1]);
if (m_id == QtNative.IdCursorHandle) {
x2 -= m_popup.getWidth() / 2 ;
diff --git a/src/android/jar/src/org/qtproject/qt/android/EditPopupMenu.java b/src/android/jar/src/org/qtproject/qt/android/EditPopupMenu.java
index 41dca5f9df..00cbb97561 100644
--- a/src/android/jar/src/org/qtproject/qt/android/EditPopupMenu.java
+++ b/src/android/jar/src/org/qtproject/qt/android/EditPopupMenu.java
@@ -29,6 +29,7 @@ public class EditPopupMenu implements ViewTreeObserver.OnPreDrawListener, View.O
private View m_layout = null;
private EditContextView m_view = null;
private PopupWindow m_popup = null;
+ private Activity m_activity;
private int m_posX;
private int m_posY;
private int m_buttons;
@@ -38,6 +39,7 @@ public class EditPopupMenu implements ViewTreeObserver.OnPreDrawListener, View.O
public EditPopupMenu(Activity activity, View layout)
{
+ m_activity = activity;
m_view = new EditContextView(activity, this);
m_view.addOnLayoutChangeListener(this);
@@ -67,11 +69,17 @@ public class EditPopupMenu implements ViewTreeObserver.OnPreDrawListener, View.O
initOverlay();
m_view.updateButtons(buttons);
- final int[] location = new int[2];
- m_layout.getLocationOnScreen(location);
+ final int[] layoutLocation = new int[2];
+ m_layout.getLocationOnScreen(layoutLocation);
- int x2 = x + location[0];
- int y2 = y + location[1];
+ // These values are used for handling split screen case
+ final int[] activityLocation = new int[2];
+ final int[] activityLocationInWindow = new int[2];
+ m_activity.getWindow().getDecorView().getLocationOnScreen(activityLocation);
+ m_activity.getWindow().getDecorView().getLocationInWindow(activityLocationInWindow);
+
+ int x2 = x + layoutLocation[0] - activityLocation[0];
+ int y2 = y + layoutLocation[1] + (activityLocationInWindow[1] - activityLocation[1]);
x2 -= m_view.getWidth() / 2 ;