2012-07-20 13:10:44 +04:00
|
|
|
/* Copyright 2012 Mozilla Foundation and Mozilla contributors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2011-11-11 04:17:46 +04:00
|
|
|
|
|
|
|
#ifndef nsAppShell_h
|
|
|
|
#define nsAppShell_h
|
|
|
|
|
2012-01-25 23:00:34 +04:00
|
|
|
#include <queue>
|
|
|
|
|
|
|
|
#include "mozilla/Mutex.h"
|
2011-11-11 04:17:46 +04:00
|
|
|
#include "nsBaseAppShell.h"
|
2011-11-22 23:51:51 +04:00
|
|
|
#include "nsTArray.h"
|
2011-11-11 04:17:46 +04:00
|
|
|
|
2012-01-25 23:00:34 +04:00
|
|
|
#include "utils/RefBase.h"
|
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
namespace mozilla {
|
|
|
|
bool ProcessNextEvent();
|
|
|
|
void NotifyEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
extern bool gDrawRequest;
|
|
|
|
|
|
|
|
class FdHandler;
|
|
|
|
typedef void(*FdHandlerCallback)(int, FdHandler *);
|
|
|
|
|
|
|
|
class FdHandler {
|
|
|
|
public:
|
2011-12-30 02:39:25 +04:00
|
|
|
FdHandler()
|
|
|
|
{
|
|
|
|
memset(name, 0, sizeof(name));
|
|
|
|
}
|
2011-11-11 04:17:46 +04:00
|
|
|
|
|
|
|
int fd;
|
2011-12-30 02:39:25 +04:00
|
|
|
char name[64];
|
2011-11-11 04:17:46 +04:00
|
|
|
FdHandlerCallback func;
|
|
|
|
void run()
|
|
|
|
{
|
|
|
|
func(fd, this);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-01-25 23:00:34 +04:00
|
|
|
namespace android {
|
|
|
|
class EventHub;
|
|
|
|
class InputReader;
|
|
|
|
class InputReaderThread;
|
|
|
|
}
|
|
|
|
|
|
|
|
class GeckoInputReaderPolicy;
|
|
|
|
class GeckoInputDispatcher;
|
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
class nsAppShell : public nsBaseAppShell {
|
|
|
|
public:
|
|
|
|
nsAppShell();
|
|
|
|
|
2012-11-28 22:43:19 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
nsresult Init();
|
2012-06-11 03:44:50 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD Exit() override;
|
2012-06-11 03:44:50 +04:00
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
virtual bool ProcessNextNativeEvent(bool maywait);
|
|
|
|
|
|
|
|
void NotifyNativeEvent();
|
|
|
|
|
2012-03-25 14:06:02 +04:00
|
|
|
static void NotifyScreenInitialized();
|
2012-04-25 07:59:01 +04:00
|
|
|
static void NotifyScreenRotation();
|
2012-03-25 14:06:02 +04:00
|
|
|
|
2015-09-04 21:12:48 +03:00
|
|
|
void CheckPowerKey();
|
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
protected:
|
|
|
|
virtual ~nsAppShell();
|
|
|
|
|
|
|
|
virtual void ScheduleNativeEventCallback();
|
|
|
|
|
2011-12-30 02:39:25 +04:00
|
|
|
private:
|
2011-12-30 02:39:25 +04:00
|
|
|
nsresult AddFdHandler(int fd, FdHandlerCallback handlerFunc,
|
|
|
|
const char* deviceName);
|
2012-03-25 14:06:02 +04:00
|
|
|
void InitInputDevices();
|
2011-12-30 02:39:25 +04:00
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
// This is somewhat racy but is perfectly safe given how the callback works
|
|
|
|
bool mNativeCallbackRequest;
|
2012-11-28 22:43:19 +04:00
|
|
|
|
|
|
|
// This gets flipped when we observe a browser-ui-startup-complete.
|
|
|
|
// browser-ui-startup-complete means that we're really ready to draw
|
|
|
|
// and can stop the boot animation
|
|
|
|
bool mEnableDraw;
|
2011-11-11 04:17:46 +04:00
|
|
|
nsTArray<FdHandler> mHandlers;
|
2012-01-25 23:00:34 +04:00
|
|
|
|
|
|
|
android::sp<android::EventHub> mEventHub;
|
|
|
|
android::sp<GeckoInputReaderPolicy> mReaderPolicy;
|
|
|
|
android::sp<GeckoInputDispatcher> mDispatcher;
|
|
|
|
android::sp<android::InputReader> mReader;
|
|
|
|
android::sp<android::InputReaderThread> mReaderThread;
|
2015-09-04 21:12:48 +03:00
|
|
|
|
|
|
|
// Guard against checking power key after the first configuration change.
|
|
|
|
bool mPowerKeyChecked;
|
2011-11-11 04:17:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsAppShell_h */
|
|
|
|
|