|
1 /* -*- Mode: c++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4; -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef nsAppShell_h__ |
|
7 #define nsAppShell_h__ |
|
8 |
|
9 #include "mozilla/CondVar.h" |
|
10 #include "mozilla/Mutex.h" |
|
11 #include "nsBaseAppShell.h" |
|
12 #include "nsCOMPtr.h" |
|
13 #include "nsTArray.h" |
|
14 #include "nsInterfaceHashtable.h" |
|
15 #include "nsIAndroidBridge.h" |
|
16 |
|
17 namespace mozilla { |
|
18 class AndroidGeckoEvent; |
|
19 bool ProcessNextEvent(); |
|
20 void NotifyEvent(); |
|
21 } |
|
22 |
|
23 class nsWindow; |
|
24 |
|
25 class nsAppShell : |
|
26 public nsBaseAppShell |
|
27 { |
|
28 typedef mozilla::CondVar CondVar; |
|
29 typedef mozilla::Mutex Mutex; |
|
30 |
|
31 public: |
|
32 static nsAppShell *gAppShell; |
|
33 static mozilla::AndroidGeckoEvent *gEarlyEvent; |
|
34 |
|
35 nsAppShell(); |
|
36 |
|
37 NS_DECL_ISUPPORTS_INHERITED |
|
38 NS_DECL_NSIOBSERVER |
|
39 |
|
40 nsresult Init(); |
|
41 |
|
42 void NotifyNativeEvent(); |
|
43 |
|
44 virtual bool ProcessNextNativeEvent(bool mayWait); |
|
45 |
|
46 void PostEvent(mozilla::AndroidGeckoEvent *event); |
|
47 void OnResume(); |
|
48 |
|
49 nsresult AddObserver(const nsAString &aObserverKey, nsIObserver *aObserver); |
|
50 void ResendLastResizeEvent(nsWindow* aDest); |
|
51 |
|
52 void SetBrowserApp(nsIAndroidBrowserApp* aBrowserApp) { |
|
53 mBrowserApp = aBrowserApp; |
|
54 } |
|
55 |
|
56 void GetBrowserApp(nsIAndroidBrowserApp* *aBrowserApp) { |
|
57 *aBrowserApp = mBrowserApp; |
|
58 } |
|
59 |
|
60 protected: |
|
61 virtual void ScheduleNativeEventCallback(); |
|
62 virtual ~nsAppShell(); |
|
63 |
|
64 Mutex mQueueLock; |
|
65 Mutex mCondLock; |
|
66 CondVar mQueueCond; |
|
67 mozilla::AndroidGeckoEvent *mQueuedDrawEvent; |
|
68 mozilla::AndroidGeckoEvent *mQueuedViewportEvent; |
|
69 bool mAllowCoalescingNextDraw; |
|
70 bool mAllowCoalescingTouches; |
|
71 nsTArray<mozilla::AndroidGeckoEvent *> mEventQueue; |
|
72 nsInterfaceHashtable<nsStringHashKey, nsIObserver> mObserversHash; |
|
73 |
|
74 mozilla::AndroidGeckoEvent *PopNextEvent(); |
|
75 mozilla::AndroidGeckoEvent *PeekNextEvent(); |
|
76 |
|
77 nsCOMPtr<nsIAndroidBrowserApp> mBrowserApp; |
|
78 }; |
|
79 |
|
80 #endif // nsAppShell_h__ |
|
81 |