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 17 package com.android.server.input; 18 19 import android.graphics.Region; 20 import android.view.InputChannel; 21 import android.view.IWindow; 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") 32 private long ptr; 33 34 // The input application handle. 35 public final InputApplicationHandle inputApplicationHandle; 36 37 // The window manager's window state. 38 public final Object windowState; 39 40 // The client window. 41 public final IWindow clientWindow; 42 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 94 // Display this input is on. 95 public final int displayId; 96 nativeDispose()97 private native void nativeDispose(); 98 InputWindowHandle(InputApplicationHandle inputApplicationHandle, Object windowState, IWindow clientWindow, int displayId)99 public InputWindowHandle(InputApplicationHandle inputApplicationHandle, 100 Object windowState, IWindow clientWindow, int displayId) { 101 this.inputApplicationHandle = inputApplicationHandle; 102 this.windowState = windowState; 103 this.clientWindow = clientWindow; 104 this.displayId = displayId; 105 } 106 107 @Override toString()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) 114 .append(", visible=").append(visible) 115 .toString(); 116 117 } 118 119 @Override finalize()120 protected void finalize() throws Throwable { 121 try { 122 nativeDispose(); 123 } finally { 124 super.finalize(); 125 } 126 } 127 } 128