|
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 nsWindow_h |
|
17 #define nsWindow_h |
|
18 |
|
19 #include "nsBaseWidget.h" |
|
20 #include "nsRegion.h" |
|
21 #include "nsIIdleServiceInternal.h" |
|
22 |
|
23 extern nsIntRect gScreenBounds; |
|
24 |
|
25 namespace mozilla { |
|
26 namespace gl { |
|
27 class GLContext; |
|
28 } |
|
29 namespace layers { |
|
30 class LayersManager; |
|
31 } |
|
32 } |
|
33 |
|
34 namespace android { |
|
35 class FramebufferNativeWindow; |
|
36 } |
|
37 |
|
38 namespace widget { |
|
39 struct InputContext; |
|
40 struct InputContextAction; |
|
41 } |
|
42 |
|
43 class nsWindow : public nsBaseWidget |
|
44 { |
|
45 public: |
|
46 nsWindow(); |
|
47 virtual ~nsWindow(); |
|
48 |
|
49 static void DoDraw(void); |
|
50 static nsEventStatus DispatchInputEvent(mozilla::WidgetGUIEvent& aEvent, |
|
51 bool* aWasCaptured = nullptr); |
|
52 |
|
53 NS_IMETHOD Create(nsIWidget *aParent, |
|
54 void *aNativeParent, |
|
55 const nsIntRect &aRect, |
|
56 nsDeviceContext *aContext, |
|
57 nsWidgetInitData *aInitData); |
|
58 NS_IMETHOD Destroy(void); |
|
59 |
|
60 NS_IMETHOD Show(bool aState); |
|
61 virtual bool IsVisible() const; |
|
62 NS_IMETHOD ConstrainPosition(bool aAllowSlop, |
|
63 int32_t *aX, |
|
64 int32_t *aY); |
|
65 NS_IMETHOD Move(double aX, |
|
66 double aY); |
|
67 NS_IMETHOD Resize(double aWidth, |
|
68 double aHeight, |
|
69 bool aRepaint); |
|
70 NS_IMETHOD Resize(double aX, |
|
71 double aY, |
|
72 double aWidth, |
|
73 double aHeight, |
|
74 bool aRepaint); |
|
75 NS_IMETHOD Enable(bool aState); |
|
76 virtual bool IsEnabled() const; |
|
77 NS_IMETHOD SetFocus(bool aRaise = false); |
|
78 NS_IMETHOD ConfigureChildren(const nsTArray<nsIWidget::Configuration>&); |
|
79 NS_IMETHOD Invalidate(const nsIntRect &aRect); |
|
80 virtual void* GetNativeData(uint32_t aDataType); |
|
81 NS_IMETHOD SetTitle(const nsAString& aTitle) |
|
82 { |
|
83 return NS_OK; |
|
84 } |
|
85 virtual nsIntPoint WidgetToScreenOffset(); |
|
86 NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent, |
|
87 nsEventStatus& aStatus); |
|
88 NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener, |
|
89 bool aDoCapture) |
|
90 { |
|
91 return NS_ERROR_NOT_IMPLEMENTED; |
|
92 } |
|
93 NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent); |
|
94 |
|
95 NS_IMETHOD MakeFullScreen(bool aFullScreen) /*MOZ_OVERRIDE*/; |
|
96 |
|
97 virtual float GetDPI(); |
|
98 virtual double GetDefaultScaleInternal(); |
|
99 virtual mozilla::layers::LayerManager* |
|
100 GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr, |
|
101 LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE, |
|
102 LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT, |
|
103 bool* aAllowRetaining = nullptr); |
|
104 gfxASurface* GetThebesSurface(); |
|
105 |
|
106 NS_IMETHOD_(void) SetInputContext(const InputContext& aContext, |
|
107 const InputContextAction& aAction); |
|
108 NS_IMETHOD_(InputContext) GetInputContext(); |
|
109 |
|
110 virtual uint32_t GetGLFrameBufferFormat() MOZ_OVERRIDE; |
|
111 |
|
112 virtual nsIntRect GetNaturalBounds() MOZ_OVERRIDE; |
|
113 virtual bool NeedsPaint(); |
|
114 |
|
115 virtual Composer2D* GetComposer2D() MOZ_OVERRIDE; |
|
116 |
|
117 protected: |
|
118 nsWindow* mParent; |
|
119 bool mVisible; |
|
120 InputContext mInputContext; |
|
121 nsCOMPtr<nsIIdleServiceInternal> mIdleService; |
|
122 |
|
123 void BringToTop(); |
|
124 |
|
125 // Call this function when the users activity is the direct cause of an |
|
126 // event (like a keypress or mouse click). |
|
127 void UserActivity(); |
|
128 }; |
|
129 |
|
130 #endif /* nsWindow_h */ |