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 | |
Jeff Brown | 4532e61 | 2012-04-05 14:27:12 -0700 | [diff] [blame] | 17 | package com.android.server.input; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 18 | |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 19 | import android.graphics.Region; |
| 20 | import android.view.InputChannel; |
Vladislav Kaznacheev | 3787de1 | 2016-12-21 10:36:35 -0800 | [diff] [blame] | 21 | import android.view.IWindow; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 22 | |
| 23 | /** |
| 24 | * Functions as a handle for a window that can receive input. |
| 25 | * Enables the native input dispatcher to refer indirectly to the window manager's window state. |
| 26 | * @hide |
| 27 | */ |
| 28 | public final class InputWindowHandle { |
| 29 | // Pointer to the native input window handle. |
| 30 | // This field is lazily initialized via JNI. |
| 31 | @SuppressWarnings("unused") |
Ashok Bhat | 7e2a9dc | 2014-01-02 19:43:30 +0000 | [diff] [blame] | 32 | private long ptr; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 33 | |
| 34 | // The input application handle. |
| 35 | public final InputApplicationHandle inputApplicationHandle; |
| 36 | |
| 37 | // The window manager's window state. |
Jeff Brown | 4532e61 | 2012-04-05 14:27:12 -0700 | [diff] [blame] | 38 | public final Object windowState; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 39 | |
Vladislav Kaznacheev | 3787de1 | 2016-12-21 10:36:35 -0800 | [diff] [blame] | 40 | // The client window. |
| 41 | public final IWindow clientWindow; |
| 42 | |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 43 | // The input channel associated with the window. |
| 44 | public InputChannel inputChannel; |
| 45 | |
| 46 | // The window name. |
| 47 | public String name; |
| 48 | |
| 49 | // Window layout params attributes. (WindowManager.LayoutParams) |
| 50 | public int layoutParamsFlags; |
| 51 | public int layoutParamsType; |
| 52 | |
| 53 | // Dispatching timeout. |
| 54 | public long dispatchingTimeoutNanos; |
| 55 | |
| 56 | // Window frame. |
| 57 | public int frameLeft; |
| 58 | public int frameTop; |
| 59 | public int frameRight; |
| 60 | public int frameBottom; |
| 61 | |
| 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. |
| 95 | public final int displayId; |
| 96 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 97 | private native void nativeDispose(); |
| 98 | |
| 99 | public InputWindowHandle(InputApplicationHandle inputApplicationHandle, |
Vladislav Kaznacheev | 3787de1 | 2016-12-21 10:36:35 -0800 | [diff] [blame] | 100 | Object windowState, IWindow clientWindow, int displayId) { |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 101 | this.inputApplicationHandle = inputApplicationHandle; |
| 102 | this.windowState = windowState; |
Vladislav Kaznacheev | 3787de1 | 2016-12-21 10:36:35 -0800 | [diff] [blame] | 103 | this.clientWindow = clientWindow; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 104 | this.displayId = displayId; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | @Override |
Filip Gruszczynski | f8a2a63 | 2015-10-28 11:18:02 -0700 | [diff] [blame] | 108 | public String toString() { |
| 109 | return new StringBuilder(name) |
| 110 | .append(", layer=").append(layer) |
| 111 | .append(", frame=[").append(frameLeft).append(",").append(frameTop).append(",") |
| 112 | .append(frameRight).append(",").append(frameBottom).append("]") |
| 113 | .append(", touchableRegion=").append(touchableRegion) |
Filip Gruszczynski | 5514930 | 2015-11-25 10:51:25 -0800 | [diff] [blame] | 114 | .append(", visible=").append(visible) |
Filip Gruszczynski | f8a2a63 | 2015-10-28 11:18:02 -0700 | [diff] [blame] | 115 | .toString(); |
| 116 | |
| 117 | } |
| 118 | |
| 119 | @Override |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 120 | protected void finalize() throws Throwable { |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 121 | try { |
| 122 | nativeDispose(); |
| 123 | } finally { |
| 124 | super.finalize(); |
| 125 | } |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 126 | } |
| 127 | } |