Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c58de3a authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Add system insets to windows.

This will be used to determine which parts of a window a completely
hidden by system UI elements (status bar, nav bar, system bar) so
that they can be clipped out from rendering.

Change-Id: I2c6c6ac67dbdfeed82d2c089ef806fb483165bd9
parent 3ea87619
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -154,6 +154,7 @@ public abstract class WallpaperService extends Service {
        int mCurWindowPrivateFlags = mWindowPrivateFlags;
        int mCurWindowPrivateFlags = mWindowPrivateFlags;
        final Rect mVisibleInsets = new Rect();
        final Rect mVisibleInsets = new Rect();
        final Rect mWinFrame = new Rect();
        final Rect mWinFrame = new Rect();
        final Rect mSystemInsets = new Rect();
        final Rect mContentInsets = new Rect();
        final Rect mContentInsets = new Rect();
        final Configuration mConfiguration = new Configuration();
        final Configuration mConfiguration = new Configuration();
        
        
@@ -253,7 +254,7 @@ public abstract class WallpaperService extends Service {


        final BaseIWindow mWindow = new BaseIWindow() {
        final BaseIWindow mWindow = new BaseIWindow() {
            @Override
            @Override
            public void resized(int w, int h, Rect coveredInsets,
            public void resized(int w, int h, Rect systemInsets, Rect contentInsets,
                    Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
                    Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
                Message msg = mCaller.obtainMessageI(MSG_WINDOW_RESIZED,
                Message msg = mCaller.obtainMessageI(MSG_WINDOW_RESIZED,
                        reportDraw ? 1 : 0);
                        reportDraw ? 1 : 0);
@@ -620,7 +621,7 @@ public abstract class WallpaperService extends Service {


                    final int relayoutResult = mSession.relayout(
                    final int relayoutResult = mSession.relayout(
                        mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
                        mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
                            View.VISIBLE, 0, mWinFrame, mContentInsets,
                            View.VISIBLE, 0, mWinFrame, mSystemInsets, mContentInsets,
                            mVisibleInsets, mConfiguration, mSurfaceHolder.mSurface);
                            mVisibleInsets, mConfiguration, mSurfaceHolder.mSurface);


                    if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface
                    if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface
+2 −2
Original line number Original line Diff line number Diff line
@@ -45,8 +45,8 @@ oneway interface IWindow {
     */
     */
    void executeCommand(String command, String parameters, in ParcelFileDescriptor descriptor);
    void executeCommand(String command, String parameters, in ParcelFileDescriptor descriptor);


    void resized(int w, int h, in Rect coveredInsets, in Rect visibleInsets,
    void resized(int w, int h, in Rect systemInsets, in Rect contentInsets,
            boolean reportDraw, in Configuration newConfig);
            in Rect visibleInsets, boolean reportDraw, in Configuration newConfig);
    void dispatchAppVisibility(boolean visible);
    void dispatchAppVisibility(boolean visible);
    void dispatchGetNewSurface();
    void dispatchGetNewSurface();
    void dispatchScreenState(boolean on);
    void dispatchScreenState(boolean on);
+7 −3
Original line number Original line Diff line number Diff line
@@ -58,6 +58,10 @@ interface IWindowSession {
     * {@link WindowManagerImpl#RELAYOUT_DEFER_SURFACE_DESTROY}.
     * {@link WindowManagerImpl#RELAYOUT_DEFER_SURFACE_DESTROY}.
     * @param outFrame Rect in which is placed the new position/size on
     * @param outFrame Rect in which is placed the new position/size on
     * screen.
     * screen.
     * @param outSystemInsets Rect in which is placed the offsets from
     * <var>outFrame</var> over which any core system UI elements are
     * currently covering the window.  This is not generally used for
     * layout, but just to know where the window is obscured.
     * @param outContentInsets Rect in which is placed the offsets from
     * @param outContentInsets Rect in which is placed the offsets from
     * <var>outFrame</var> in which the content of the window should be
     * <var>outFrame</var> in which the content of the window should be
     * placed.  This can be used to modify the window layout to ensure its
     * placed.  This can be used to modify the window layout to ensure its
@@ -79,9 +83,9 @@ interface IWindowSession {
     */
     */
    int relayout(IWindow window, int seq, in WindowManager.LayoutParams attrs,
    int relayout(IWindow window, int seq, in WindowManager.LayoutParams attrs,
            int requestedWidth, int requestedHeight, int viewVisibility,
            int requestedWidth, int requestedHeight, int viewVisibility,
            int flags, out Rect outFrame, out Rect outContentInsets,
            int flags, out Rect outFrame, out Rect outSystemInsets,
            out Rect outVisibleInsets, out Configuration outConfig,
            out Rect outContentInsets, out Rect outVisibleInsets,
            out Surface outSurface);
            out Configuration outConfig, out Surface outSurface);


    /**
    /**
     * If a call to relayout() asked to have the surface destroy deferred,
     * If a call to relayout() asked to have the surface destroy deferred,
+3 −2
Original line number Original line Diff line number Diff line
@@ -98,6 +98,7 @@ public class SurfaceView extends View {
    MyWindow mWindow;
    MyWindow mWindow;
    final Rect mVisibleInsets = new Rect();
    final Rect mVisibleInsets = new Rect();
    final Rect mWinFrame = new Rect();
    final Rect mWinFrame = new Rect();
    final Rect mSystemInsets = new Rect();
    final Rect mContentInsets = new Rect();
    final Rect mContentInsets = new Rect();
    final Configuration mConfiguration = new Configuration();
    final Configuration mConfiguration = new Configuration();
    
    
@@ -471,7 +472,7 @@ public class SurfaceView extends View {
                        mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
                        mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
                            visible ? VISIBLE : GONE,
                            visible ? VISIBLE : GONE,
                            WindowManagerImpl.RELAYOUT_DEFER_SURFACE_DESTROY,
                            WindowManagerImpl.RELAYOUT_DEFER_SURFACE_DESTROY,
                            mWinFrame, mContentInsets,
                            mWinFrame, mSystemInsets, mContentInsets,
                            mVisibleInsets, mConfiguration, mNewSurface);
                            mVisibleInsets, mConfiguration, mNewSurface);
                    if ((relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0) {
                    if ((relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0) {
                        mReportDrawNeeded = true;
                        mReportDrawNeeded = true;
@@ -605,7 +606,7 @@ public class SurfaceView extends View {
            mSurfaceView = new WeakReference<SurfaceView>(surfaceView);
            mSurfaceView = new WeakReference<SurfaceView>(surfaceView);
        }
        }


        public void resized(int w, int h, Rect coveredInsets,
        public void resized(int w, int h, Rect systemInsets, Rect contentInsets,
                Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
                Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
            SurfaceView surfaceView = mSurfaceView.get();
            SurfaceView surfaceView = mSurfaceView.get();
            if (surfaceView != null) {
            if (surfaceView != null) {
+5 −4
Original line number Original line Diff line number Diff line
@@ -261,6 +261,7 @@ public final class ViewRootImpl implements ViewParent,


    final Rect mPendingVisibleInsets = new Rect();
    final Rect mPendingVisibleInsets = new Rect();
    final Rect mPendingContentInsets = new Rect();
    final Rect mPendingContentInsets = new Rect();
    final Rect mPendingSystemInsets = new Rect();
    final ViewTreeObserver.InternalInsetsInfo mLastGivenInsets
    final ViewTreeObserver.InternalInsetsInfo mLastGivenInsets
            = new ViewTreeObserver.InternalInsetsInfo();
            = new ViewTreeObserver.InternalInsetsInfo();


@@ -3841,7 +3842,7 @@ public final class ViewRootImpl implements ViewParent,
                (int) (mView.getMeasuredWidth() * appScale + 0.5f),
                (int) (mView.getMeasuredWidth() * appScale + 0.5f),
                (int) (mView.getMeasuredHeight() * appScale + 0.5f),
                (int) (mView.getMeasuredHeight() * appScale + 0.5f),
                viewVisibility, insetsPending ? WindowManagerImpl.RELAYOUT_INSETS_PENDING : 0,
                viewVisibility, insetsPending ? WindowManagerImpl.RELAYOUT_INSETS_PENDING : 0,
                mWinFrame, mPendingContentInsets, mPendingVisibleInsets,
                mWinFrame, mPendingSystemInsets, mPendingContentInsets, mPendingVisibleInsets,
                mPendingConfiguration, mSurface);
                mPendingConfiguration, mSurface);
        //Log.d(TAG, "<<<<<< BACK FROM relayout");
        //Log.d(TAG, "<<<<<< BACK FROM relayout");
        if (restore) {
        if (restore) {
@@ -4684,11 +4685,11 @@ public final class ViewRootImpl implements ViewParent,
            mViewAncestor = new WeakReference<ViewRootImpl>(viewAncestor);
            mViewAncestor = new WeakReference<ViewRootImpl>(viewAncestor);
        }
        }


        public void resized(int w, int h, Rect coveredInsets, Rect visibleInsets,
        public void resized(int w, int h, Rect systemInsets, Rect contentInsets,
                boolean reportDraw, Configuration newConfig) {
                Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
            final ViewRootImpl viewAncestor = mViewAncestor.get();
            final ViewRootImpl viewAncestor = mViewAncestor.get();
            if (viewAncestor != null) {
            if (viewAncestor != null) {
                viewAncestor.dispatchResized(w, h, coveredInsets, visibleInsets, reportDraw,
                viewAncestor.dispatchResized(w, h, contentInsets, visibleInsets, reportDraw,
                        newConfig);
                        newConfig);
            }
            }
        }
        }
Loading