blob: ec79eea45ee6a4eb62ce73c1d666039a4f8336f7 [file] [log] [blame]
Jeff Brown928e0542011-01-10 11:17:36 -08001/*
2 * Copyright (C) 2011 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
Robert Carr788f5742018-07-30 17:46:45 -070017package android.view;
Jeff Brown928e0542011-01-10 11:17:36 -080018
Tiger Huang04dc4cc2019-01-17 18:41:41 +080019import static android.view.Display.INVALID_DISPLAY;
20
Jeff Brown9302c872011-07-13 22:51:29 -070021import android.graphics.Region;
Robert Carreadae822018-10-11 19:07:03 -070022import android.os.IBinder;
Jeff Brown928e0542011-01-10 11:17:36 -080023
24/**
25 * Functions as a handle for a window that can receive input.
26 * Enables the native input dispatcher to refer indirectly to the window manager's window state.
27 * @hide
28 */
29public final class InputWindowHandle {
30 // Pointer to the native input window handle.
31 // This field is lazily initialized via JNI.
32 @SuppressWarnings("unused")
Ashok Bhat7e2a9dc2014-01-02 19:43:30 +000033 private long ptr;
Jeff Brown928e0542011-01-10 11:17:36 -080034
35 // The input application handle.
36 public final InputApplicationHandle inputApplicationHandle;
37
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -080038 // The client window.
39 public final IWindow clientWindow;
40
Robert Carreadae822018-10-11 19:07:03 -070041 // The token assosciated with the window.
42 public IBinder token;
Jeff Brown9302c872011-07-13 22:51:29 -070043
44 // The window name.
45 public String name;
46
47 // Window layout params attributes. (WindowManager.LayoutParams)
48 public int layoutParamsFlags;
49 public int layoutParamsType;
50
51 // Dispatching timeout.
52 public long dispatchingTimeoutNanos;
53
54 // Window frame.
55 public int frameLeft;
56 public int frameTop;
57 public int frameRight;
58 public int frameBottom;
59
Robert Carrfcc08522018-11-14 14:02:52 -080060 public int surfaceInset;
61
Jeff Brown9302c872011-07-13 22:51:29 -070062 // Global scaling factor applied to touch events when they are dispatched
63 // to the window
64 public float scaleFactor;
65
66 // Window touchable region.
67 public final Region touchableRegion = new Region();
68
69 // Window is visible.
70 public boolean visible;
71
72 // Window can receive keys.
73 public boolean canReceiveKeys;
74
75 // Window has focus.
76 public boolean hasFocus;
77
78 // Window has wallpaper. (window is the current wallpaper target)
79 public boolean hasWallpaper;
80
81 // Input event dispatching is paused.
82 public boolean paused;
83
84 // Window layer.
85 public int layer;
86
87 // Id of process and user that owns the window.
88 public int ownerPid;
89 public int ownerUid;
90
91 // Window input features.
92 public int inputFeatures;
93
Craig Mautner59c00972012-07-30 12:10:24 -070094 // Display this input is on.
Brad Stenningaf596412018-04-02 12:03:19 -070095 public int displayId;
Craig Mautner59c00972012-07-30 12:10:24 -070096
Tiger Huang04dc4cc2019-01-17 18:41:41 +080097 // If this value is set to a valid display ID, it indicates this window is a portal which
98 // transports the touch of this window to the display indicated by portalToDisplayId.
99 public int portalToDisplayId = INVALID_DISPLAY;
100
Jeff Brown928e0542011-01-10 11:17:36 -0800101 private native void nativeDispose();
102
103 public InputWindowHandle(InputApplicationHandle inputApplicationHandle,
Robert Carre0a353c2018-08-02 16:38:04 -0700104 IWindow clientWindow, int displayId) {
Jeff Brown928e0542011-01-10 11:17:36 -0800105 this.inputApplicationHandle = inputApplicationHandle;
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -0800106 this.clientWindow = clientWindow;
Craig Mautner59c00972012-07-30 12:10:24 -0700107 this.displayId = displayId;
Jeff Brown928e0542011-01-10 11:17:36 -0800108 }
109
110 @Override
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700111 public String toString() {
Arthur Hung39134b22018-08-14 11:58:28 +0800112 return new StringBuilder(name != null ? name : "")
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700113 .append(", layer=").append(layer)
114 .append(", frame=[").append(frameLeft).append(",").append(frameTop).append(",")
115 .append(frameRight).append(",").append(frameBottom).append("]")
116 .append(", touchableRegion=").append(touchableRegion)
Filip Gruszczynski55149302015-11-25 10:51:25 -0800117 .append(", visible=").append(visible)
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700118 .toString();
119
120 }
121
122 @Override
Jeff Brown928e0542011-01-10 11:17:36 -0800123 protected void finalize() throws Throwable {
Jeff Browncc4f7db2011-08-30 20:34:48 -0700124 try {
125 nativeDispose();
126 } finally {
127 super.finalize();
128 }
Jeff Brown928e0542011-01-10 11:17:36 -0800129 }
130}