michael@0: /* michael@0: * Copyright (C) 2011 The Android Open Source Project michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #ifndef _UI_INPUT_WINDOW_H michael@0: #define _UI_INPUT_WINDOW_H michael@0: michael@0: #include "Input.h" michael@0: #include "InputTransport.h" michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: #include michael@0: michael@0: #include "InputApplication.h" michael@0: michael@0: namespace android { michael@0: michael@0: /* michael@0: * Describes the properties of a window that can receive input. michael@0: */ michael@0: struct InputWindowInfo { michael@0: // Window flags from WindowManager.LayoutParams michael@0: enum { michael@0: FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001, michael@0: FLAG_DIM_BEHIND = 0x00000002, michael@0: FLAG_BLUR_BEHIND = 0x00000004, michael@0: FLAG_NOT_FOCUSABLE = 0x00000008, michael@0: FLAG_NOT_TOUCHABLE = 0x00000010, michael@0: FLAG_NOT_TOUCH_MODAL = 0x00000020, michael@0: FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040, michael@0: FLAG_KEEP_SCREEN_ON = 0x00000080, michael@0: FLAG_LAYOUT_IN_SCREEN = 0x00000100, michael@0: FLAG_LAYOUT_NO_LIMITS = 0x00000200, michael@0: FLAG_FULLSCREEN = 0x00000400, michael@0: FLAG_FORCE_NOT_FULLSCREEN = 0x00000800, michael@0: FLAG_DITHER = 0x00001000, michael@0: FLAG_SECURE = 0x00002000, michael@0: FLAG_SCALED = 0x00004000, michael@0: FLAG_IGNORE_CHEEK_PRESSES = 0x00008000, michael@0: FLAG_LAYOUT_INSET_DECOR = 0x00010000, michael@0: FLAG_ALT_FOCUSABLE_IM = 0x00020000, michael@0: FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000, michael@0: FLAG_SHOW_WHEN_LOCKED = 0x00080000, michael@0: FLAG_SHOW_WALLPAPER = 0x00100000, michael@0: FLAG_TURN_SCREEN_ON = 0x00200000, michael@0: FLAG_DISMISS_KEYGUARD = 0x00400000, michael@0: FLAG_SPLIT_TOUCH = 0x00800000, michael@0: FLAG_HARDWARE_ACCELERATED = 0x01000000, michael@0: FLAG_HARDWARE_ACCELERATED_SYSTEM = 0x02000000, michael@0: FLAG_SLIPPERY = 0x04000000, michael@0: FLAG_NEEDS_MENU_KEY = 0x08000000, michael@0: FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000, michael@0: FLAG_COMPATIBLE_WINDOW = 0x20000000, michael@0: FLAG_SYSTEM_ERROR = 0x40000000, michael@0: }; michael@0: michael@0: // Window types from WindowManager.LayoutParams michael@0: enum { michael@0: FIRST_APPLICATION_WINDOW = 1, michael@0: TYPE_BASE_APPLICATION = 1, michael@0: TYPE_APPLICATION = 2, michael@0: TYPE_APPLICATION_STARTING = 3, michael@0: LAST_APPLICATION_WINDOW = 99, michael@0: FIRST_SUB_WINDOW = 1000, michael@0: TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW, michael@0: TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1, michael@0: TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2, michael@0: TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3, michael@0: TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4, michael@0: LAST_SUB_WINDOW = 1999, michael@0: FIRST_SYSTEM_WINDOW = 2000, michael@0: TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW, michael@0: TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1, michael@0: TYPE_PHONE = FIRST_SYSTEM_WINDOW+2, michael@0: TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3, michael@0: TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4, michael@0: TYPE_TOAST = FIRST_SYSTEM_WINDOW+5, michael@0: TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6, michael@0: TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7, michael@0: TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8, michael@0: TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9, michael@0: TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10, michael@0: TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11, michael@0: TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12, michael@0: TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13, michael@0: TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14, michael@0: TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15, michael@0: TYPE_DRAG = FIRST_SYSTEM_WINDOW+16, michael@0: TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17, michael@0: TYPE_POINTER = FIRST_SYSTEM_WINDOW+18, michael@0: TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19, michael@0: TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20, michael@0: TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21, michael@0: LAST_SYSTEM_WINDOW = 2999, michael@0: }; michael@0: michael@0: enum { michael@0: INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES = 0x00000001, michael@0: INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002, michael@0: INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004, michael@0: }; michael@0: michael@0: sp inputChannel; michael@0: String8 name; michael@0: int32_t layoutParamsFlags; michael@0: int32_t layoutParamsType; michael@0: nsecs_t dispatchingTimeout; michael@0: int32_t frameLeft; michael@0: int32_t frameTop; michael@0: int32_t frameRight; michael@0: int32_t frameBottom; michael@0: float scaleFactor; michael@0: SkRegion touchableRegion; michael@0: bool visible; michael@0: bool canReceiveKeys; michael@0: bool hasFocus; michael@0: bool hasWallpaper; michael@0: bool paused; michael@0: int32_t layer; michael@0: int32_t ownerPid; michael@0: int32_t ownerUid; michael@0: int32_t inputFeatures; michael@0: int32_t displayId; michael@0: michael@0: bool touchableRegionContainsPoint(int32_t x, int32_t y) const; michael@0: bool frameContainsPoint(int32_t x, int32_t y) const; michael@0: michael@0: /* Returns true if the window is of a trusted type that is allowed to silently michael@0: * overlay other windows for the purpose of implementing the secure views feature. michael@0: * Trusted overlays, such as IME windows, can partly obscure other windows without causing michael@0: * motion events to be delivered to them with AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED. michael@0: */ michael@0: bool isTrustedOverlay() const; michael@0: michael@0: bool supportsSplitTouch() const; michael@0: }; michael@0: michael@0: michael@0: /* michael@0: * Handle for a window that can receive input. michael@0: * michael@0: * Used by the native input dispatcher to indirectly refer to the window manager objects michael@0: * that describe a window. michael@0: */ michael@0: class InputWindowHandle : public RefBase { michael@0: public: michael@0: const sp inputApplicationHandle; michael@0: michael@0: inline const InputWindowInfo* getInfo() const { michael@0: return mInfo; michael@0: } michael@0: michael@0: inline sp getInputChannel() const { michael@0: return mInfo ? mInfo->inputChannel : NULL; michael@0: } michael@0: michael@0: inline String8 getName() const { michael@0: return mInfo ? mInfo->name : String8(""); michael@0: } michael@0: michael@0: inline nsecs_t getDispatchingTimeout(nsecs_t defaultValue) const { michael@0: return mInfo ? mInfo->dispatchingTimeout : defaultValue; michael@0: } michael@0: michael@0: /** michael@0: * Requests that the state of this object be updated to reflect michael@0: * the most current available information about the application. michael@0: * michael@0: * This method should only be called from within the input dispatcher's michael@0: * critical section. michael@0: * michael@0: * Returns true on success, or false if the handle is no longer valid. michael@0: */ michael@0: virtual bool updateInfo() = 0; michael@0: michael@0: /** michael@0: * Releases the storage used by the associated information when it is michael@0: * no longer needed. michael@0: */ michael@0: void releaseInfo(); michael@0: michael@0: protected: michael@0: InputWindowHandle(const sp& inputApplicationHandle); michael@0: virtual ~InputWindowHandle(); michael@0: michael@0: InputWindowInfo* mInfo; michael@0: }; michael@0: michael@0: } // namespace android michael@0: michael@0: #endif // _UI_INPUT_WINDOW_H