2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-11-11 00:17:46 +00:00
|
|
|
|
|
|
|
#ifndef nsAppShell_h
|
|
|
|
#define nsAppShell_h
|
|
|
|
|
2012-01-25 19:00:34 +00:00
|
|
|
#include <queue>
|
|
|
|
|
|
|
|
#include "mozilla/Mutex.h"
|
2011-11-11 00:17:46 +00:00
|
|
|
#include "nsBaseAppShell.h"
|
2011-12-29 22:39:25 +00:00
|
|
|
#include "nsRect.h"
|
2011-11-22 19:51:51 +00:00
|
|
|
#include "nsTArray.h"
|
2011-11-11 00:17:46 +00:00
|
|
|
|
2012-01-25 19:00:34 +00:00
|
|
|
#include "utils/RefBase.h"
|
|
|
|
|
2011-11-11 00:17:46 +00:00
|
|
|
namespace mozilla {
|
|
|
|
bool ProcessNextEvent();
|
|
|
|
void NotifyEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
extern bool gDrawRequest;
|
|
|
|
|
|
|
|
class FdHandler;
|
|
|
|
typedef void(*FdHandlerCallback)(int, FdHandler *);
|
|
|
|
|
|
|
|
class FdHandler {
|
|
|
|
public:
|
2011-12-29 22:39:25 +00:00
|
|
|
FdHandler()
|
|
|
|
{
|
|
|
|
memset(name, 0, sizeof(name));
|
|
|
|
}
|
2011-11-11 00:17:46 +00:00
|
|
|
|
|
|
|
int fd;
|
2011-12-29 22:39:25 +00:00
|
|
|
char name[64];
|
2011-11-11 00:17:46 +00:00
|
|
|
FdHandlerCallback func;
|
|
|
|
void run()
|
|
|
|
{
|
|
|
|
func(fd, this);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-01-25 19:00:34 +00:00
|
|
|
namespace android {
|
|
|
|
class EventHub;
|
|
|
|
class InputReader;
|
|
|
|
class InputReaderThread;
|
|
|
|
}
|
|
|
|
|
|
|
|
class GeckoInputReaderPolicy;
|
|
|
|
class GeckoInputDispatcher;
|
|
|
|
|
2011-11-11 00:17:46 +00:00
|
|
|
class nsAppShell : public nsBaseAppShell {
|
|
|
|
public:
|
|
|
|
nsAppShell();
|
|
|
|
|
|
|
|
nsresult Init();
|
2012-06-10 23:44:50 +00:00
|
|
|
|
|
|
|
NS_IMETHOD Exit() MOZ_OVERRIDE;
|
|
|
|
|
2011-11-11 00:17:46 +00:00
|
|
|
virtual bool ProcessNextNativeEvent(bool maywait);
|
|
|
|
|
|
|
|
void NotifyNativeEvent();
|
|
|
|
|
2012-03-25 10:06:02 +00:00
|
|
|
static void NotifyScreenInitialized();
|
2012-04-25 03:59:01 +00:00
|
|
|
static void NotifyScreenRotation();
|
2012-03-25 10:06:02 +00:00
|
|
|
|
2011-11-11 00:17:46 +00:00
|
|
|
protected:
|
|
|
|
virtual ~nsAppShell();
|
|
|
|
|
|
|
|
virtual void ScheduleNativeEventCallback();
|
|
|
|
|
2011-12-29 22:39:25 +00:00
|
|
|
private:
|
2011-12-29 22:39:25 +00:00
|
|
|
nsresult AddFdHandler(int fd, FdHandlerCallback handlerFunc,
|
|
|
|
const char* deviceName);
|
2012-03-25 10:06:02 +00:00
|
|
|
void InitInputDevices();
|
2011-12-29 22:39:25 +00:00
|
|
|
|
2011-11-11 00:17:46 +00:00
|
|
|
// This is somewhat racy but is perfectly safe given how the callback works
|
|
|
|
bool mNativeCallbackRequest;
|
|
|
|
nsTArray<FdHandler> mHandlers;
|
2012-01-25 19:00:34 +00:00
|
|
|
|
|
|
|
android::sp<android::EventHub> mEventHub;
|
|
|
|
android::sp<GeckoInputReaderPolicy> mReaderPolicy;
|
|
|
|
android::sp<GeckoInputDispatcher> mDispatcher;
|
|
|
|
android::sp<android::InputReader> mReader;
|
|
|
|
android::sp<android::InputReaderThread> mReaderThread;
|
2011-11-11 00:17:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsAppShell_h */
|
|
|
|
|