1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.window; 18 19 import android.annotation.NonNull; 20 import android.graphics.Rect; 21 import android.os.Parcel; 22 import android.os.Parcelable; 23 24 /** 25 * The window frame container class used by client side for layout. 26 * @hide 27 */ 28 public class ClientWindowFrames implements Parcelable { 29 /** The actual window bounds. */ 30 public final @NonNull Rect frame; 31 32 /** 33 * The container frame that is usually the same as display size. It may exclude the area of 34 * insets if the window layout parameter has specified fit-insets-sides. 35 */ 36 public final @NonNull Rect displayFrame; 37 38 /** The background area while the window is resizing. */ 39 public final @NonNull Rect backdropFrame; 40 ClientWindowFrames()41 public ClientWindowFrames() { 42 frame = new Rect(); 43 displayFrame = new Rect(); 44 backdropFrame = new Rect(); 45 } 46 ClientWindowFrames(ClientWindowFrames other)47 public ClientWindowFrames(ClientWindowFrames other) { 48 frame = new Rect(other.frame); 49 displayFrame = new Rect(other.displayFrame); 50 backdropFrame = new Rect(other.backdropFrame); 51 } 52 ClientWindowFrames(Parcel in)53 private ClientWindowFrames(Parcel in) { 54 frame = Rect.CREATOR.createFromParcel(in); 55 displayFrame = Rect.CREATOR.createFromParcel(in); 56 backdropFrame = Rect.CREATOR.createFromParcel(in); 57 } 58 59 /** Needed for AIDL out parameters. */ readFromParcel(Parcel in)60 public void readFromParcel(Parcel in) { 61 frame.readFromParcel(in); 62 displayFrame.readFromParcel(in); 63 backdropFrame.readFromParcel(in); 64 } 65 66 @Override writeToParcel(Parcel dest, int flags)67 public void writeToParcel(Parcel dest, int flags) { 68 frame.writeToParcel(dest, flags); 69 displayFrame.writeToParcel(dest, flags); 70 backdropFrame.writeToParcel(dest, flags); 71 } 72 73 @Override toString()74 public String toString() { 75 final StringBuilder sb = new StringBuilder(32); 76 return "ClientWindowFrames{frame=" + frame.toShortString(sb) 77 + " display=" + displayFrame.toShortString(sb) 78 + " backdrop=" + backdropFrame.toShortString(sb) + "}"; 79 } 80 81 @Override describeContents()82 public int describeContents() { 83 return 0; 84 } 85 86 public static final Creator<ClientWindowFrames> CREATOR = new Creator<ClientWindowFrames>() { 87 public ClientWindowFrames createFromParcel(Parcel in) { 88 return new ClientWindowFrames(in); 89 } 90 91 public ClientWindowFrames[] newArray(int size) { 92 return new ClientWindowFrames[size]; 93 } 94 }; 95 } 96