summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/ViewRootImpl.java46
-rw-r--r--core/java/com/android/internal/widget/NonClientDecorView.java39
2 files changed, 48 insertions, 37 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 7cf23e717f6e..c447c1415c36 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -141,10 +141,10 @@ public final class ViewRootImpl implements ViewParent,
static final ArrayList<Runnable> sFirstDrawHandlers = new ArrayList();
static boolean sFirstDrawComplete = false;
- static final ArrayList<WindowCallbacks> sWindowCallbacks = new ArrayList();
static final ArrayList<ComponentCallbacks> sConfigCallbacks = new ArrayList();
+ final ArrayList<WindowCallbacks> mWindowCallbacks = new ArrayList();
final Context mContext;
final IWindowSession mWindowSession;
final Display mDisplay;
@@ -424,18 +424,18 @@ public final class ViewRootImpl implements ViewParent,
}
}
- public static void addWindowCallbacks(WindowCallbacks callback) {
+ public void addWindowCallbacks(WindowCallbacks callback) {
if (USE_MT_RENDERER) {
- synchronized (sWindowCallbacks) {
- sWindowCallbacks.add(callback);
+ synchronized (mWindowCallbacks) {
+ mWindowCallbacks.add(callback);
}
}
}
- public static void removeWindowCallbacks(WindowCallbacks callback) {
+ public void removeWindowCallbacks(WindowCallbacks callback) {
if (USE_MT_RENDERER) {
- synchronized (sWindowCallbacks) {
- sWindowCallbacks.remove(callback);
+ synchronized (mWindowCallbacks) {
+ mWindowCallbacks.remove(callback);
}
}
}
@@ -5653,6 +5653,17 @@ public final class ViewRootImpl implements ViewParent,
+ " contentInsets=" + contentInsets.toShortString()
+ " visibleInsets=" + visibleInsets.toShortString()
+ " reportDraw=" + reportDraw);
+
+ // Tell all listeners that we are resizing the window so that the chrome can get
+ // updated as fast as possible on a separate thread,
+ if (mDragResizing) {
+ synchronized (mWindowCallbacks) {
+ for (int i = mWindowCallbacks.size() - 1; i >= 0; i--) {
+ mWindowCallbacks.get(i).onWindowSizeIsChanging(frame);
+ }
+ }
+ }
+
Message msg = mHandler.obtainMessage(reportDraw ? MSG_RESIZED_REPORT : MSG_RESIZED);
if (mTranslator != null) {
mTranslator.translateRectInScreenToAppWindow(frame);
@@ -6665,15 +6676,6 @@ public final class ViewRootImpl implements ViewParent,
Configuration newConfig) {
final ViewRootImpl viewAncestor = mViewAncestor.get();
if (viewAncestor != null) {
- // Tell all listeners that we are resizing the window so that the chrome can get
- // updated as fast as possible on a separate thread,
- if (mViewAncestor.get().mDragResizing) {
- synchronized (sWindowCallbacks) {
- for (int i = sWindowCallbacks.size() - 1; i >= 0; i--) {
- sWindowCallbacks.get(i).onWindowSizeIsChanging(frame);
- }
- }
- }
viewAncestor.dispatchResized(frame, overscanInsets, contentInsets,
visibleInsets, stableInsets, outsets, reportDraw, newConfig);
}
@@ -6848,9 +6850,9 @@ public final class ViewRootImpl implements ViewParent,
private void startDragResizing(Rect initialBounds) {
if (!mDragResizing) {
mDragResizing = true;
- synchronized (sWindowCallbacks) {
- for (int i = sWindowCallbacks.size() - 1; i >= 0; i--) {
- sWindowCallbacks.get(i).onWindowDragResizeStart(initialBounds);
+ synchronized (mWindowCallbacks) {
+ for (int i = mWindowCallbacks.size() - 1; i >= 0; i--) {
+ mWindowCallbacks.get(i).onWindowDragResizeStart(initialBounds);
}
}
mFullRedrawNeeded = true;
@@ -6863,9 +6865,9 @@ public final class ViewRootImpl implements ViewParent,
private void endDragResizing() {
if (mDragResizing) {
mDragResizing = false;
- synchronized (sWindowCallbacks) {
- for (int i = sWindowCallbacks.size() - 1; i >= 0; i--) {
- sWindowCallbacks.get(i).onWindowDragResizeEnd();
+ synchronized (mWindowCallbacks) {
+ for (int i = mWindowCallbacks.size() - 1; i >= 0; i--) {
+ mWindowCallbacks.get(i).onWindowDragResizeEnd();
}
}
mFullRedrawNeeded = true;
diff --git a/core/java/com/android/internal/widget/NonClientDecorView.java b/core/java/com/android/internal/widget/NonClientDecorView.java
index 7b80ac261d73..4689ffc902cd 100644
--- a/core/java/com/android/internal/widget/NonClientDecorView.java
+++ b/core/java/com/android/internal/widget/NonClientDecorView.java
@@ -110,6 +110,30 @@ public class NonClientDecorView extends LinearLayout
super(context, attrs, defStyle);
}
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ if (!mAttachedCallbacksToRootViewImpl) {
+ // If there is no window callback installed there was no window set before. Set it now.
+ // Note that our ViewRootImpl object will not change.
+ getViewRootImpl().addWindowCallbacks(this);
+ mAttachedCallbacksToRootViewImpl = true;
+ } else if (mFrameRendererThread != null) {
+ // We are resizing and this call happened due to a configuration change. Tell the
+ // renderer about it.
+ mFrameRendererThread.onConfigurationChange();
+ }
+ }
+
+ @Override
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ if (mAttachedCallbacksToRootViewImpl) {
+ getViewRootImpl().removeWindowCallbacks(this);
+ mAttachedCallbacksToRootViewImpl = false;
+ }
+ }
+
public void setPhoneWindow(PhoneWindow owner, boolean showDecor, boolean windowHasShadow) {
mOwner = owner;
mWindowHasShadow = windowHasShadow;
@@ -122,17 +146,6 @@ public class NonClientDecorView extends LinearLayout
// background without removing the shadow.
mOwner.getDecorView().setOutlineProvider(ViewOutlineProvider.BOUNDS);
- if (!mAttachedCallbacksToRootViewImpl) {
- // If there is no window callback installed there was no window set before. Set it now.
- // Note that our ViewRootImpl object will not change.
- getViewRootImpl().addWindowCallbacks(this);
- mAttachedCallbacksToRootViewImpl = true;
- } else if (mFrameRendererThread != null) {
- // We are resizing and this call happened due to a configuration change. Tell the
- // renderer about it.
- mFrameRendererThread.onConfigurationChange();
- }
-
findViewById(R.id.maximize_window).setOnClickListener(this);
findViewById(R.id.close_window).setOnClickListener(this);
}
@@ -372,10 +385,6 @@ public class NonClientDecorView extends LinearLayout
*/
private void releaseResources() {
releaseThreadedRenderer();
- if (mAttachedCallbacksToRootViewImpl) {
- ViewRootImpl.removeWindowCallbacks(this);
- mAttachedCallbacksToRootViewImpl = false;
- }
}
/**