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 | |
Dianne Hackborn | a924dc0d | 2011-02-17 14:22:17 -0800 | [diff] [blame] | 17 | package com.android.server.wm; |
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; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 21 | import android.view.WindowManagerPolicy; |
| 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 int ptr; |
| 33 | |
| 34 | // The input application handle. |
| 35 | public final InputApplicationHandle inputApplicationHandle; |
| 36 | |
| 37 | // The window manager's window state. |
| 38 | public final WindowManagerPolicy.WindowState windowState; |
| 39 | |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 40 | // The input channel associated with the window. |
| 41 | public InputChannel inputChannel; |
| 42 | |
| 43 | // The window name. |
| 44 | public String name; |
| 45 | |
| 46 | // Window layout params attributes. (WindowManager.LayoutParams) |
| 47 | public int layoutParamsFlags; |
| 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 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 91 | private native void nativeDispose(); |
| 92 | |
| 93 | public InputWindowHandle(InputApplicationHandle inputApplicationHandle, |
| 94 | WindowManagerPolicy.WindowState windowState) { |
| 95 | this.inputApplicationHandle = inputApplicationHandle; |
| 96 | this.windowState = windowState; |
| 97 | } |
| 98 | |
| 99 | @Override |
| 100 | protected void finalize() throws Throwable { |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 101 | try { |
| 102 | nativeDispose(); |
| 103 | } finally { |
| 104 | super.finalize(); |
| 105 | } |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 106 | } |
| 107 | } |