Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (C) 2011 The Android Open Source Project |
michael@0 | 3 | * |
michael@0 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 5 | * you may not use this file except in compliance with the License. |
michael@0 | 6 | * You may obtain a copy of the License at |
michael@0 | 7 | * |
michael@0 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 9 | * |
michael@0 | 10 | * Unless required by applicable law or agreed to in writing, software |
michael@0 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 13 | * See the License for the specific language governing permissions and |
michael@0 | 14 | * limitations under the License. |
michael@0 | 15 | */ |
michael@0 | 16 | |
michael@0 | 17 | #ifndef _UI_INPUT_APPLICATION_H |
michael@0 | 18 | #define _UI_INPUT_APPLICATION_H |
michael@0 | 19 | |
michael@0 | 20 | #include "Input.h" |
michael@0 | 21 | |
michael@0 | 22 | #include <utils/RefBase.h> |
michael@0 | 23 | #include <utils/Timers.h> |
michael@0 | 24 | #include <utils/String8.h> |
michael@0 | 25 | |
michael@0 | 26 | namespace android { |
michael@0 | 27 | |
michael@0 | 28 | /* |
michael@0 | 29 | * Describes the properties of an application that can receive input. |
michael@0 | 30 | */ |
michael@0 | 31 | struct InputApplicationInfo { |
michael@0 | 32 | String8 name; |
michael@0 | 33 | nsecs_t dispatchingTimeout; |
michael@0 | 34 | }; |
michael@0 | 35 | |
michael@0 | 36 | |
michael@0 | 37 | /* |
michael@0 | 38 | * Handle for an application that can receive input. |
michael@0 | 39 | * |
michael@0 | 40 | * Used by the native input dispatcher as a handle for the window manager objects |
michael@0 | 41 | * that describe an application. |
michael@0 | 42 | */ |
michael@0 | 43 | class InputApplicationHandle : public RefBase { |
michael@0 | 44 | public: |
michael@0 | 45 | inline const InputApplicationInfo* getInfo() const { |
michael@0 | 46 | return mInfo; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | inline String8 getName() const { |
michael@0 | 50 | return mInfo ? mInfo->name : String8("<invalid>"); |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | inline nsecs_t getDispatchingTimeout(nsecs_t defaultValue) const { |
michael@0 | 54 | return mInfo ? mInfo->dispatchingTimeout : defaultValue; |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | /** |
michael@0 | 58 | * Requests that the state of this object be updated to reflect |
michael@0 | 59 | * the most current available information about the application. |
michael@0 | 60 | * |
michael@0 | 61 | * This method should only be called from within the input dispatcher's |
michael@0 | 62 | * critical section. |
michael@0 | 63 | * |
michael@0 | 64 | * Returns true on success, or false if the handle is no longer valid. |
michael@0 | 65 | */ |
michael@0 | 66 | virtual bool updateInfo() = 0; |
michael@0 | 67 | |
michael@0 | 68 | /** |
michael@0 | 69 | * Releases the storage used by the associated information when it is |
michael@0 | 70 | * no longer needed. |
michael@0 | 71 | */ |
michael@0 | 72 | void releaseInfo(); |
michael@0 | 73 | |
michael@0 | 74 | protected: |
michael@0 | 75 | InputApplicationHandle(); |
michael@0 | 76 | virtual ~InputApplicationHandle(); |
michael@0 | 77 | |
michael@0 | 78 | InputApplicationInfo* mInfo; |
michael@0 | 79 | }; |
michael@0 | 80 | |
michael@0 | 81 | } // namespace android |
michael@0 | 82 | |
michael@0 | 83 | #endif // _UI_INPUT_APPLICATION_H |