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 nsWindow_h
|
|
|
|
#define nsWindow_h
|
|
|
|
|
2015-01-15 07:37:54 -08:00
|
|
|
#include "InputData.h"
|
2011-11-10 16:17:46 -08:00
|
|
|
#include "nsBaseWidget.h"
|
2013-08-19 03:15:55 -07:00
|
|
|
#include "nsRegion.h"
|
2012-06-29 01:32:21 -07:00
|
|
|
#include "nsIIdleServiceInternal.h"
|
2014-10-16 13:57:10 -07:00
|
|
|
#include "Units.h"
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2014-10-16 13:57:10 -07:00
|
|
|
class ANativeWindowBuffer;
|
|
|
|
|
2011-12-15 15:38:45 -08:00
|
|
|
namespace widget {
|
|
|
|
struct InputContext;
|
|
|
|
struct InputContextAction;
|
|
|
|
}
|
|
|
|
|
2015-04-29 20:17:57 -07:00
|
|
|
class nsScreenGonk;
|
|
|
|
|
2015-02-17 22:27:53 -08:00
|
|
|
class nsWindow : public nsBaseWidget
|
2011-11-10 16:17:46 -08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsWindow();
|
|
|
|
|
2015-02-09 10:50:51 -08:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
static void DoDraw(void);
|
2015-04-15 02:45:18 -07:00
|
|
|
static nsEventStatus DispatchKeyInput(mozilla::WidgetKeyboardEvent& aEvent);
|
2015-01-15 07:37:54 -08:00
|
|
|
static void DispatchTouchInput(mozilla::MultiTouchInput& aInput);
|
2011-11-10 16:17:46 -08:00
|
|
|
|
|
|
|
NS_IMETHOD Create(nsIWidget *aParent,
|
|
|
|
void *aNativeParent,
|
|
|
|
const nsIntRect &aRect,
|
|
|
|
nsWidgetInitData *aInitData);
|
|
|
|
NS_IMETHOD Destroy(void);
|
|
|
|
|
|
|
|
NS_IMETHOD Show(bool aState);
|
2012-07-19 01:57:50 -07:00
|
|
|
virtual bool IsVisible() const;
|
2011-11-10 16:17:46 -08:00
|
|
|
NS_IMETHOD ConstrainPosition(bool aAllowSlop,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t *aX,
|
|
|
|
int32_t *aY);
|
2012-12-12 01:57:38 -08:00
|
|
|
NS_IMETHOD Move(double aX,
|
|
|
|
double aY);
|
|
|
|
NS_IMETHOD Resize(double aWidth,
|
|
|
|
double aHeight,
|
2011-11-10 16:17:46 -08:00
|
|
|
bool aRepaint);
|
2012-12-12 01:57:38 -08:00
|
|
|
NS_IMETHOD Resize(double aX,
|
|
|
|
double aY,
|
|
|
|
double aWidth,
|
|
|
|
double aHeight,
|
2011-11-10 16:17:46 -08:00
|
|
|
bool aRepaint);
|
|
|
|
NS_IMETHOD Enable(bool aState);
|
2012-07-22 22:19:08 -07:00
|
|
|
virtual bool IsEnabled() const;
|
2011-11-10 16:17:46 -08:00
|
|
|
NS_IMETHOD SetFocus(bool aRaise = false);
|
|
|
|
NS_IMETHOD ConfigureChildren(const nsTArray<nsIWidget::Configuration>&);
|
2012-01-18 13:22:12 -08:00
|
|
|
NS_IMETHOD Invalidate(const nsIntRect &aRect);
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void* GetNativeData(uint32_t aDataType);
|
2015-04-17 09:28:41 -07:00
|
|
|
virtual void SetNativeData(uint32_t aDataType, uintptr_t aVal);
|
2011-11-10 16:17:46 -08:00
|
|
|
NS_IMETHOD SetTitle(const nsAString& aTitle)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2015-02-04 12:21:03 -08:00
|
|
|
virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset();
|
2015-01-15 07:37:54 -08:00
|
|
|
void DispatchTouchInputViaAPZ(mozilla::MultiTouchInput& aInput);
|
2015-02-10 05:24:23 -08:00
|
|
|
void DispatchTouchEventForAPZ(const mozilla::MultiTouchInput& aInput,
|
|
|
|
const ScrollableLayerGuid& aGuid,
|
2015-03-25 09:20:20 -07:00
|
|
|
const uint64_t aInputBlockId,
|
|
|
|
nsEventStatus aApzResponse);
|
2013-10-01 20:46:03 -07:00
|
|
|
NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus& aStatus);
|
2015-01-19 15:38:00 -08:00
|
|
|
virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
|
|
|
|
TouchPointerState aPointerState,
|
|
|
|
nsIntPoint aPointerScreenPoint,
|
|
|
|
double aPointerPressure,
|
2015-04-14 08:36:36 -07:00
|
|
|
uint32_t aPointerOrientation,
|
|
|
|
nsIObserver* aObserver) override;
|
2015-01-19 15:38:00 -08:00
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
|
2012-10-26 06:15:22 -07:00
|
|
|
bool aDoCapture)
|
2011-11-10 16:17:46 -08:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent);
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
NS_IMETHOD MakeFullScreen(bool aFullScreen, nsIScreen* aTargetScreen = nullptr) /*override*/;
|
2012-08-14 23:13:48 -07:00
|
|
|
|
2014-10-16 13:57:10 -07:00
|
|
|
virtual mozilla::TemporaryRef<mozilla::gfx::DrawTarget>
|
2015-03-21 09:28:04 -07:00
|
|
|
StartRemoteDrawing() override;
|
|
|
|
virtual void EndRemoteDrawing() override;
|
2014-10-16 13:57:10 -07:00
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
virtual float GetDPI();
|
2013-05-01 13:04:56 -07:00
|
|
|
virtual double GetDefaultScaleInternal();
|
2011-11-10 16:17:46 -08:00
|
|
|
virtual mozilla::layers::LayerManager*
|
2013-04-24 11:42:40 -07:00
|
|
|
GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr,
|
2014-01-23 10:26:41 -08:00
|
|
|
LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE,
|
2011-11-10 16:17:46 -08:00
|
|
|
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
|
2012-07-30 07:20:58 -07:00
|
|
|
bool* aAllowRetaining = nullptr);
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2011-12-15 15:38:45 -08:00
|
|
|
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
|
|
|
const InputContextAction& aAction);
|
|
|
|
NS_IMETHOD_(InputContext) GetInputContext();
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual uint32_t GetGLFrameBufferFormat() override;
|
2012-01-25 18:05:34 -08:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual nsIntRect GetNaturalBounds() override;
|
2012-08-13 19:41:09 -07:00
|
|
|
virtual bool NeedsPaint();
|
2012-07-24 12:01:09 -07:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual Composer2D* GetComposer2D() override;
|
2012-11-19 09:58:38 -08:00
|
|
|
|
2015-03-26 14:23:02 -07:00
|
|
|
void ConfigureAPZControllerThread() override;
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
protected:
|
|
|
|
nsWindow* mParent;
|
|
|
|
bool mVisible;
|
2011-12-29 15:01:51 -08:00
|
|
|
InputContext mInputContext;
|
2012-06-29 01:32:21 -07:00
|
|
|
nsCOMPtr<nsIIdleServiceInternal> mIdleService;
|
2014-10-16 13:57:10 -07:00
|
|
|
// If we're using a BasicCompositor, these fields are temporarily
|
|
|
|
// set during frame composition. They wrap the hardware
|
|
|
|
// framebuffer.
|
|
|
|
mozilla::RefPtr<mozilla::gfx::DrawTarget> mFramebufferTarget;
|
|
|
|
ANativeWindowBuffer* mFramebuffer;
|
2014-11-06 11:39:48 -08:00
|
|
|
// If we're using a BasicCompositor, this is our window back
|
|
|
|
// buffer. The gralloc framebuffer driver expects us to draw the
|
|
|
|
// entire framebuffer on every frame, but gecko expects the
|
|
|
|
// windowing system to be tracking buffer updates for invalidated
|
|
|
|
// regions. We get stuck holding that bag.
|
|
|
|
//
|
|
|
|
// Only accessed on the compositor thread, except during
|
|
|
|
// destruction.
|
|
|
|
mozilla::RefPtr<mozilla::gfx::DrawTarget> mBackBuffer;
|
2011-11-10 16:17:46 -08:00
|
|
|
|
2015-03-10 05:44:02 -07:00
|
|
|
virtual ~nsWindow();
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
void BringToTop();
|
2012-01-10 18:07:00 -08:00
|
|
|
|
|
|
|
// Call this function when the users activity is the direct cause of an
|
|
|
|
// event (like a keypress or mouse click).
|
|
|
|
void UserActivity();
|
2015-01-19 15:38:00 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
// This is used by SynthesizeNativeTouchPoint to maintain state between
|
|
|
|
// multiple synthesized points
|
|
|
|
nsAutoPtr<mozilla::MultiTouchInput> mSynthesizedTouchInput;
|
2015-04-29 20:17:57 -07:00
|
|
|
|
|
|
|
nsRefPtr<nsScreenGonk> mScreen;
|
2011-11-10 16:17:46 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsWindow_h */
|