widget/gonk/nsAppShell.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:c838d9943265
1 /* Copyright 2012 Mozilla Foundation and Mozilla contributors
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #ifndef nsAppShell_h
17 #define nsAppShell_h
18
19 #include <queue>
20
21 #include "mozilla/Mutex.h"
22 #include "nsBaseAppShell.h"
23 #include "nsTArray.h"
24
25 #include "utils/RefBase.h"
26
27 namespace mozilla {
28 bool ProcessNextEvent();
29 void NotifyEvent();
30 }
31
32 extern bool gDrawRequest;
33
34 class FdHandler;
35 typedef void(*FdHandlerCallback)(int, FdHandler *);
36
37 class FdHandler {
38 public:
39 FdHandler()
40 {
41 memset(name, 0, sizeof(name));
42 }
43
44 int fd;
45 char name[64];
46 FdHandlerCallback func;
47 void run()
48 {
49 func(fd, this);
50 }
51 };
52
53 namespace android {
54 class EventHub;
55 class InputReader;
56 class InputReaderThread;
57 }
58
59 class GeckoInputReaderPolicy;
60 class GeckoInputDispatcher;
61
62 class nsAppShell : public nsBaseAppShell {
63 public:
64 nsAppShell();
65
66 NS_DECL_ISUPPORTS_INHERITED
67 NS_DECL_NSIOBSERVER
68
69 nsresult Init();
70
71 NS_IMETHOD Exit() MOZ_OVERRIDE;
72
73 virtual bool ProcessNextNativeEvent(bool maywait);
74
75 void NotifyNativeEvent();
76
77 static void NotifyScreenInitialized();
78 static void NotifyScreenRotation();
79
80 protected:
81 virtual ~nsAppShell();
82
83 virtual void ScheduleNativeEventCallback();
84
85 private:
86 nsresult AddFdHandler(int fd, FdHandlerCallback handlerFunc,
87 const char* deviceName);
88 void InitInputDevices();
89
90 // This is somewhat racy but is perfectly safe given how the callback works
91 bool mNativeCallbackRequest;
92
93 // This gets flipped when we observe a browser-ui-startup-complete.
94 // browser-ui-startup-complete means that we're really ready to draw
95 // and can stop the boot animation
96 bool mEnableDraw;
97 nsTArray<FdHandler> mHandlers;
98
99 android::sp<android::EventHub> mEventHub;
100 android::sp<GeckoInputReaderPolicy> mReaderPolicy;
101 android::sp<GeckoInputDispatcher> mDispatcher;
102 android::sp<android::InputReader> mReader;
103 android::sp<android::InputReaderThread> mReaderThread;
104 };
105
106 #endif /* nsAppShell_h */
107

mercurial