blob: 3d6f7ad16a7a558e41f7195f7cb47ca9b6a64149 [file] [log] [blame]
Jeff Brown928e0542011-01-10 11:17:36 -08001/*
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
Jeff Brown4532e612012-04-05 14:27:12 -070017package com.android.server.input;
Jeff Brown928e0542011-01-10 11:17:36 -080018
Jeff Brown9302c872011-07-13 22:51:29 -070019import android.graphics.Region;
20import android.view.InputChannel;
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -080021import android.view.IWindow;
Jeff Brown928e0542011-01-10 11:17:36 -080022
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 */
28public final class InputWindowHandle {
29 // Pointer to the native input window handle.
30 // This field is lazily initialized via JNI.
31 @SuppressWarnings("unused")
Ashok Bhat7e2a9dc2014-01-02 19:43:30 +000032 private long ptr;
Jeff Brown928e0542011-01-10 11:17:36 -080033
34 // The input application handle.
35 public final InputApplicationHandle inputApplicationHandle;
36
37 // The window manager's window state.
Jeff Brown4532e612012-04-05 14:27:12 -070038 public final Object windowState;
Jeff Brown928e0542011-01-10 11:17:36 -080039
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -080040 // The client window.
41 public final IWindow clientWindow;
42
Jeff Brown9302c872011-07-13 22:51:29 -070043 // 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
Craig Mautner59c00972012-07-30 12:10:24 -070094 // Display this input is on.
95 public final int displayId;
96
Jeff Brown928e0542011-01-10 11:17:36 -080097 private native void nativeDispose();
98
99 public InputWindowHandle(InputApplicationHandle inputApplicationHandle,
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -0800100 Object windowState, IWindow clientWindow, int displayId) {
Jeff Brown928e0542011-01-10 11:17:36 -0800101 this.inputApplicationHandle = inputApplicationHandle;
102 this.windowState = windowState;
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -0800103 this.clientWindow = clientWindow;
Craig Mautner59c00972012-07-30 12:10:24 -0700104 this.displayId = displayId;
Jeff Brown928e0542011-01-10 11:17:36 -0800105 }
106
107 @Override
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700108 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)
Filip Gruszczynski55149302015-11-25 10:51:25 -0800114 .append(", visible=").append(visible)
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700115 .toString();
116
117 }
118
119 @Override
Jeff Brown928e0542011-01-10 11:17:36 -0800120 protected void finalize() throws Throwable {
Jeff Browncc4f7db2011-08-30 20:34:48 -0700121 try {
122 nativeDispose();
123 } finally {
124 super.finalize();
125 }
Jeff Brown928e0542011-01-10 11:17:36 -0800126 }
127}