summaryrefslogtreecommitdiff
path: root/core/java/android/view/ViewRootImpl.java
diff options
context:
space:
mode:
authorCraig Mautner <cmautner@google.com>2012-06-30 14:10:16 -0700
committerCraig Mautner <cmautner@google.com>2012-06-30 14:10:16 -0700
commit5702d4dfb5b81491f873a3617f8d8fc8dc5279e6 (patch)
treee9e9a95db55f1ee7ef8c3e9d5e807b083c53c59a /core/java/android/view/ViewRootImpl.java
parent5af65850eaa92c53be37a6973603b1f1e4f02a43 (diff)
Notify client side of window movement.
Add a one way method to notify Views that the window has moved on the screen. Fixes issues arising from the IME popping up and translating the window that uses it. Accessibility was left unaware of these movements and was drawing the box around the wrong widgets. Similarly PopupWindow used getLocationOnScreen to determine how much screen real estate was above and below the anchor point to determine where to put an anchored window. Fixes bug 6623031. Change-Id: I4731a94d5424c1ec77bf1729fba8fc9ea34cae46
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
-rw-r--r--core/java/android/view/ViewRootImpl.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 17783a49c9ea..97488bc930d8 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -2724,6 +2724,7 @@ public final class ViewRootImpl implements ViewParent,
private final static int MSG_CLEAR_ACCESSIBILITY_FOCUS_HOST = 22;
private final static int MSG_DISPATCH_DONE_ANIMATING = 23;
private final static int MSG_INVALIDATE_WORLD = 24;
+ private final static int MSG_WINDOW_MOVED = 25;
final class ViewRootHandler extends Handler {
@Override
@@ -2775,6 +2776,8 @@ public final class ViewRootImpl implements ViewParent,
return "MSG_CLEAR_ACCESSIBILITY_FOCUS_HOST";
case MSG_DISPATCH_DONE_ANIMATING:
return "MSG_DISPATCH_DONE_ANIMATING";
+ case MSG_WINDOW_MOVED:
+ return "MSG_WINDOW_MOVED";
}
return super.getMessageName(message);
}
@@ -2819,6 +2822,7 @@ public final class ViewRootImpl implements ViewParent,
if (config != null) {
updateConfiguration(config, false);
}
+ // TODO: Should left/top stay unchanged and only change the right/bottom?
mWinFrame.left = 0;
mWinFrame.right = msg.arg1;
mWinFrame.top = 0;
@@ -2835,6 +2839,23 @@ public final class ViewRootImpl implements ViewParent,
requestLayout();
}
break;
+ case MSG_WINDOW_MOVED:
+ if (mAdded) {
+ final int w = mWinFrame.width();
+ final int h = mWinFrame.height();
+ final int l = msg.arg1;
+ final int t = msg.arg2;
+ mWinFrame.left = l;
+ mWinFrame.right = l + w;
+ mWinFrame.top = t;
+ mWinFrame.bottom = t + h;
+
+ if (mView != null) {
+ forceLayout(mView);
+ }
+ requestLayout();
+ }
+ break;
case MSG_WINDOW_FOCUS_CHANGED: {
if (mAdded) {
boolean hasWindowFocus = msg.arg1 != 0;
@@ -4054,6 +4075,18 @@ public final class ViewRootImpl implements ViewParent,
mHandler.sendMessage(msg);
}
+ public void dispatchMoved(int newX, int newY) {
+ if (DEBUG_LAYOUT) Log.v(TAG, "Window moved " + this + ": newX=" + newX + " newY=" + newY);
+ if (mTranslator != null) {
+ PointF point = new PointF(newX, newY);
+ mTranslator.translatePointInScreenToAppWindow(point);
+ newX = (int) (point.x + 0.5);
+ newY = (int) (point.y + 0.5);
+ }
+ Message msg = mHandler.obtainMessage(MSG_WINDOW_MOVED, newX, newY);
+ mHandler.sendMessage(msg);
+ }
+
/**
* Represents a pending input event that is waiting in a queue.
*
@@ -4693,6 +4726,14 @@ public final class ViewRootImpl implements ViewParent,
}
}
+ @Override
+ public void moved(int newX, int newY) {
+ final ViewRootImpl viewAncestor = mViewAncestor.get();
+ if (viewAncestor != null) {
+ viewAncestor.dispatchMoved(newX, newY);
+ }
+ }
+
public void dispatchAppVisibility(boolean visible) {
final ViewRootImpl viewAncestor = mViewAncestor.get();
if (viewAncestor != null) {