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 nativeDispose()90 private native void nativeDispose(); 91 InputWindowHandle(InputApplicationHandle inputApplicationHandle, Object windowState)92 public InputWindowHandle(InputApplicationHandle inputApplicationHandle, 93 Object windowState) { 94 this.inputApplicationHandle = inputApplicationHandle; 95 this.windowState = windowState; 96 } 97 98 @Override finalize()99 protected void finalize() throws Throwable { 100 try { 101 nativeDispose(); 102 } finally { 103 super.finalize(); 104 } 105 } 106 } 107