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 22 /** 23 * Functions as a handle for a window that can receive input. 24 * Enables the native input dispatcher to refer indirectly to the window manager's window state. 25 * @hide 26 */ 27 public final class InputWindowHandle { 28 // Pointer to the native input window handle. 29 // This field is lazily initialized via JNI. 30 @SuppressWarnings("unused") 31 private int ptr; 32 33 // The input application handle. 34 public final InputApplicationHandle inputApplicationHandle; 35 36 // The window manager's window state. 37 public final Object windowState; 38 39 // The input channel associated with the window. 40 public InputChannel inputChannel; 41 42 // The window name. 43 public String name; 44 45 // Window layout params attributes. (WindowManager.LayoutParams) 46 public int layoutParamsFlags; 47 public int layoutParamsType; 48 49 // Dispatching timeout. 50 public long dispatchingTimeoutNanos; 51 52 // Window frame. 53 public int frameLeft; 54 public int frameTop; 55 public int frameRight; 56 public int frameBottom; 57 58 // Global scaling factor applied to touch events when they are dispatched 59 // to the window 60 public float scaleFactor; 61 62 // Window touchable region. 63 public final Region touchableRegion = new Region(); 64 65 // Window is visible. 66 public boolean visible; 67 68 // Window can receive keys. 69 public boolean canReceiveKeys; 70 71 // Window has focus. 72 public boolean hasFocus; 73 74 // Window has wallpaper. (window is the current wallpaper target) 75 public boolean hasWallpaper; 76 77 // Input event dispatching is paused. 78 public boolean paused; 79 80 // Window layer. 81 public int layer; 82 83 // Id of process and user that owns the window. 84 public int ownerPid; 85 public int ownerUid; 86 87 // Window input features. 88 public int inputFeatures; 89 90 // Display this input is on. 91 public final int displayId; 92 nativeDispose()93 private native void nativeDispose(); 94 InputWindowHandle(InputApplicationHandle inputApplicationHandle, Object windowState, int displayId)95 public InputWindowHandle(InputApplicationHandle inputApplicationHandle, 96 Object windowState, int displayId) { 97 this.inputApplicationHandle = inputApplicationHandle; 98 this.windowState = windowState; 99 this.displayId = displayId; 100 } 101 102 @Override finalize()103 protected void finalize() throws Throwable { 104 try { 105 nativeDispose(); 106 } finally { 107 super.finalize(); 108 } 109 } 110 } 111