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_APPLICATION_H michael@0: #define _UI_INPUT_APPLICATION_H michael@0: michael@0: #include "Input.h" michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: namespace android { michael@0: michael@0: /* michael@0: * Describes the properties of an application that can receive input. michael@0: */ michael@0: struct InputApplicationInfo { michael@0: String8 name; michael@0: nsecs_t dispatchingTimeout; michael@0: }; michael@0: michael@0: michael@0: /* michael@0: * Handle for an application that can receive input. michael@0: * michael@0: * Used by the native input dispatcher as a handle for the window manager objects michael@0: * that describe an application. michael@0: */ michael@0: class InputApplicationHandle : public RefBase { michael@0: public: michael@0: inline const InputApplicationInfo* getInfo() const { michael@0: return mInfo; 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: InputApplicationHandle(); michael@0: virtual ~InputApplicationHandle(); michael@0: michael@0: InputApplicationInfo* mInfo; michael@0: }; michael@0: michael@0: } // namespace android michael@0: michael@0: #endif // _UI_INPUT_APPLICATION_H