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 layoutParamsPrivateFlags; 48 public int layoutParamsType; 49 50 // Dispatching timeout. 51 public long dispatchingTimeoutNanos; 52 53 // Window frame. 54 public int frameLeft; 55 public int frameTop; 56 public int frameRight; 57 public int frameBottom; 58 59 // Global scaling factor applied to touch events when they are dispatched 60 // to the window 61 public float scaleFactor; 62 63 // Window touchable region. 64 public final Region touchableRegion = new Region(); 65 66 // Window is visible. 67 public boolean visible; 68 69 // Window can receive keys. 70 public boolean canReceiveKeys; 71 72 // Window has focus. 73 public boolean hasFocus; 74 75 // Window has wallpaper. (window is the current wallpaper target) 76 public boolean hasWallpaper; 77 78 // Input event dispatching is paused. 79 public boolean paused; 80 81 // Window layer. 82 public int layer; 83 84 // Id of process and user that owns the window. 85 public int ownerPid; 86 public int ownerUid; 87 88 // Window input features. 89 public int inputFeatures; 90 91 // Display this input is on. 92 public final int displayId; 93 94 private native void nativeDispose(); 95 96 public InputWindowHandle(InputApplicationHandle inputApplicationHandle, 97 Object windowState, int displayId) { 98 this.inputApplicationHandle = inputApplicationHandle; 99 this.windowState = windowState; 100 this.displayId = displayId; 101 } 102 103 @Override 104 protected void finalize() throws Throwable { 105 try { 106 nativeDispose(); 107 } finally { 108 super.finalize(); 109 } 110 } 111 } 112