widget/gonk/libui/InputApplication.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/gonk/libui/InputApplication.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,83 @@
     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_APPLICATION_H
    1.21 +#define _UI_INPUT_APPLICATION_H
    1.22 +
    1.23 +#include "Input.h"
    1.24 +
    1.25 +#include <utils/RefBase.h>
    1.26 +#include <utils/Timers.h>
    1.27 +#include <utils/String8.h>
    1.28 +
    1.29 +namespace android {
    1.30 +
    1.31 +/*
    1.32 + * Describes the properties of an application that can receive input.
    1.33 + */
    1.34 +struct InputApplicationInfo {
    1.35 +    String8 name;
    1.36 +    nsecs_t dispatchingTimeout;
    1.37 +};
    1.38 +
    1.39 +
    1.40 +/*
    1.41 + * Handle for an application that can receive input.
    1.42 + *
    1.43 + * Used by the native input dispatcher as a handle for the window manager objects
    1.44 + * that describe an application.
    1.45 + */
    1.46 +class InputApplicationHandle : public RefBase {
    1.47 +public:
    1.48 +    inline const InputApplicationInfo* getInfo() const {
    1.49 +        return mInfo;
    1.50 +    }
    1.51 +
    1.52 +    inline String8 getName() const {
    1.53 +        return mInfo ? mInfo->name : String8("<invalid>");
    1.54 +    }
    1.55 +
    1.56 +    inline nsecs_t getDispatchingTimeout(nsecs_t defaultValue) const {
    1.57 +        return mInfo ? mInfo->dispatchingTimeout : defaultValue;
    1.58 +    }
    1.59 +
    1.60 +    /**
    1.61 +     * Requests that the state of this object be updated to reflect
    1.62 +     * the most current available information about the application.
    1.63 +     *
    1.64 +     * This method should only be called from within the input dispatcher's
    1.65 +     * critical section.
    1.66 +     *
    1.67 +     * Returns true on success, or false if the handle is no longer valid.
    1.68 +     */
    1.69 +    virtual bool updateInfo() = 0;
    1.70 +
    1.71 +    /**
    1.72 +     * Releases the storage used by the associated information when it is
    1.73 +     * no longer needed.
    1.74 +     */
    1.75 +    void releaseInfo();
    1.76 +
    1.77 +protected:
    1.78 +    InputApplicationHandle();
    1.79 +    virtual ~InputApplicationHandle();
    1.80 +
    1.81 +    InputApplicationInfo* mInfo;
    1.82 +};
    1.83 +
    1.84 +} // namespace android
    1.85 +
    1.86 +#endif // _UI_INPUT_APPLICATION_H

mercurial