summaryrefslogtreecommitdiff
path: root/core/java/android/view/ViewRootImpl.java
diff options
context:
space:
mode:
authorCraig Mautner <cmautner@google.com>2012-07-10 14:48:06 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-07-10 14:48:06 -0700
commitfbf885b652272013f44da71e9f77923333bf62eb (patch)
tree5ab64f7642664a172c5bfaceea554be329b21a3d /core/java/android/view/ViewRootImpl.java
parentdb30781663bb907ed6a0915979bc86e1e063d909 (diff)
parent5702d4dfb5b81491f873a3617f8d8fc8dc5279e6 (diff)
Merge "Notify client side of window movement."
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 9798877a815d..85b6d3df72c6 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -2717,6 +2717,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
@@ -2768,6 +2769,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);
}
@@ -2812,6 +2815,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;
@@ -2828,6 +2832,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;
@@ -4047,6 +4068,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.
*
@@ -4686,6 +4719,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) {