michael@0: /* Copyright 2012 Mozilla Foundation and Mozilla contributors 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 nsAppShell_h michael@0: #define nsAppShell_h michael@0: michael@0: #include michael@0: michael@0: #include "mozilla/Mutex.h" michael@0: #include "nsBaseAppShell.h" michael@0: #include "nsTArray.h" michael@0: michael@0: #include "utils/RefBase.h" michael@0: michael@0: namespace mozilla { michael@0: bool ProcessNextEvent(); michael@0: void NotifyEvent(); michael@0: } michael@0: michael@0: extern bool gDrawRequest; michael@0: michael@0: class FdHandler; michael@0: typedef void(*FdHandlerCallback)(int, FdHandler *); michael@0: michael@0: class FdHandler { michael@0: public: michael@0: FdHandler() michael@0: { michael@0: memset(name, 0, sizeof(name)); michael@0: } michael@0: michael@0: int fd; michael@0: char name[64]; michael@0: FdHandlerCallback func; michael@0: void run() michael@0: { michael@0: func(fd, this); michael@0: } michael@0: }; michael@0: michael@0: namespace android { michael@0: class EventHub; michael@0: class InputReader; michael@0: class InputReaderThread; michael@0: } michael@0: michael@0: class GeckoInputReaderPolicy; michael@0: class GeckoInputDispatcher; michael@0: michael@0: class nsAppShell : public nsBaseAppShell { michael@0: public: michael@0: nsAppShell(); michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_NSIOBSERVER michael@0: michael@0: nsresult Init(); michael@0: michael@0: NS_IMETHOD Exit() MOZ_OVERRIDE; michael@0: michael@0: virtual bool ProcessNextNativeEvent(bool maywait); michael@0: michael@0: void NotifyNativeEvent(); michael@0: michael@0: static void NotifyScreenInitialized(); michael@0: static void NotifyScreenRotation(); michael@0: michael@0: protected: michael@0: virtual ~nsAppShell(); michael@0: michael@0: virtual void ScheduleNativeEventCallback(); michael@0: michael@0: private: michael@0: nsresult AddFdHandler(int fd, FdHandlerCallback handlerFunc, michael@0: const char* deviceName); michael@0: void InitInputDevices(); michael@0: michael@0: // This is somewhat racy but is perfectly safe given how the callback works michael@0: bool mNativeCallbackRequest; michael@0: michael@0: // This gets flipped when we observe a browser-ui-startup-complete. michael@0: // browser-ui-startup-complete means that we're really ready to draw michael@0: // and can stop the boot animation michael@0: bool mEnableDraw; michael@0: nsTArray mHandlers; michael@0: michael@0: android::sp mEventHub; michael@0: android::sp mReaderPolicy; michael@0: android::sp mDispatcher; michael@0: android::sp mReader; michael@0: android::sp mReaderThread; michael@0: }; michael@0: michael@0: #endif /* nsAppShell_h */ michael@0: