Search in sources :

Example 1 with WindowPanel

use of com.android.server.wm.WindowManagerService.WindowPanel in project cornerstone by Onskreen.

the class WindowState method computeShownFrameLocked.

void computeShownFrameLocked() {
    final boolean selfTransformation = mHasLocalTransformation;
    Transformation attachedTransformation = (mAttachedWindow != null && mAttachedWindow.mHasLocalTransformation) ? mAttachedWindow.mTransformation : null;
    Transformation appTransformation = (mAppToken != null && mAppToken.hasTransformation) ? mAppToken.transformation : null;
    // are currently targeting.
    if (mAttrs.type == TYPE_WALLPAPER && mService.mLowerWallpaperTarget == null && mService.mWallpaperTarget != null) {
        if (mService.mWallpaperTarget.mHasLocalTransformation && mService.mWallpaperTarget.mAnimation != null && !mService.mWallpaperTarget.mAnimation.getDetachWallpaper()) {
            attachedTransformation = mService.mWallpaperTarget.mTransformation;
            if (WindowManagerService.DEBUG_WALLPAPER && attachedTransformation != null) {
                Slog.v(WindowManagerService.TAG, "WP target attached xform: " + attachedTransformation);
            }
        }
        if (mService.mWallpaperTarget.mAppToken != null && mService.mWallpaperTarget.mAppToken.hasTransformation && mService.mWallpaperTarget.mAppToken.animation != null && !mService.mWallpaperTarget.mAppToken.animation.getDetachWallpaper()) {
            appTransformation = mService.mWallpaperTarget.mAppToken.transformation;
            if (WindowManagerService.DEBUG_WALLPAPER && appTransformation != null) {
                Slog.v(WindowManagerService.TAG, "WP target app xform: " + appTransformation);
            }
        }
    }
    final boolean screenAnimation = mService.mScreenRotationAnimation != null && mService.mScreenRotationAnimation.isAnimating();
    if (selfTransformation || attachedTransformation != null || appTransformation != null || screenAnimation) {
        // cache often used attributes locally
        final Rect frame = mFrame;
        final float[] tmpFloats = mService.mTmpFloats;
        final Matrix tmpMatrix = mTmpMatrix;
        // Compute the desired transformation.
        if (screenAnimation) {
            // If we are doing a screen animation, the global rotation
            // applied to windows can result in windows that are carefully
            // aligned with each other to slightly separate, allowing you
            // to see what is behind them.  An unsightly mess.  This...
            // thing...  magically makes it call good: scale each window
            // slightly (two pixels larger in each dimension, from the
            // window's center).
            final float w = frame.width();
            final float h = frame.height();
            if (w >= 1 && h >= 1) {
                tmpMatrix.setScale(1 + 2 / w, 1 + 2 / h, w / 2, h / 2);
            } else {
                tmpMatrix.reset();
            }
        } else {
            tmpMatrix.reset();
        }
        tmpMatrix.postScale(mGlobalScale, mGlobalScale);
        if (selfTransformation) {
            tmpMatrix.postConcat(mTransformation.getMatrix());
        }
        tmpMatrix.postTranslate(frame.left + mXOffset, frame.top + mYOffset);
        if (attachedTransformation != null) {
            tmpMatrix.postConcat(attachedTransformation.getMatrix());
        }
        if (appTransformation != null) {
            tmpMatrix.postConcat(appTransformation.getMatrix());
        }
        if (screenAnimation) {
            tmpMatrix.postConcat(mService.mScreenRotationAnimation.getEnterTransformation().getMatrix());
        }
        // "convert" it into SurfaceFlinger's format
        // (a 2x2 matrix + an offset)
        // Here we must not transform the position of the surface
        // since it is already included in the transformation.
        //Slog.i(TAG, "Transform: " + matrix);
        mHaveMatrix = true;
        tmpMatrix.getValues(tmpFloats);
        mDsDx = tmpFloats[Matrix.MSCALE_X];
        mDtDx = tmpFloats[Matrix.MSKEW_Y];
        mDsDy = tmpFloats[Matrix.MSKEW_X];
        mDtDy = tmpFloats[Matrix.MSCALE_Y];
        float x = tmpFloats[Matrix.MTRANS_X];
        float y = tmpFloats[Matrix.MTRANS_Y];
        int w = frame.width();
        int h = frame.height();
        mShownFrame.set(x, y, x + w, y + h);
        // Now set the alpha...  but because our current hardware
        // can't do alpha transformation on a non-opaque surface,
        // turn it off if we are running an animation that is also
        // transforming since it is more important to have that
        // animation be smooth.
        mShownAlpha = mAlpha;
        if (!mService.mLimitedAlphaCompositing || (!PixelFormat.formatHasAlpha(mAttrs.format) || (isIdentityMatrix(mDsDx, mDtDx, mDsDy, mDtDy) && x == frame.left && y == frame.top))) {
            //Slog.i(TAG, "Applying alpha transform");
            if (selfTransformation) {
                mShownAlpha *= mTransformation.getAlpha();
            }
            if (attachedTransformation != null) {
                mShownAlpha *= attachedTransformation.getAlpha();
            }
            if (appTransformation != null) {
                mShownAlpha *= appTransformation.getAlpha();
            }
            if (screenAnimation) {
                mShownAlpha *= mService.mScreenRotationAnimation.getEnterTransformation().getAlpha();
            }
        } else {
        //Slog.i(TAG, "Not applying alpha transform");
        }
        if (WindowManagerService.localLOGV)
            Slog.v(WindowManagerService.TAG, "Continuing animation in " + this + ": " + mShownFrame + ", alpha=" + mTransformation.getAlpha());
        return;
    }
    /**
	 * Author: Onskreen
	 * Date: 25/02/2011
	 *
	 * When the cornerstone is in a state change we know there is an animation. At the end
	 * of which we want the cornerstone and cornerstone panels to remain in there final
	 * animated positions, not the original position they started in (which is what
	 * happens with no changes to the logic here).
	 *
	 * We are relying on the fact that the cornerstone is always at the bottom of the
	 * mWindows, so not unsetting mCornerstoneStateChange flag until we encounter it
	 * after the animation is complete.
	 */
    if (//Cornerstone is active
    mService.mCornerstoneState != Cornerstone_State.TERMINATED && //In the midst of a cornerstone state change
    mService.mCornerstoneStateChangeAnimating && mAppToken != null) {
        //Ignore non app tokens
        WindowPanel wp = mService.findWindowPanel(this.mAppToken.token);
        if (wp != null) {
            //just in case...
            if (DEBUG_CORNERSTONE) {
                Slog.v(WindowManagerService.TAG, "WindowState.computeShownFrameLocked for: " + this);
                Slog.v(WindowManagerService.TAG, "mCornerstoneStateChangeProcessing: " + mService.mCornerstoneStateChangeProcessing);
                Slog.v(WindowManagerService.TAG, "mCornerstoneStateChangeAnimating: " + mService.mCornerstoneStateChangeAnimating);
                Slog.v(WindowManagerService.TAG, "WP: " + wp);
                Slog.v(WindowManagerService.TAG, "mFrame: " + mFrame);
                Slog.v(WindowManagerService.TAG, "mShownFrame: " + mShownFrame);
            }
            /**
				 * Cornerstone and panels should be locked to their final
				 * animated position.
				 */
            if (wp.isCornerstone() || wp.isCornerstonePanel() && mAnimating == false) {
                //Only lock the frame at the end of the animation
                if (DEBUG_CORNERSTONE) {
                    Slog.v(WindowManagerService.TAG, "Animation complete, locking frames");
                }
                Rect rect = mService.computeWindowPanelRect(wp, mService.mCurConfiguration.orientation, mService.mCornerstoneState);
                if (DEBUG_CORNERSTONE) {
                    Slog.v(WindowManagerService.TAG, "Updating " + wp + " to: " + rect);
                }
                wp.setFrame(rect);
                if (wp.isCornerstone()) {
                    if (DEBUG_CORNERSTONE)
                        Slog.v(WindowManagerService.TAG, "Setting mCornerstoneStateChangeAnimating to False");
                    mService.mCornerstoneStateChangeAnimating = false;
                }
            }
        }
    }
    mShownFrame.set(mFrame);
    if (mXOffset != 0 || mYOffset != 0) {
        mShownFrame.offset(mXOffset, mYOffset);
    }
    mShownAlpha = mAlpha;
    mHaveMatrix = false;
    mDsDx = mGlobalScale;
    mDtDx = 0;
    mDsDy = 0;
    mDtDy = mGlobalScale;
}
Also used : Transformation(android.view.animation.Transformation) Rect(android.graphics.Rect) Matrix(android.graphics.Matrix) WindowPanel(com.android.server.wm.WindowManagerService.WindowPanel)

Example 2 with WindowPanel

use of com.android.server.wm.WindowManagerService.WindowPanel in project cornerstone by Onskreen.

the class WindowAnimator method startDimming.

void startDimming(final WindowStateAnimator winAnimator, final float target, final int width, final int height) {
    if (mDimAnimator == null) {
        mDimAnimator = new DimAnimator(mService.mFxSession);
    }
    // Only set dim params on the highest dimmed layer.
    final WindowStateAnimator dimWinAnimator = mDimParams == null ? null : mDimParams.mDimWinAnimator;
    // Don't turn on for an unshown surface, or for any layer but the highest dimmed one.
    if (winAnimator.mSurfaceShown && (dimWinAnimator == null || !dimWinAnimator.mSurfaceShown || dimWinAnimator.mAnimLayer < winAnimator.mAnimLayer)) {
        /**
             * Author: Onskreen
             * Date: 21/12/2012
             *
             * Sets the dimming rect and position as per panel(main or
             * either of cornerstone panels)'s current position in which
             * this window is running.
             */
        if (winAnimator.mWin != null) {
            if (winAnimator.mWin.mAppToken != null) {
                IBinder token = winAnimator.mWin.mAppToken.token;
                if (token != null) {
                    WindowPanel wp = mService.findWindowPanel(token);
                    if (wp != null) {
                        Rect dimRect = new Rect();
                        dimRect.set(wp.getPos());
                        mDimAnimator.mDimX = dimRect.left;
                        mDimAnimator.mDimY = dimRect.top;
                        mService.mH.sendMessage(mService.mH.obtainMessage(SET_DIM_PARAMETERS, new DimAnimator.Parameters(winAnimator, dimRect.width(), dimRect.height(), target)));
                    } else {
                        mService.mH.sendMessage(mService.mH.obtainMessage(SET_DIM_PARAMETERS, new DimAnimator.Parameters(winAnimator, width, height, target)));
                    }
                } else {
                    mService.mH.sendMessage(mService.mH.obtainMessage(SET_DIM_PARAMETERS, new DimAnimator.Parameters(winAnimator, width, height, target)));
                }
            } else {
                mService.mH.sendMessage(mService.mH.obtainMessage(SET_DIM_PARAMETERS, new DimAnimator.Parameters(winAnimator, width, height, target)));
            }
        } else {
            mService.mH.sendMessage(mService.mH.obtainMessage(SET_DIM_PARAMETERS, new DimAnimator.Parameters(winAnimator, width, height, target)));
        }
    }
}
Also used : IBinder(android.os.IBinder) Rect(android.graphics.Rect) WindowPanel(com.android.server.wm.WindowManagerService.WindowPanel)

Example 3 with WindowPanel

use of com.android.server.wm.WindowManagerService.WindowPanel in project cornerstone by Onskreen.

the class WindowStateAnimator method computeShownFrameLocked.

void computeShownFrameLocked() {
    final boolean selfTransformation = mHasLocalTransformation;
    Transformation attachedTransformation = (mAttachedWindow != null && mAttachedWindow.mWinAnimator.mHasLocalTransformation) ? mAttachedWindow.mWinAnimator.mTransformation : null;
    final AppWindowAnimator appAnimator = mWin.mAppToken == null ? null : mWin.mAppToken.mAppAnimator;
    Transformation appTransformation = (appAnimator != null && appAnimator.hasTransformation) ? appAnimator.transformation : null;
    // are currently targeting.
    if (mWin.mAttrs.type == TYPE_WALLPAPER && mService.mLowerWallpaperTarget == null && mService.mWallpaperTarget != null) {
        if (mService.mWallpaperTarget.mWinAnimator.mHasLocalTransformation && mService.mWallpaperTarget.mWinAnimator.mAnimation != null && !mService.mWallpaperTarget.mWinAnimator.mAnimation.getDetachWallpaper()) {
            attachedTransformation = mService.mWallpaperTarget.mWinAnimator.mTransformation;
            if (WindowManagerService.DEBUG_WALLPAPER && attachedTransformation != null) {
                Slog.v(TAG, "WP target attached xform: " + attachedTransformation);
            }
        }
        final AppWindowAnimator wpAppAnimator = mService.mWallpaperTarget.mAppToken == null ? null : mService.mWallpaperTarget.mAppToken.mAppAnimator;
        if (wpAppAnimator != null && wpAppAnimator.hasTransformation && wpAppAnimator.animation != null && !wpAppAnimator.animation.getDetachWallpaper()) {
            appTransformation = wpAppAnimator.transformation;
            if (WindowManagerService.DEBUG_WALLPAPER && appTransformation != null) {
                Slog.v(TAG, "WP target app xform: " + appTransformation);
            }
        }
    }
    final boolean screenAnimation = mService.mAnimator.mScreenRotationAnimation != null && mService.mAnimator.mScreenRotationAnimation.isAnimating();
    if (selfTransformation || attachedTransformation != null || appTransformation != null || screenAnimation) {
        // cache often used attributes locally
        final Rect frame = mWin.mFrame;
        final float[] tmpFloats = mService.mTmpFloats;
        final Matrix tmpMatrix = mWin.mTmpMatrix;
        // Compute the desired transformation.
        if (screenAnimation) {
            // If we are doing a screen animation, the global rotation
            // applied to windows can result in windows that are carefully
            // aligned with each other to slightly separate, allowing you
            // to see what is behind them.  An unsightly mess.  This...
            // thing...  magically makes it call good: scale each window
            // slightly (two pixels larger in each dimension, from the
            // window's center).
            final float w = frame.width();
            final float h = frame.height();
            if (w >= 1 && h >= 1) {
                tmpMatrix.setScale(1 + 2 / w, 1 + 2 / h, w / 2, h / 2);
            } else {
                tmpMatrix.reset();
            }
        } else {
            tmpMatrix.reset();
        }
        tmpMatrix.postScale(mWin.mGlobalScale, mWin.mGlobalScale);
        if (selfTransformation) {
            tmpMatrix.postConcat(mTransformation.getMatrix());
        }
        tmpMatrix.postTranslate(frame.left + mWin.mXOffset, frame.top + mWin.mYOffset);
        if (attachedTransformation != null) {
            tmpMatrix.postConcat(attachedTransformation.getMatrix());
        }
        if (appTransformation != null) {
            tmpMatrix.postConcat(appTransformation.getMatrix());
        }
        if (screenAnimation) {
            tmpMatrix.postConcat(mService.mAnimator.mScreenRotationAnimation.getEnterTransformation().getMatrix());
        }
        // "convert" it into SurfaceFlinger's format
        // (a 2x2 matrix + an offset)
        // Here we must not transform the position of the surface
        // since it is already included in the transformation.
        //Slog.i(TAG, "Transform: " + matrix);
        mHaveMatrix = true;
        tmpMatrix.getValues(tmpFloats);
        mDsDx = tmpFloats[Matrix.MSCALE_X];
        mDtDx = tmpFloats[Matrix.MSKEW_Y];
        mDsDy = tmpFloats[Matrix.MSKEW_X];
        mDtDy = tmpFloats[Matrix.MSCALE_Y];
        float x = tmpFloats[Matrix.MTRANS_X];
        float y = tmpFloats[Matrix.MTRANS_Y];
        int w = frame.width();
        int h = frame.height();
        mWin.mShownFrame.set(x, y, x + w, y + h);
        // Now set the alpha...  but because our current hardware
        // can't do alpha transformation on a non-opaque surface,
        // turn it off if we are running an animation that is also
        // transforming since it is more important to have that
        // animation be smooth.
        mShownAlpha = mAlpha;
        if (!mService.mLimitedAlphaCompositing || (!PixelFormat.formatHasAlpha(mWin.mAttrs.format) || (mWin.isIdentityMatrix(mDsDx, mDtDx, mDsDy, mDtDy) && x == frame.left && y == frame.top))) {
            //Slog.i(TAG, "Applying alpha transform");
            if (selfTransformation) {
                mShownAlpha *= mTransformation.getAlpha();
            }
            if (attachedTransformation != null) {
                mShownAlpha *= attachedTransformation.getAlpha();
            }
            if (appTransformation != null) {
                mShownAlpha *= appTransformation.getAlpha();
            }
            if (screenAnimation) {
                mShownAlpha *= mService.mAnimator.mScreenRotationAnimation.getEnterTransformation().getAlpha();
            }
        } else {
        //Slog.i(TAG, "Not applying alpha transform");
        }
        if (WindowManagerService.localLOGV && (mShownAlpha == 1.0 || mShownAlpha == 0.0))
            Slog.v(TAG, "computeShownFrameLocked: Animating " + this + " mAlpha=" + mAlpha + " self=" + (selfTransformation ? mTransformation.getAlpha() : "null") + " attached=" + (attachedTransformation == null ? "null" : attachedTransformation.getAlpha()) + " app=" + (appTransformation == null ? "null" : appTransformation.getAlpha()) + " screen=" + (screenAnimation ? mService.mAnimator.mScreenRotationAnimation.getEnterTransformation().getAlpha() : "null"));
        return;
    } else if (mWin.mIsWallpaper && (mAnimator.mPendingActions & WindowAnimator.WALLPAPER_ACTION_PENDING) != 0) {
        return;
    }
    if (WindowManagerService.localLOGV)
        Slog.v(TAG, "computeShownFrameLocked: " + this + " not attached, mAlpha=" + mAlpha);
    /**
         * Author: Onskreen
         * Date: 25/02/2011
         *
         * When the cornerstone is in a state change we know there is an animation. At the end
         * of which we want the cornerstone and cornerstone panels to remain in there final
         * animated positions, not the original position they started in (which is what
         * happens with no changes to the logic here).
         *
         * We are relying on the fact that the cornerstone is always at the bottom of the
         * mWindows, so not unsetting mCornerstoneStateChange flag until we encounter it
         * after the animation is complete.
         */
    if (//Cornerstone is active
    mService.mCornerstoneState != Cornerstone_State.TERMINATED && //In the midst of a cornerstone state change
    mService.mCornerstoneStateChangeAnimating && mWin.mAppToken != null) {
        //Ignore non app tokens
        WindowPanel wp = mService.findWindowPanel(mWin.mAppToken.token);
        if (wp != null) {
            //just in case...
            if (WindowManagerService.DEBUG_CORNERSTONE) {
                Slog.v(WindowManagerService.TAG, "WindowState.computeShownFrameLocked for: " + this);
                Slog.v(WindowManagerService.TAG, "mCornerstoneStateChangeProcessing: " + mService.mCornerstoneStateChangeProcessing);
                Slog.v(WindowManagerService.TAG, "mCornerstoneStateChangeAnimating: " + mService.mCornerstoneStateChangeAnimating);
                Slog.v(WindowManagerService.TAG, "WP: " + wp);
                Slog.v(WindowManagerService.TAG, "mFrame: " + mWin.mFrame);
                Slog.v(WindowManagerService.TAG, "mShownFrame: " + mWin.mShownFrame);
            }
            /**
				 * Cornerstone and panels should be locked to their final
				 * animated position.
				 */
            if (wp.isCornerstone() || wp.isCornerstonePanel() && mAnimating == false) {
                //Only lock the frame at the end of the animation
                if (WindowManagerService.DEBUG_CORNERSTONE) {
                    Slog.v(WindowManagerService.TAG, "Animation complete, locking frames");
                }
                Rect rect = mService.computeWindowPanelRect(wp, mService.mCurConfiguration.orientation, mService.mCornerstoneState);
                if (WindowManagerService.DEBUG_CORNERSTONE) {
                    Slog.v(WindowManagerService.TAG, "Updating " + wp + " to: " + rect);
                }
                wp.setFrame(rect);
                if (wp.isCornerstone()) {
                    if (WindowManagerService.DEBUG_CORNERSTONE)
                        Slog.v(WindowManagerService.TAG, "Setting mCornerstoneStateChangeAnimating to False");
                    mService.mCornerstoneStateChangeAnimating = false;
                }
            }
        }
    }
    mWin.mShownFrame.set(mWin.mFrame);
    if (mWin.mXOffset != 0 || mWin.mYOffset != 0) {
        mWin.mShownFrame.offset(mWin.mXOffset, mWin.mYOffset);
    }
    mShownAlpha = mAlpha;
    mHaveMatrix = false;
    mDsDx = mWin.mGlobalScale;
    mDtDx = 0;
    mDsDy = 0;
    mDtDy = mWin.mGlobalScale;
}
Also used : Transformation(android.view.animation.Transformation) Rect(android.graphics.Rect) Matrix(android.graphics.Matrix) WindowPanel(com.android.server.wm.WindowManagerService.WindowPanel) Point(android.graphics.Point)

Example 4 with WindowPanel

use of com.android.server.wm.WindowManagerService.WindowPanel in project cornerstone by Onskreen.

the class WindowState method computeFrameLw.

@Override
public void computeFrameLw(Rect pf, Rect df, Rect cf, Rect vf) {
    mHaveFrame = true;
    final Rect container = mContainingFrame;
    container.set(pf);
    final Rect display = mDisplayFrame;
    display.set(df);
    /**
         * Author: Onskreen
         * Date: 08/04/2011
         *
         * This block commented out.
         * Compatibility mode is not yet fully supported. It causes issues on the
         * Viewsonic. Until we fully evaluate this feature, we are
         * laying out the same regardless of compatibility mode being set or not
         * by the WindowState. Assumedly, This will have to be reverted when we fully
         * support compatibility mode.
         *
         */
    /*if ((mAttrs.flags & FLAG_COMPATIBLE_WINDOW) != 0) {
			container.intersect(mCompatibleScreenFrame);
			if ((mAttrs.flags & FLAG_LAYOUT_NO_LIMITS) == 0) {
			    display.intersect(mCompatibleScreenFrame);
			}
		}*/
    final int pw = container.right - container.left;
    final int ph = container.bottom - container.top;
    int w, h;
    if ((mAttrs.flags & WindowManager.LayoutParams.FLAG_SCALED) != 0) {
        if (mAttrs.width < 0) {
            w = pw;
        } else if (mEnforceSizeCompat) {
            w = (int) (mAttrs.width * mGlobalScale + .5f);
        } else {
            w = mAttrs.width;
        }
        if (mAttrs.height < 0) {
            h = ph;
        } else if (mEnforceSizeCompat) {
            h = (int) (mAttrs.height * mGlobalScale + .5f);
        } else {
            h = mAttrs.height;
        }
    } else {
        if (mAttrs.width == WindowManager.LayoutParams.MATCH_PARENT) {
            w = pw;
        } else if (mEnforceSizeCompat) {
            w = (int) (mRequestedWidth * mGlobalScale + .5f);
        } else {
            w = mRequestedWidth;
        }
        if (mAttrs.height == WindowManager.LayoutParams.MATCH_PARENT) {
            h = ph;
        } else if (mEnforceSizeCompat) {
            h = (int) (mRequestedHeight * mGlobalScale + .5f);
        } else {
            h = mRequestedHeight;
        }
    }
    /**
         * Author: Onskreen
         * Date: 03/08/2011
         *
         * When width(w) and height(h) of the window frame exceeds the container rect's
         * width(pw) and height(ph), we should set the width(w) and height(h) of the window
         * frame to the actual container rect. It's been exprienced that when apps like YouTube
         * runs in to portrait mode in either cs panels, it renders outside of its layout
         * rect and to overcome that issue, we're setting the width of frame to its container
         * rect's width. This solution renders the Youtube app within its layout rect but for
         * some unknown reason when video is playing, it doesn't render by covering the width
         * of the cs panel window.
         */
    if (w > pw && h > ph) {
        w = pw;
        //h = ph;
        if (mAttrs.x < 0) {
            mAttrs.x = 0;
        }
        mRequestedWidth = w;
    }
    if (!mParentFrame.equals(pf)) {
        //Slog.i(TAG, "Window " + this + " content frame from " + mParentFrame
        //        + " to " + pf);
        mParentFrame.set(pf);
        mContentChanged = true;
    }
    if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) {
        mLastRequestedWidth = mRequestedWidth;
        mLastRequestedHeight = mRequestedHeight;
        mContentChanged = true;
    }
    final Rect content = mContentFrame;
    content.set(cf);
    final Rect visible = mVisibleFrame;
    visible.set(vf);
    final Rect frame = mFrame;
    final int fw = frame.width();
    final int fh = frame.height();
    //System.out.println("In: w=" + w + " h=" + h + " container=" +
    //                   container + " x=" + mAttrs.x + " y=" + mAttrs.y);
    float x, y;
    if (mEnforceSizeCompat) {
        x = mAttrs.x * mGlobalScale;
        y = mAttrs.y * mGlobalScale;
    } else {
        x = mAttrs.x;
        y = mAttrs.y;
    }
    Gravity.apply(mAttrs.gravity, w, h, container, (int) (x + mAttrs.horizontalMargin * pw), (int) (y + mAttrs.verticalMargin * ph), frame);
    //System.out.println("Out: " + mFrame);
    // Now make sure the window fits in the overall display.
    Gravity.applyDisplay(mAttrs.gravity, df, frame);
    /**
         * Author: Onskreen
         * Date: 16/12/2011
         *
         * When user launches actionbar menu or types in search/address
         * bar in browser app in either cs panels, then such Windows
         * mFrame was set or calculated outside the total screen area
         * after the Gravity applied by the above code. This can be
         * resolved by setting the frame rect to fit into its container
         * rect.
         */
    if (this.mAppToken != null) {
        WindowPanel wp = mService.findWindowPanel(this.mAppToken.token);
        if (wp != null) {
            if (wp.isCornerstonePanel() && mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL && (frame.left > container.left || frame.bottom < container.bottom)) {
                frame.left = container.right - w;
                frame.right = container.right;
                /**
                    * Author: Onskreen
                    * Date: 04/01/2013
                    *
                    * Resetting frame's top and bottom positions
                    * of Action bar window.
                    */
                if (frame.bottom > container.bottom) {
                    frame.top = container.top + 44;
                    int diff = 0;
                    if (mRequestedHeight > ph) {
                        diff = mRequestedHeight - ph;
                    } else {
                        diff = ph - mRequestedHeight;
                    }
                    frame.bottom = container.bottom + diff + 44;
                }
                /**
                    * Author: Onskreen
                    * Date: 04/01/2013
                    *
                    * Resetting frame's top and bottom positions
                    * of attached windows such as Browser app's
                    * auto-complete PopupWindow.
                    */
                if (frame.top < container.top) {
                    frame.top = container.top + 50;
                    frame.bottom = mRequestedHeight + container.top + 50;
                }
            //mRequestedHeight = frame.bottom - frame.top;
            //h = mRequestedHeight;
            }
        }
    }
    // final window frame.
    if (content.left < frame.left)
        content.left = frame.left;
    if (content.top < frame.top)
        content.top = frame.top;
    if (content.right > frame.right)
        content.right = frame.right;
    if (content.bottom > frame.bottom)
        content.bottom = frame.bottom;
    if (visible.left < frame.left)
        visible.left = frame.left;
    if (visible.top < frame.top)
        visible.top = frame.top;
    if (visible.right > frame.right)
        visible.right = frame.right;
    if (visible.bottom > frame.bottom)
        visible.bottom = frame.bottom;
    final Rect contentInsets = mContentInsets;
    contentInsets.left = content.left - frame.left;
    contentInsets.top = content.top - frame.top;
    contentInsets.right = frame.right - content.right;
    contentInsets.bottom = frame.bottom - content.bottom;
    final Rect visibleInsets = mVisibleInsets;
    visibleInsets.left = visible.left - frame.left;
    visibleInsets.top = visible.top - frame.top;
    visibleInsets.right = frame.right - visible.right;
    visibleInsets.bottom = frame.bottom - visible.bottom;
    mCompatFrame.set(frame);
    if (mEnforceSizeCompat) {
        // If there is a size compatibility scale being applied to the
        // window, we need to apply this to its insets so that they are
        // reported to the app in its coordinate space.
        contentInsets.scale(mInvGlobalScale);
        visibleInsets.scale(mInvGlobalScale);
        // Also the scaled frame that we report to the app needs to be
        // adjusted to be in its coordinate space.
        mCompatFrame.scale(mInvGlobalScale);
    }
    if (mIsWallpaper && (fw != frame.width() || fh != frame.height())) {
        mService.updateWallpaperOffsetLocked(this, mService.mAppDisplayWidth, mService.mAppDisplayHeight, false);
    }
    if (WindowManagerService.localLOGV) {
        //if ("com.google.android.youtube".equals(mAttrs.packageName)
        //        && mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
        Slog.v(TAG, "Resolving (mRequestedWidth=" + mRequestedWidth + ", mRequestedheight=" + mRequestedHeight + ") to" + " (pw=" + pw + ", ph=" + ph + "): frame=" + mFrame.toShortString() + " ci=" + contentInsets.toShortString() + " vi=" + visibleInsets.toShortString());
    //}
    }
}
Also used : Rect(android.graphics.Rect) WindowPanel(com.android.server.wm.WindowManagerService.WindowPanel)

Aggregations

Rect (android.graphics.Rect)4 WindowPanel (com.android.server.wm.WindowManagerService.WindowPanel)4 Matrix (android.graphics.Matrix)2 Transformation (android.view.animation.Transformation)2 Point (android.graphics.Point)1 IBinder (android.os.IBinder)1