diff options
| author | Wale Ogunwale <ogunwale@google.com> | 2017-07-27 02:56:23 -0700 |
|---|---|---|
| committer | Wale Ogunwale <ogunwale@google.com> | 2017-08-22 06:53:01 -0700 |
| commit | 687b42733412a1bf482801f9544b6f8911c6a213 (patch) | |
| tree | 9b7800bac8c5a092d446399a8e763e920acfbcd6 /core/java/android/app/WindowConfiguration.java | |
| parent | 249a45363a00e325ea383538f62dc31edc7e085c (diff) | |
Introducing windowing mode in WindowConfiguration.
Currently Stacks (specifically their ids) are used to determine
windowing mode for activities. This isn't flexible when it comes
to changing/mixing various windowing modes at different levels
of the window hierarchy. E.g. how do you have the non-default
display support freeform or split-screen or how do you
interleave freeform windows with fullscreen windows.
To help with this problem we are introducing windowing mode
in WindowConfiguration that can be used to set the windowing
mode for any WindowContainer in the hierarchy.
Currently all displays are set to fullscreen windowing mode and
stacks windowing modes are set based on their id.
Test: bit FrameworksServicesTests:com.android.server.wm.WindowConfigurationTests
Test: adb shell am instrument -w -e package com.android.server.wm com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Test: go/wm-smoke
Change-Id: Iccdc3212cda651998d6ad76ce5261d089bff897a
Diffstat (limited to 'core/java/android/app/WindowConfiguration.java')
| -rw-r--r-- | core/java/android/app/WindowConfiguration.java | 73 |
1 files changed, 69 insertions, 4 deletions
diff --git a/core/java/android/app/WindowConfiguration.java b/core/java/android/app/WindowConfiguration.java index 86abaa37bab1..e4ec8c3b3b9c 100644 --- a/core/java/android/app/WindowConfiguration.java +++ b/core/java/android/app/WindowConfiguration.java @@ -44,16 +44,43 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu */ private Rect mAppBounds; + /** The current windowing mode of the configuration. */ + private @WindowingMode int mWindowingMode; + + /** Windowing mode is currently not defined. */ + public static final int WINDOWING_MODE_UNDEFINED = 0; + /** Occupies the full area of the screen or the parent container. */ + public static final int WINDOWING_MODE_FULLSCREEN = 1; + /** Always on-top (always visible). of other siblings in its parent container. */ + public static final int WINDOWING_MODE_PINNED = 2; + /** Occupies a dedicated region of the screen or its parent container. */ + public static final int WINDOWING_MODE_DOCKED = 3; + /** Can be freely resized within its parent container. */ + public static final int WINDOWING_MODE_FREEFORM = 4; + + @IntDef(value = { + WINDOWING_MODE_UNDEFINED, + WINDOWING_MODE_FULLSCREEN, + WINDOWING_MODE_PINNED, + WINDOWING_MODE_DOCKED, + WINDOWING_MODE_FREEFORM, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface WindowingMode {} + + /** Bit that indicates that the {@link #mAppBounds} changed. */ + public static final int WINDOW_CONFIG_APP_BOUNDS = 1 << 0; + /** Bit that indicates that the {@link #mWindowingMode} changed. */ + public static final int WINDOW_CONFIG_WINDOWING_MODE = 1 << 1; + @IntDef(flag = true, value = { WINDOW_CONFIG_APP_BOUNDS, + WINDOW_CONFIG_WINDOWING_MODE, }) @Retention(RetentionPolicy.SOURCE) public @interface WindowConfig {} - /** Bit that indicates that the {@link #mAppBounds} changed. */ - public static final int WINDOW_CONFIG_APP_BOUNDS = 1 << 0; - public WindowConfiguration() { unset(); } @@ -69,10 +96,12 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu @Override public void writeToParcel(Parcel dest, int flags) { dest.writeParcelable(mAppBounds, flags); + dest.writeInt(mWindowingMode); } private void readFromParcel(Parcel source) { mAppBounds = source.readParcelable(Rect.class.getClassLoader()); + mWindowingMode = source.readInt(); } @Override @@ -125,8 +154,18 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu return mAppBounds; } + public void setWindowingMode(@WindowingMode int windowingMode) { + mWindowingMode = windowingMode; + } + + @WindowingMode + public int getWindowingMode() { + return mWindowingMode; + } + public void setTo(WindowConfiguration other) { setAppBounds(other.mAppBounds); + setWindowingMode(other.mWindowingMode); } /** Set this object to completely undefined. */ @@ -136,6 +175,7 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu public void setToDefaults() { setAppBounds(null); + setWindowingMode(WINDOWING_MODE_UNDEFINED); } /** @@ -151,6 +191,11 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu changed |= WINDOW_CONFIG_APP_BOUNDS; setAppBounds(delta.mAppBounds); } + if (delta.mWindowingMode != WINDOWING_MODE_UNDEFINED + && mWindowingMode != delta.mWindowingMode) { + changed |= WINDOW_CONFIG_WINDOWING_MODE; + setWindowingMode(delta.mWindowingMode); + } return changed; } @@ -174,6 +219,11 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu changes |= WINDOW_CONFIG_APP_BOUNDS; } + if ((compareUndefined || other.mWindowingMode != WINDOWING_MODE_UNDEFINED) + && mWindowingMode != other.mWindowingMode) { + changes |= WINDOW_CONFIG_WINDOWING_MODE; + } + return changes; } @@ -194,6 +244,8 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu n = mAppBounds.bottom - that.mAppBounds.bottom; if (n != 0) return n; } + n = mWindowingMode - that.mWindowingMode; + if (n != 0) return n; // if (n != 0) return n; return n; @@ -215,11 +267,24 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu if (mAppBounds != null) { result = 31 * result + mAppBounds.hashCode(); } + result = 31 * result + mWindowingMode; return result; } @Override public String toString() { - return "{mAppBounds=" + mAppBounds + "}"; + return "{mAppBounds=" + mAppBounds + + " mWindowingMode=" + windowingModeToString(mWindowingMode) + "}"; + } + + private static String windowingModeToString(@WindowingMode int windowingMode) { + switch (windowingMode) { + case WINDOWING_MODE_UNDEFINED: return "undefined"; + case WINDOWING_MODE_FULLSCREEN: return "fullscreen"; + case WINDOWING_MODE_PINNED: return "pinned"; + case WINDOWING_MODE_DOCKED: return "docked"; + case WINDOWING_MODE_FREEFORM: return "freeform"; + } + return String.valueOf(windowingMode); } } |
