widget/gonk/nsAppShell.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/gonk/nsAppShell.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,107 @@
     1.4 +/* Copyright 2012 Mozilla Foundation and Mozilla contributors
     1.5 + *
     1.6 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.7 + * you may not use this file except in compliance with the License.
     1.8 + * You may obtain a copy of the License at
     1.9 + *
    1.10 + *     http://www.apache.org/licenses/LICENSE-2.0
    1.11 + *
    1.12 + * Unless required by applicable law or agreed to in writing, software
    1.13 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.15 + * See the License for the specific language governing permissions and
    1.16 + * limitations under the License.
    1.17 + */
    1.18 +
    1.19 +#ifndef nsAppShell_h
    1.20 +#define nsAppShell_h
    1.21 +
    1.22 +#include <queue>
    1.23 +
    1.24 +#include "mozilla/Mutex.h"
    1.25 +#include "nsBaseAppShell.h"
    1.26 +#include "nsTArray.h"
    1.27 +
    1.28 +#include "utils/RefBase.h"
    1.29 +
    1.30 +namespace mozilla {
    1.31 +bool ProcessNextEvent();
    1.32 +void NotifyEvent();
    1.33 +}
    1.34 +
    1.35 +extern bool gDrawRequest;
    1.36 +
    1.37 +class FdHandler;
    1.38 +typedef void(*FdHandlerCallback)(int, FdHandler *);
    1.39 +
    1.40 +class FdHandler {
    1.41 +public:
    1.42 +    FdHandler()
    1.43 +    {
    1.44 +        memset(name, 0, sizeof(name));
    1.45 +    }
    1.46 +
    1.47 +    int fd;
    1.48 +    char name[64];
    1.49 +    FdHandlerCallback func;
    1.50 +    void run()
    1.51 +    {
    1.52 +        func(fd, this);
    1.53 +    }
    1.54 +};
    1.55 +
    1.56 +namespace android {
    1.57 +class EventHub;
    1.58 +class InputReader;
    1.59 +class InputReaderThread;
    1.60 +}
    1.61 +
    1.62 +class GeckoInputReaderPolicy;
    1.63 +class GeckoInputDispatcher;
    1.64 +
    1.65 +class nsAppShell : public nsBaseAppShell {
    1.66 +public:
    1.67 +    nsAppShell();
    1.68 +
    1.69 +    NS_DECL_ISUPPORTS_INHERITED
    1.70 +    NS_DECL_NSIOBSERVER
    1.71 +
    1.72 +    nsresult Init();
    1.73 +
    1.74 +    NS_IMETHOD Exit() MOZ_OVERRIDE;
    1.75 +
    1.76 +    virtual bool ProcessNextNativeEvent(bool maywait);
    1.77 +
    1.78 +    void NotifyNativeEvent();
    1.79 +
    1.80 +    static void NotifyScreenInitialized();
    1.81 +    static void NotifyScreenRotation();
    1.82 +
    1.83 +protected:
    1.84 +    virtual ~nsAppShell();
    1.85 +
    1.86 +    virtual void ScheduleNativeEventCallback();
    1.87 +
    1.88 +private:
    1.89 +    nsresult AddFdHandler(int fd, FdHandlerCallback handlerFunc,
    1.90 +                          const char* deviceName);
    1.91 +    void InitInputDevices();
    1.92 +
    1.93 +    // This is somewhat racy but is perfectly safe given how the callback works
    1.94 +    bool mNativeCallbackRequest;
    1.95 +
    1.96 +    // This gets flipped when we observe a browser-ui-startup-complete.
    1.97 +    // browser-ui-startup-complete means that we're really ready to draw
    1.98 +    // and can stop the boot animation
    1.99 +    bool mEnableDraw;
   1.100 +    nsTArray<FdHandler> mHandlers;
   1.101 +
   1.102 +    android::sp<android::EventHub>               mEventHub;
   1.103 +    android::sp<GeckoInputReaderPolicy> mReaderPolicy;
   1.104 +    android::sp<GeckoInputDispatcher>   mDispatcher;
   1.105 +    android::sp<android::InputReader>            mReader;
   1.106 +    android::sp<android::InputReaderThread>      mReaderThread;
   1.107 +};
   1.108 +
   1.109 +#endif /* nsAppShell_h */
   1.110 +

mercurial