widget/gonk/libui/InputWindow.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/gonk/libui/InputWindow.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,205 @@
     1.4 +/*
     1.5 + * Copyright (C) 2011 The Android Open Source Project
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + *      http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * Unless required by applicable law or agreed to in writing, software
    1.14 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.16 + * See the License for the specific language governing permissions and
    1.17 + * limitations under the License.
    1.18 + */
    1.19 +
    1.20 +#ifndef _UI_INPUT_WINDOW_H
    1.21 +#define _UI_INPUT_WINDOW_H
    1.22 +
    1.23 +#include "Input.h"
    1.24 +#include "InputTransport.h"
    1.25 +#include <utils/RefBase.h>
    1.26 +#include <utils/Timers.h>
    1.27 +#include <utils/String8.h>
    1.28 +
    1.29 +#include <SkRegion.h>
    1.30 +
    1.31 +#include "InputApplication.h"
    1.32 +
    1.33 +namespace android {
    1.34 +
    1.35 +/*
    1.36 + * Describes the properties of a window that can receive input.
    1.37 + */
    1.38 +struct InputWindowInfo {
    1.39 +    // Window flags from WindowManager.LayoutParams
    1.40 +    enum {
    1.41 +        FLAG_ALLOW_LOCK_WHILE_SCREEN_ON     = 0x00000001,
    1.42 +        FLAG_DIM_BEHIND        = 0x00000002,
    1.43 +        FLAG_BLUR_BEHIND        = 0x00000004,
    1.44 +        FLAG_NOT_FOCUSABLE      = 0x00000008,
    1.45 +        FLAG_NOT_TOUCHABLE      = 0x00000010,
    1.46 +        FLAG_NOT_TOUCH_MODAL    = 0x00000020,
    1.47 +        FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040,
    1.48 +        FLAG_KEEP_SCREEN_ON     = 0x00000080,
    1.49 +        FLAG_LAYOUT_IN_SCREEN   = 0x00000100,
    1.50 +        FLAG_LAYOUT_NO_LIMITS   = 0x00000200,
    1.51 +        FLAG_FULLSCREEN      = 0x00000400,
    1.52 +        FLAG_FORCE_NOT_FULLSCREEN   = 0x00000800,
    1.53 +        FLAG_DITHER             = 0x00001000,
    1.54 +        FLAG_SECURE             = 0x00002000,
    1.55 +        FLAG_SCALED             = 0x00004000,
    1.56 +        FLAG_IGNORE_CHEEK_PRESSES    = 0x00008000,
    1.57 +        FLAG_LAYOUT_INSET_DECOR = 0x00010000,
    1.58 +        FLAG_ALT_FOCUSABLE_IM = 0x00020000,
    1.59 +        FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000,
    1.60 +        FLAG_SHOW_WHEN_LOCKED = 0x00080000,
    1.61 +        FLAG_SHOW_WALLPAPER = 0x00100000,
    1.62 +        FLAG_TURN_SCREEN_ON = 0x00200000,
    1.63 +        FLAG_DISMISS_KEYGUARD = 0x00400000,
    1.64 +        FLAG_SPLIT_TOUCH = 0x00800000,
    1.65 +        FLAG_HARDWARE_ACCELERATED = 0x01000000,
    1.66 +        FLAG_HARDWARE_ACCELERATED_SYSTEM = 0x02000000,
    1.67 +        FLAG_SLIPPERY = 0x04000000,
    1.68 +        FLAG_NEEDS_MENU_KEY = 0x08000000,
    1.69 +        FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000,
    1.70 +        FLAG_COMPATIBLE_WINDOW = 0x20000000,
    1.71 +        FLAG_SYSTEM_ERROR = 0x40000000,
    1.72 +    };
    1.73 +
    1.74 +    // Window types from WindowManager.LayoutParams
    1.75 +    enum {
    1.76 +        FIRST_APPLICATION_WINDOW = 1,
    1.77 +        TYPE_BASE_APPLICATION   = 1,
    1.78 +        TYPE_APPLICATION        = 2,
    1.79 +        TYPE_APPLICATION_STARTING = 3,
    1.80 +        LAST_APPLICATION_WINDOW = 99,
    1.81 +        FIRST_SUB_WINDOW        = 1000,
    1.82 +        TYPE_APPLICATION_PANEL  = FIRST_SUB_WINDOW,
    1.83 +        TYPE_APPLICATION_MEDIA  = FIRST_SUB_WINDOW+1,
    1.84 +        TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2,
    1.85 +        TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3,
    1.86 +        TYPE_APPLICATION_MEDIA_OVERLAY  = FIRST_SUB_WINDOW+4,
    1.87 +        LAST_SUB_WINDOW         = 1999,
    1.88 +        FIRST_SYSTEM_WINDOW     = 2000,
    1.89 +        TYPE_STATUS_BAR         = FIRST_SYSTEM_WINDOW,
    1.90 +        TYPE_SEARCH_BAR         = FIRST_SYSTEM_WINDOW+1,
    1.91 +        TYPE_PHONE              = FIRST_SYSTEM_WINDOW+2,
    1.92 +        TYPE_SYSTEM_ALERT       = FIRST_SYSTEM_WINDOW+3,
    1.93 +        TYPE_KEYGUARD           = FIRST_SYSTEM_WINDOW+4,
    1.94 +        TYPE_TOAST              = FIRST_SYSTEM_WINDOW+5,
    1.95 +        TYPE_SYSTEM_OVERLAY     = FIRST_SYSTEM_WINDOW+6,
    1.96 +        TYPE_PRIORITY_PHONE     = FIRST_SYSTEM_WINDOW+7,
    1.97 +        TYPE_SYSTEM_DIALOG      = FIRST_SYSTEM_WINDOW+8,
    1.98 +        TYPE_KEYGUARD_DIALOG    = FIRST_SYSTEM_WINDOW+9,
    1.99 +        TYPE_SYSTEM_ERROR       = FIRST_SYSTEM_WINDOW+10,
   1.100 +        TYPE_INPUT_METHOD       = FIRST_SYSTEM_WINDOW+11,
   1.101 +        TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12,
   1.102 +        TYPE_WALLPAPER          = FIRST_SYSTEM_WINDOW+13,
   1.103 +        TYPE_STATUS_BAR_PANEL   = FIRST_SYSTEM_WINDOW+14,
   1.104 +        TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15,
   1.105 +        TYPE_DRAG               = FIRST_SYSTEM_WINDOW+16,
   1.106 +        TYPE_STATUS_BAR_SUB_PANEL  = FIRST_SYSTEM_WINDOW+17,
   1.107 +        TYPE_POINTER            = FIRST_SYSTEM_WINDOW+18,
   1.108 +        TYPE_NAVIGATION_BAR     = FIRST_SYSTEM_WINDOW+19,
   1.109 +        TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20,
   1.110 +        TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21,
   1.111 +        LAST_SYSTEM_WINDOW      = 2999,
   1.112 +    };
   1.113 +
   1.114 +    enum {
   1.115 +        INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES = 0x00000001,
   1.116 +        INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002,
   1.117 +        INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004,
   1.118 +    };
   1.119 +
   1.120 +    sp<InputChannel> inputChannel;
   1.121 +    String8 name;
   1.122 +    int32_t layoutParamsFlags;
   1.123 +    int32_t layoutParamsType;
   1.124 +    nsecs_t dispatchingTimeout;
   1.125 +    int32_t frameLeft;
   1.126 +    int32_t frameTop;
   1.127 +    int32_t frameRight;
   1.128 +    int32_t frameBottom;
   1.129 +    float scaleFactor;
   1.130 +    SkRegion touchableRegion;
   1.131 +    bool visible;
   1.132 +    bool canReceiveKeys;
   1.133 +    bool hasFocus;
   1.134 +    bool hasWallpaper;
   1.135 +    bool paused;
   1.136 +    int32_t layer;
   1.137 +    int32_t ownerPid;
   1.138 +    int32_t ownerUid;
   1.139 +    int32_t inputFeatures;
   1.140 +    int32_t displayId;
   1.141 +
   1.142 +    bool touchableRegionContainsPoint(int32_t x, int32_t y) const;
   1.143 +    bool frameContainsPoint(int32_t x, int32_t y) const;
   1.144 +
   1.145 +    /* Returns true if the window is of a trusted type that is allowed to silently
   1.146 +     * overlay other windows for the purpose of implementing the secure views feature.
   1.147 +     * Trusted overlays, such as IME windows, can partly obscure other windows without causing
   1.148 +     * motion events to be delivered to them with AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED.
   1.149 +     */
   1.150 +    bool isTrustedOverlay() const;
   1.151 +
   1.152 +    bool supportsSplitTouch() const;
   1.153 +};
   1.154 +
   1.155 +
   1.156 +/*
   1.157 + * Handle for a window that can receive input.
   1.158 + *
   1.159 + * Used by the native input dispatcher to indirectly refer to the window manager objects
   1.160 + * that describe a window.
   1.161 + */
   1.162 +class InputWindowHandle : public RefBase {
   1.163 +public:
   1.164 +    const sp<InputApplicationHandle> inputApplicationHandle;
   1.165 +
   1.166 +    inline const InputWindowInfo* getInfo() const {
   1.167 +        return mInfo;
   1.168 +    }
   1.169 +
   1.170 +    inline sp<InputChannel> getInputChannel() const {
   1.171 +        return mInfo ? mInfo->inputChannel : NULL;
   1.172 +    }
   1.173 +
   1.174 +    inline String8 getName() const {
   1.175 +        return mInfo ? mInfo->name : String8("<invalid>");
   1.176 +    }
   1.177 +
   1.178 +    inline nsecs_t getDispatchingTimeout(nsecs_t defaultValue) const {
   1.179 +        return mInfo ? mInfo->dispatchingTimeout : defaultValue;
   1.180 +    }
   1.181 +
   1.182 +    /**
   1.183 +     * Requests that the state of this object be updated to reflect
   1.184 +     * the most current available information about the application.
   1.185 +     *
   1.186 +     * This method should only be called from within the input dispatcher's
   1.187 +     * critical section.
   1.188 +     *
   1.189 +     * Returns true on success, or false if the handle is no longer valid.
   1.190 +     */
   1.191 +    virtual bool updateInfo() = 0;
   1.192 +
   1.193 +    /**
   1.194 +     * Releases the storage used by the associated information when it is
   1.195 +     * no longer needed.
   1.196 +     */
   1.197 +    void releaseInfo();
   1.198 +
   1.199 +protected:
   1.200 +    InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle);
   1.201 +    virtual ~InputWindowHandle();
   1.202 +
   1.203 +    InputWindowInfo* mInfo;
   1.204 +};
   1.205 +
   1.206 +} // namespace android
   1.207 +
   1.208 +#endif // _UI_INPUT_WINDOW_H

mercurial