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

Commit 32a0d2ff authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge "Added contentSize to WindowInfo" into main

parents 9136b7ea b6914ab6
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.graphics.Region;
import android.gui.TouchOcclusionMode;
import android.os.IBinder;
import android.os.InputConfig;
import android.util.Size;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -106,6 +107,9 @@ public final class InputWindowHandle {
    // Window frame.
    public final Rect frame = new Rect();

    // The real size of the content, excluding any crop. If no buffer is rendered, this is 0,0
    public Size contentSize = new Size(0, 0);

    public int surfaceInset;

    // Global scaling factor applied to touch events when they are dispatched
@@ -199,6 +203,7 @@ public final class InputWindowHandle {
            transform.set(other.transform);
        }
        focusTransferTarget = other.focusTransferTarget;
        contentSize = new Size(other.contentSize.getWidth(), other.contentSize.getHeight());
    }

    @Override
@@ -211,6 +216,7 @@ public final class InputWindowHandle {
                .append(", windowToken=").append(windowToken)
                .append(", displayId=").append(displayId)
                .append(", isClone=").append((inputConfig & InputConfig.CLONE) != 0)
                .append(", contentSize=").append(contentSize)
                .toString();

    }
+7 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ static struct {
    jfieldID layoutParamsType;
    jfieldID dispatchingTimeoutMillis;
    jfieldID frame;
    jfieldID contentSize;
    jfieldID surfaceInset;
    jfieldID scaleFactor;
    jfieldID touchableRegion;
@@ -281,6 +282,9 @@ jobject android_view_InputWindowHandle_fromWindowInfo(JNIEnv* env, gui::WindowIn
    ScopedLocalRef<jobject> rectObj(env, JNICommon::objFromRect(env, windowInfo.frame));
    env->SetObjectField(inputWindowHandle, gInputWindowHandleClassInfo.frame, rectObj.get());

    ScopedLocalRef<jobject> sizeObj(env, JNICommon::objFromSize(env, windowInfo.contentSize));
    env->SetObjectField(inputWindowHandle, gInputWindowHandleClassInfo.contentSize, sizeObj.get());

    env->SetIntField(inputWindowHandle, gInputWindowHandleClassInfo.surfaceInset,
                     windowInfo.surfaceInset);
    env->SetFloatField(inputWindowHandle, gInputWindowHandleClassInfo.scaleFactor,
@@ -393,6 +397,9 @@ int register_android_view_InputWindowHandle(JNIEnv* env) {

    GET_FIELD_ID(gInputWindowHandleClassInfo.frame, clazz, "frame", "Landroid/graphics/Rect;");

    GET_FIELD_ID(gInputWindowHandleClassInfo.contentSize, clazz, "contentSize",
                 "Landroid/util/Size;");

    GET_FIELD_ID(gInputWindowHandleClassInfo.surfaceInset, clazz,
            "surfaceInset", "I");

+14 −0
Original line number Diff line number Diff line
@@ -34,6 +34,11 @@ static struct {
    jfieldID top;
} gRectClassInfo;

static struct {
    jclass clazz;
    jmethodID ctor;
} gSizeClassInfo;

Rect JNICommon::rectFromObj(JNIEnv* env, jobject rectObj) {
    int left = env->GetIntField(rectObj, gRectClassInfo.left);
    int top = env->GetIntField(rectObj, gRectClassInfo.top);
@@ -47,6 +52,10 @@ jobject JNICommon::objFromRect(JNIEnv* env, Rect rect) {
                          rect.right, rect.bottom);
}

jobject JNICommon::objFromSize(JNIEnv* env, Size size) {
    return env->NewObject(gSizeClassInfo.clazz, gSizeClassInfo.ctor, size.width, size.height);
}

int register_jni_common(JNIEnv* env) {
    jclass rectClazz = FindClassOrDie(env, "android/graphics/Rect");
    gRectClassInfo.clazz = MakeGlobalRefOrDie(env, rectClazz);
@@ -55,6 +64,11 @@ int register_jni_common(JNIEnv* env) {
    gRectClassInfo.left = GetFieldIDOrDie(env, rectClazz, "left", "I");
    gRectClassInfo.right = GetFieldIDOrDie(env, rectClazz, "right", "I");
    gRectClassInfo.top = GetFieldIDOrDie(env, rectClazz, "top", "I");

    jclass sizeClazz = FindClassOrDie(env, "android/util/Size");
    gSizeClassInfo.clazz = MakeGlobalRefOrDie(env, sizeClazz);
    gSizeClassInfo.ctor = GetMethodIDOrDie(env, sizeClazz, "<init>", "(II)V");

    return 0;
}

+3 −0
Original line number Diff line number Diff line
@@ -14,14 +14,17 @@
 * limitations under the License.
 */
#include <jni.h>
#include <ui/Size.h>

namespace android {

class Rect;
using ui::Size;

class JNICommon {
public:
    static Rect rectFromObj(JNIEnv* env, jobject rectObj);
    static jobject objFromRect(JNIEnv* env, Rect rect);
    static jobject objFromSize(JNIEnv* env, Size size);
};
} // namespace android
 No newline at end of file