2012-07-20 02:10:44 -07: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-10 16:17:46 -08:00
|
|
|
|
|
|
|
#ifndef nsAppShell_h
|
|
|
|
#define nsAppShell_h
|
|
|
|
|
2012-01-25 11:00:34 -08:00
|
|
|
#include <queue>
|
|
|
|
|
|
|
|
#include "mozilla/Mutex.h"
|
2011-11-10 16:17:46 -08:00
|
|
|
#include "nsBaseAppShell.h"
|
2011-12-29 14:39:25 -08:00
|
|
|
#include "nsRect.h"
|
2011-11-22 11:51:51 -08:00
|
|
|
#include "nsTArray.h"
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2012-01-25 11:00:34 -08:00
|
|
|
#include "utils/RefBase.h"
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
namespace mozilla {
|
|
|
|
bool ProcessNextEvent();
|
|
|
|
void NotifyEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
extern bool gDrawRequest;
|
|
|
|
|
|
|
|
class FdHandler;
|
|
|
|
typedef void(*FdHandlerCallback)(int, FdHandler *);
|
|
|
|
|
|
|
|
class FdHandler {
|
|
|
|
public:
|
2011-12-29 14:39:25 -08:00
|
|
|
FdHandler()
|
|
|
|
{
|
|
|
|
memset(name, 0, sizeof(name));
|
|
|
|
}
|
2011-11-10 16:17:46 -08:00
|
|
|
|
|
|
|
int fd;
|
2011-12-29 14:39:25 -08:00
|
|
|
char name[64];
|
2011-11-10 16:17:46 -08:00
|
|
|
FdHandlerCallback func;
|
|
|
|
void run()
|
|
|
|
{
|
|
|
|
func(fd, this);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-01-25 11:00:34 -08:00
|
|
|
namespace android {
|
|
|
|
class EventHub;
|
|
|
|
class InputReader;
|
|
|
|
class InputReaderThread;
|
|
|
|
}
|
|
|
|
|
|
|
|
class GeckoInputReaderPolicy;
|
|
|
|
class GeckoInputDispatcher;
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
class nsAppShell : public nsBaseAppShell {
|
|
|
|
public:
|
|
|
|
nsAppShell();
|
|
|
|
|
|
|
|
nsresult Init();
|
2012-06-10 16:44:50 -07:00
|
|
|
|
|
|
|
NS_IMETHOD Exit() MOZ_OVERRIDE;
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
virtual bool ProcessNextNativeEvent(bool maywait);
|
|
|
|
|
|
|
|
void NotifyNativeEvent();
|
|
|
|
|
2012-03-25 03:06:02 -07:00
|
|
|
static void NotifyScreenInitialized();
|
2012-04-24 20:59:01 -07:00
|
|
|
static void NotifyScreenRotation();
|
2012-03-25 03:06:02 -07:00
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
protected:
|
|
|
|
virtual ~nsAppShell();
|
|
|
|
|
|
|
|
virtual void ScheduleNativeEventCallback();
|
|
|
|
|
2011-12-29 14:39:25 -08:00
|
|
|
private:
|
2011-12-29 14:39:25 -08:00
|
|
|
nsresult AddFdHandler(int fd, FdHandlerCallback handlerFunc,
|
|
|
|
const char* deviceName);
|
2012-03-25 03:06:02 -07:00
|
|
|
void InitInputDevices();
|
2011-12-29 14:39:25 -08:00
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
// This is somewhat racy but is perfectly safe given how the callback works
|
|
|
|
bool mNativeCallbackRequest;
|
|
|
|
nsTArray<FdHandler> mHandlers;
|
2012-01-25 11:00:34 -08: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-10 16:17:46 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsAppShell_h */
|
|
|
|
|