2011-01-10 11:17:36 -08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2011 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _UI_INPUT_WINDOW_H
|
|
|
|
#define _UI_INPUT_WINDOW_H
|
|
|
|
|
2013-07-01 19:07:15 -07:00
|
|
|
#include <input/Input.h>
|
|
|
|
#include <input/InputTransport.h>
|
2011-01-10 11:17:36 -08:00
|
|
|
#include <utils/RefBase.h>
|
|
|
|
#include <utils/Timers.h>
|
|
|
|
#include <utils/String8.h>
|
|
|
|
|
2011-01-16 14:06:57 -08:00
|
|
|
#include <SkRegion.h>
|
|
|
|
|
2011-01-10 11:17:36 -08:00
|
|
|
#include "InputApplication.h"
|
|
|
|
|
|
|
|
namespace android {
|
|
|
|
|
|
|
|
/*
|
2011-08-30 20:34:48 -07:00
|
|
|
* Describes the properties of a window that can receive input.
|
2011-01-10 11:17:36 -08:00
|
|
|
*/
|
2011-08-30 20:34:48 -07:00
|
|
|
struct InputWindowInfo {
|
2011-01-10 11:17:36 -08:00
|
|
|
// Window flags from WindowManager.LayoutParams
|
|
|
|
enum {
|
|
|
|
FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001,
|
|
|
|
FLAG_DIM_BEHIND = 0x00000002,
|
|
|
|
FLAG_BLUR_BEHIND = 0x00000004,
|
|
|
|
FLAG_NOT_FOCUSABLE = 0x00000008,
|
|
|
|
FLAG_NOT_TOUCHABLE = 0x00000010,
|
|
|
|
FLAG_NOT_TOUCH_MODAL = 0x00000020,
|
|
|
|
FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040,
|
|
|
|
FLAG_KEEP_SCREEN_ON = 0x00000080,
|
|
|
|
FLAG_LAYOUT_IN_SCREEN = 0x00000100,
|
|
|
|
FLAG_LAYOUT_NO_LIMITS = 0x00000200,
|
|
|
|
FLAG_FULLSCREEN = 0x00000400,
|
|
|
|
FLAG_FORCE_NOT_FULLSCREEN = 0x00000800,
|
|
|
|
FLAG_DITHER = 0x00001000,
|
|
|
|
FLAG_SECURE = 0x00002000,
|
|
|
|
FLAG_SCALED = 0x00004000,
|
|
|
|
FLAG_IGNORE_CHEEK_PRESSES = 0x00008000,
|
|
|
|
FLAG_LAYOUT_INSET_DECOR = 0x00010000,
|
|
|
|
FLAG_ALT_FOCUSABLE_IM = 0x00020000,
|
|
|
|
FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000,
|
|
|
|
FLAG_SHOW_WHEN_LOCKED = 0x00080000,
|
|
|
|
FLAG_SHOW_WALLPAPER = 0x00100000,
|
|
|
|
FLAG_TURN_SCREEN_ON = 0x00200000,
|
|
|
|
FLAG_DISMISS_KEYGUARD = 0x00400000,
|
|
|
|
FLAG_SPLIT_TOUCH = 0x00800000,
|
2013-10-02 10:13:27 -07:00
|
|
|
FLAG_SLIPPERY = 0x20000000,
|
|
|
|
FLAG_NEEDS_MENU_KEY = 0x40000000,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Private Window flags from WindowManager.LayoutParams
|
|
|
|
enum {
|
|
|
|
PRIVATE_FLAG_SYSTEM_ERROR = 0x00000100,
|
2011-01-10 11:17:36 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
// Window types from WindowManager.LayoutParams
|
|
|
|
enum {
|
|
|
|
FIRST_APPLICATION_WINDOW = 1,
|
|
|
|
TYPE_BASE_APPLICATION = 1,
|
|
|
|
TYPE_APPLICATION = 2,
|
|
|
|
TYPE_APPLICATION_STARTING = 3,
|
|
|
|
LAST_APPLICATION_WINDOW = 99,
|
|
|
|
FIRST_SUB_WINDOW = 1000,
|
|
|
|
TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW,
|
|
|
|
TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1,
|
|
|
|
TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2,
|
|
|
|
TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3,
|
|
|
|
TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4,
|
|
|
|
LAST_SUB_WINDOW = 1999,
|
|
|
|
FIRST_SYSTEM_WINDOW = 2000,
|
|
|
|
TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW,
|
|
|
|
TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1,
|
|
|
|
TYPE_PHONE = FIRST_SYSTEM_WINDOW+2,
|
|
|
|
TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3,
|
|
|
|
TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4,
|
|
|
|
TYPE_TOAST = FIRST_SYSTEM_WINDOW+5,
|
|
|
|
TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6,
|
|
|
|
TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7,
|
|
|
|
TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8,
|
|
|
|
TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9,
|
|
|
|
TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10,
|
|
|
|
TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11,
|
|
|
|
TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12,
|
|
|
|
TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13,
|
2011-04-27 14:07:12 -04:00
|
|
|
TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14,
|
2011-01-10 11:17:36 -08:00
|
|
|
TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15,
|
|
|
|
TYPE_DRAG = FIRST_SYSTEM_WINDOW+16,
|
2011-04-27 14:07:12 -04:00
|
|
|
TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17,
|
|
|
|
TYPE_POINTER = FIRST_SYSTEM_WINDOW+18,
|
On-screen navigation bar (separate from the status bar).
In Honeycomb we introduced navigation controls in the status
bar, for xlarge devices without physical buttons. What about
phones? The status bar is pretty cramped already, and
besides, it's at the top of the display most of the time,
not at the bottom where your thumb is likely to be.
Enter the navigation bar. It's a new window type that
appears atop almost everything (including the keyguard); the
window manager subtracts its rectangle from the default
visible rectangle of other windows (including the status bar
and notification shade).
However, it behaves (on phones) like the status bar in that
applications that request fullscreen windows can get access
to those pixels. Well, almost; they need cooperation from
the navigation bar implementation to make the navbar
disappear, just like the status bar.
The current SystemUI implementation of the navigation bar on
phones is still rough, but it has the basics:
+ back, home, and menu keys (NB: we're showing menu all the
time right now because checking the api level of the
package owning the top window is currently a poor
indicator of whether the app requires the menu key)
+ it tries to stick to the same physical end of the device,
regardless of device orientation (on a phone, this is
the strip of land closest to the microphone)
Change-Id: Ic613a3351220af0bbfbdef63e1d99cbefd5ed1c2
2011-04-22 07:55:02 -04:00
|
|
|
TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19,
|
2011-09-08 18:51:14 -07:00
|
|
|
TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20,
|
|
|
|
TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21,
|
2011-01-10 11:17:36 -08:00
|
|
|
LAST_SYSTEM_WINDOW = 2999,
|
|
|
|
};
|
|
|
|
|
2011-06-14 20:22:50 -07:00
|
|
|
enum {
|
|
|
|
INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES = 0x00000001,
|
2012-09-30 18:58:59 -07:00
|
|
|
INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002,
|
|
|
|
INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004,
|
2011-06-14 20:22:50 -07:00
|
|
|
};
|
|
|
|
|
2011-01-10 11:17:36 -08:00
|
|
|
sp<InputChannel> inputChannel;
|
|
|
|
String8 name;
|
|
|
|
int32_t layoutParamsFlags;
|
2013-10-02 10:13:27 -07:00
|
|
|
int32_t layoutParamsPrivateFlags;
|
2011-01-10 11:17:36 -08:00
|
|
|
int32_t layoutParamsType;
|
|
|
|
nsecs_t dispatchingTimeout;
|
|
|
|
int32_t frameLeft;
|
|
|
|
int32_t frameTop;
|
|
|
|
int32_t frameRight;
|
|
|
|
int32_t frameBottom;
|
Better compat mode part one: start scaling windows.
First step of improving app screen size compatibility mode. When
running in compat mode, an application's windows are scaled up on
the screen rather than being small with 1:1 pixels.
Currently we scale the application to fill the entire screen, so
don't use an even pixel scaling. Though this may have some
negative impact on the appearance (it looks okay to me), it has a
big benefit of allowing us to now treat these apps as normal
full-screens apps and do the normal transition animations as you
move in and out and around in them.
This introduces fun stuff in the input system to take care of
modifying pointer coordinates to account for the app window
surface scaling. The input dispatcher is told about the scale
that is being applied to each window and, when there is one,
adjusts pointer events appropriately as they are being sent
to the transport.
Also modified is CompatibilityInfo, which has been greatly
simplified to not be so insane and incomprehendible. It is
now simple -- when constructed it determines if the given app
is compatible with the current screen size and density, and
that is that.
There are new APIs on ActivityManagerService to put applications
that we would traditionally consider compatible with larger screens
in compatibility mode. This is the start of a facility to have
a UI affordance for a user to switch apps in and out of
compatibility.
To test switching of modes, there is a new variation of the "am"
command to do this: am screen-compat [on|off] [package]
This mode switching has the fundamentals of restarting activities
when it is changed, though the state still needs to be persisted
and the overall mode switch cleaned up.
For the few small apps I have tested, things mostly seem to be
working well. I know of one problem with the text selection
handles being drawn at the wrong position because at some point
the window offset is being scaled incorrectly. There are
probably other similar issues around the interaction between
two windows because the different window coordinate spaces are
done in a hacky way instead of being formally integrated into
the window manager layout process.
Change-Id: Ie038e3746b448135117bd860859d74e360938557
2011-04-27 18:52:56 -04:00
|
|
|
float scaleFactor;
|
2011-01-16 14:06:57 -08:00
|
|
|
SkRegion touchableRegion;
|
2011-01-10 11:17:36 -08:00
|
|
|
bool visible;
|
|
|
|
bool canReceiveKeys;
|
|
|
|
bool hasFocus;
|
|
|
|
bool hasWallpaper;
|
|
|
|
bool paused;
|
|
|
|
int32_t layer;
|
|
|
|
int32_t ownerPid;
|
|
|
|
int32_t ownerUid;
|
2011-06-14 20:22:50 -07:00
|
|
|
int32_t inputFeatures;
|
2012-09-09 20:33:43 -07:00
|
|
|
int32_t displayId;
|
2011-01-10 11:17:36 -08:00
|
|
|
|
2011-01-16 14:06:57 -08:00
|
|
|
bool touchableRegionContainsPoint(int32_t x, int32_t y) const;
|
2011-01-10 11:17:36 -08:00
|
|
|
bool frameContainsPoint(int32_t x, int32_t y) const;
|
|
|
|
|
|
|
|
/* Returns true if the window is of a trusted type that is allowed to silently
|
|
|
|
* overlay other windows for the purpose of implementing the secure views feature.
|
|
|
|
* Trusted overlays, such as IME windows, can partly obscure other windows without causing
|
|
|
|
* motion events to be delivered to them with AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED.
|
|
|
|
*/
|
|
|
|
bool isTrustedOverlay() const;
|
|
|
|
|
|
|
|
bool supportsSplitTouch() const;
|
2011-08-30 20:34:48 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle for a window that can receive input.
|
|
|
|
*
|
|
|
|
* Used by the native input dispatcher to indirectly refer to the window manager objects
|
|
|
|
* that describe a window.
|
|
|
|
*/
|
|
|
|
class InputWindowHandle : public RefBase {
|
|
|
|
public:
|
|
|
|
const sp<InputApplicationHandle> inputApplicationHandle;
|
|
|
|
|
|
|
|
inline const InputWindowInfo* getInfo() const {
|
|
|
|
return mInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline sp<InputChannel> getInputChannel() const {
|
|
|
|
return mInfo ? mInfo->inputChannel : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline String8 getName() const {
|
|
|
|
return mInfo ? mInfo->name : String8("<invalid>");
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nsecs_t getDispatchingTimeout(nsecs_t defaultValue) const {
|
|
|
|
return mInfo ? mInfo->dispatchingTimeout : defaultValue;
|
|
|
|
}
|
2011-07-13 22:51:29 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Requests that the state of this object be updated to reflect
|
|
|
|
* the most current available information about the application.
|
|
|
|
*
|
|
|
|
* This method should only be called from within the input dispatcher's
|
|
|
|
* critical section.
|
|
|
|
*
|
|
|
|
* Returns true on success, or false if the handle is no longer valid.
|
|
|
|
*/
|
2011-08-30 20:34:48 -07:00
|
|
|
virtual bool updateInfo() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Releases the storage used by the associated information when it is
|
|
|
|
* no longer needed.
|
|
|
|
*/
|
|
|
|
void releaseInfo();
|
2011-07-13 22:51:29 -07:00
|
|
|
|
|
|
|
protected:
|
2011-08-30 20:34:48 -07:00
|
|
|
InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle);
|
|
|
|
virtual ~InputWindowHandle();
|
|
|
|
|
|
|
|
InputWindowInfo* mInfo;
|
2011-01-10 11:17:36 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace android
|
|
|
|
|
|
|
|
#endif // _UI_INPUT_WINDOW_H
|