Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 1 | /* |
| 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 Carr | 788f574 | 2018-07-30 17:46:45 -0700 | [diff] [blame] | 17 | package android.view; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 18 | |
Tiger Huang | 04dc4cc | 2019-01-17 18:41:41 +0800 | [diff] [blame] | 19 | import static android.view.Display.INVALID_DISPLAY; |
| 20 | |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 21 | import android.graphics.Region; |
Robert Carr | eadae82 | 2018-10-11 19:07:03 -0700 | [diff] [blame] | 22 | import android.os.IBinder; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 23 | |
| 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 | */ |
| 29 | public final class InputWindowHandle { |
| 30 | // Pointer to the native input window handle. |
| 31 | // This field is lazily initialized via JNI. |
| 32 | @SuppressWarnings("unused") |
Ashok Bhat | 7e2a9dc | 2014-01-02 19:43:30 +0000 | [diff] [blame] | 33 | private long ptr; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 34 | |
| 35 | // The input application handle. |
| 36 | public final InputApplicationHandle inputApplicationHandle; |
| 37 | |
Vladislav Kaznacheev | 3787de1 | 2016-12-21 10:36:35 -0800 | [diff] [blame] | 38 | // The client window. |
| 39 | public final IWindow clientWindow; |
| 40 | |
Robert Carr | eadae82 | 2018-10-11 19:07:03 -0700 | [diff] [blame] | 41 | // The token assosciated with the window. |
| 42 | public IBinder token; |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 43 | |
| 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 Carr | fcc0852 | 2018-11-14 14:02:52 -0800 | [diff] [blame] | 60 | public int surfaceInset; |
| 61 | |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 62 | // 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 Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 94 | // Display this input is on. |
Brad Stenning | af59641 | 2018-04-02 12:03:19 -0700 | [diff] [blame] | 95 | public int displayId; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 96 | |
Tiger Huang | 04dc4cc | 2019-01-17 18:41:41 +0800 | [diff] [blame] | 97 | // 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 Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 101 | private native void nativeDispose(); |
| 102 | |
| 103 | public InputWindowHandle(InputApplicationHandle inputApplicationHandle, |
Robert Carr | e0a353c | 2018-08-02 16:38:04 -0700 | [diff] [blame] | 104 | IWindow clientWindow, int displayId) { |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 105 | this.inputApplicationHandle = inputApplicationHandle; |
Vladislav Kaznacheev | 3787de1 | 2016-12-21 10:36:35 -0800 | [diff] [blame] | 106 | this.clientWindow = clientWindow; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 107 | this.displayId = displayId; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | @Override |
Filip Gruszczynski | f8a2a63 | 2015-10-28 11:18:02 -0700 | [diff] [blame] | 111 | public String toString() { |
Arthur Hung | 39134b2 | 2018-08-14 11:58:28 +0800 | [diff] [blame] | 112 | return new StringBuilder(name != null ? name : "") |
Filip Gruszczynski | f8a2a63 | 2015-10-28 11:18:02 -0700 | [diff] [blame] | 113 | .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 Gruszczynski | 5514930 | 2015-11-25 10:51:25 -0800 | [diff] [blame] | 117 | .append(", visible=").append(visible) |
Filip Gruszczynski | f8a2a63 | 2015-10-28 11:18:02 -0700 | [diff] [blame] | 118 | .toString(); |
| 119 | |
| 120 | } |
| 121 | |
| 122 | @Override |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 123 | protected void finalize() throws Throwable { |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 124 | try { |
| 125 | nativeDispose(); |
| 126 | } finally { |
| 127 | super.finalize(); |
| 128 | } |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 129 | } |
| 130 | } |