summaryrefslogtreecommitdiffstats
path: root/src/android/jar/src/org/qtproject/qt5/android/CursorHandle.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/android/jar/src/org/qtproject/qt5/android/CursorHandle.java')
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/CursorHandle.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/android/jar/src/org/qtproject/qt5/android/CursorHandle.java b/src/android/jar/src/org/qtproject/qt5/android/CursorHandle.java
index 38cc695c37..7dbac0412b 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/CursorHandle.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/CursorHandle.java
@@ -124,8 +124,7 @@ public class CursorHandle implements ViewTreeObserver.OnPreDrawListener
m_id = id;
m_attr = attr;
m_layout = layout;
- DisplayMetrics metrics = new DisplayMetrics();
- activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
+ DisplayMetrics metrics = activity.getResources().getDisplayMetrics();
m_yShift = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_MM, 1f, metrics);
tolerance = Math.min(1, (int)(m_yShift / 2f));
m_lastX = m_lastY = -1 - tolerance;
@@ -159,11 +158,17 @@ public class CursorHandle implements ViewTreeObserver.OnPreDrawListener
public void setPosition(final int x, final int y){
initOverlay();
- final int[] location = new int[2];
- m_layout.getLocationOnScreen(location);
+ final int[] layoutLocation = new int[2];
+ m_layout.getLocationOnScreen(layoutLocation);
+
+ // 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 + location[0];
- int y2 = y + location[1] + m_yShift;
+ int x2 = x + layoutLocation[0] - activityLocation[0];
+ int y2 = y + layoutLocation[1] + m_yShift + (activityLocationInWindow[1] - activityLocation[1]);
if (m_id == QtNative.IdCursorHandle) {
x2 -= m_popup.getWidth() / 2 ;
@@ -198,6 +203,10 @@ public class CursorHandle implements ViewTreeObserver.OnPreDrawListener
}
}
+ public int width() {
+ return m_cursorView.getDrawable().getIntrinsicWidth();
+ }
+
// The handle was dragged by a given relative position
public void updatePosition(int x, int y) {
y -= m_yShift;