2010-06-03 13:56:36 -07:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-06-03 13:56:36 -07:00
|
|
|
|
|
|
|
#ifndef NSWINDOW_H_
|
|
|
|
#define NSWINDOW_H_
|
|
|
|
|
|
|
|
#include "nsBaseWidget.h"
|
|
|
|
#include "gfxPoint.h"
|
2012-06-29 01:32:21 -07:00
|
|
|
#include "nsIIdleServiceInternal.h"
|
2010-06-03 13:56:36 -07:00
|
|
|
#include "nsTArray.h"
|
2012-02-09 23:55:13 -08:00
|
|
|
#include "AndroidJavaWrappers.h"
|
2013-11-12 10:41:01 -08:00
|
|
|
#include "GeneratedJNIWrappers.h"
|
2013-10-22 06:27:36 -07:00
|
|
|
#include "mozilla/EventForwards.h"
|
2013-08-13 06:32:03 -07:00
|
|
|
#include "mozilla/StaticPtr.h"
|
2013-10-22 06:27:36 -07:00
|
|
|
#include "mozilla/TextRange.h"
|
2012-02-09 23:55:13 -08:00
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
class gfxASurface;
|
|
|
|
|
2012-04-19 10:49:31 -07:00
|
|
|
struct ANPEvent;
|
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
namespace mozilla {
|
|
|
|
class AndroidGeckoEvent;
|
2012-03-13 21:15:11 -07:00
|
|
|
|
|
|
|
namespace layers {
|
|
|
|
class CompositorParent;
|
2012-03-28 15:00:32 -07:00
|
|
|
class CompositorChild;
|
2012-07-30 17:42:26 -07:00
|
|
|
class LayerManager;
|
2013-07-30 11:03:40 -07:00
|
|
|
class APZCTreeManager;
|
2012-03-13 21:15:11 -07:00
|
|
|
}
|
2010-06-03 13:56:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
class nsWindow :
|
|
|
|
public nsBaseWidget
|
|
|
|
{
|
|
|
|
public:
|
2010-12-06 18:05:52 -08:00
|
|
|
using nsBaseWidget::GetLayerManager;
|
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
nsWindow();
|
|
|
|
virtual ~nsWindow();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
static void OnGlobalAndroidEvent(mozilla::AndroidGeckoEvent *ae);
|
2011-01-14 12:36:19 -08:00
|
|
|
static gfxIntSize GetAndroidScreenBounds();
|
2012-04-20 09:49:50 -07:00
|
|
|
static nsWindow* TopWindow();
|
2010-06-03 13:56:36 -07:00
|
|
|
|
|
|
|
nsWindow* FindWindowForPoint(const nsIntPoint& pt);
|
|
|
|
|
2012-01-24 16:31:33 -08:00
|
|
|
bool OnMultitouchEvent(mozilla::AndroidGeckoEvent *ae);
|
2012-10-02 13:18:21 -07:00
|
|
|
void OnNativeGestureEvent(mozilla::AndroidGeckoEvent *ae);
|
2012-06-15 15:34:22 -07:00
|
|
|
void OnMouseEvent(mozilla::AndroidGeckoEvent *ae);
|
2010-06-03 13:56:36 -07:00
|
|
|
void OnKeyEvent(mozilla::AndroidGeckoEvent *ae);
|
|
|
|
void OnIMEEvent(mozilla::AndroidGeckoEvent *ae);
|
|
|
|
|
|
|
|
void OnSizeChanged(const gfxIntSize& aSize);
|
|
|
|
|
2013-10-01 20:46:03 -07:00
|
|
|
void InitEvent(mozilla::WidgetGUIEvent& event, nsIntPoint* aPoint = 0);
|
2010-06-03 13:56:36 -07:00
|
|
|
|
|
|
|
//
|
|
|
|
// nsIWidget
|
|
|
|
//
|
|
|
|
|
|
|
|
NS_IMETHOD Create(nsIWidget *aParent,
|
|
|
|
nsNativeWidget aNativeParent,
|
|
|
|
const nsIntRect &aRect,
|
2011-04-16 18:22:44 -07:00
|
|
|
nsDeviceContext *aContext,
|
2010-06-03 13:56:36 -07:00
|
|
|
nsWidgetInitData *aInitData);
|
|
|
|
NS_IMETHOD Destroy(void);
|
|
|
|
NS_IMETHOD ConfigureChildren(const nsTArray<nsIWidget::Configuration>&);
|
|
|
|
NS_IMETHOD SetParent(nsIWidget* aNewParent);
|
|
|
|
virtual nsIWidget *GetParent(void);
|
2010-10-07 10:28:27 -07:00
|
|
|
virtual float GetDPI();
|
2013-07-04 06:02:29 -07:00
|
|
|
virtual double GetDefaultScaleInternal();
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD Show(bool aState);
|
|
|
|
NS_IMETHOD SetModal(bool aModal);
|
2012-07-19 01:57:50 -07:00
|
|
|
virtual bool IsVisible() const;
|
2011-09-28 23:19:26 -07: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,
|
|
|
|
bool aRepaint);
|
|
|
|
NS_IMETHOD Resize(double aX,
|
|
|
|
double aY,
|
|
|
|
double aWidth,
|
|
|
|
double aHeight,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aRepaint);
|
2014-03-19 09:48:08 -07:00
|
|
|
void SetZIndex(int32_t aZIndex);
|
2010-06-03 13:56:36 -07:00
|
|
|
NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
|
|
|
|
nsIWidget *aWidget,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aActivate);
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD SetSizeMode(int32_t aMode);
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD Enable(bool aState);
|
2012-07-22 22:19:08 -07:00
|
|
|
virtual bool IsEnabled() const;
|
2011-12-23 19:52:21 -08:00
|
|
|
NS_IMETHOD Invalidate(const nsIntRect &aRect);
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD SetFocus(bool aRaise = false);
|
2010-06-03 13:56:36 -07:00
|
|
|
NS_IMETHOD GetScreenBounds(nsIntRect &aRect);
|
|
|
|
virtual nsIntPoint WidgetToScreenOffset();
|
2013-10-01 20:46:03 -07:00
|
|
|
NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus& aStatus);
|
|
|
|
nsEventStatus DispatchEvent(mozilla::WidgetGUIEvent* aEvent);
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD MakeFullScreen(bool aFullScreen);
|
2010-06-03 13:56:36 -07:00
|
|
|
NS_IMETHOD SetWindowClass(const nsAString& xulWinType);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHOD SetCursor(nsCursor aCursor) { return NS_ERROR_NOT_IMPLEMENTED; }
|
|
|
|
NS_IMETHOD SetCursor(imgIContainer* aCursor,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aHotspotX,
|
|
|
|
uint32_t aHotspotY) { return NS_ERROR_NOT_IMPLEMENTED; }
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD SetHasTransparentBackground(bool aTransparent) { return NS_OK; }
|
|
|
|
NS_IMETHOD GetHasTransparentBackground(bool& aTransparent) { aTransparent = false; return NS_OK; }
|
|
|
|
NS_IMETHOD HideWindowChrome(bool aShouldHide) { return NS_ERROR_NOT_IMPLEMENTED; }
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void* GetNativeData(uint32_t aDataType);
|
2010-06-03 13:56:36 -07:00
|
|
|
NS_IMETHOD SetTitle(const nsAString& aTitle) { return NS_OK; }
|
|
|
|
NS_IMETHOD SetIcon(const nsAString& aIconSpec) { return NS_OK; }
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD EnableDragDrop(bool aEnable) { return NS_OK; }
|
|
|
|
NS_IMETHOD CaptureMouse(bool aCapture) { return NS_ERROR_NOT_IMPLEMENTED; }
|
2010-06-03 13:56:36 -07:00
|
|
|
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
|
2012-10-26 06:15:22 -07:00
|
|
|
bool aDoCapture) { return NS_ERROR_NOT_IMPLEMENTED; }
|
2010-06-03 13:56:36 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD GetAttention(int32_t aCycleCount) { return NS_ERROR_NOT_IMPLEMENTED; }
|
2013-10-01 20:46:03 -07:00
|
|
|
NS_IMETHOD BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
int32_t aHorizontal,
|
|
|
|
int32_t aVertical)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2010-06-03 13:56:36 -07:00
|
|
|
|
2014-02-17 16:00:15 -08:00
|
|
|
NS_IMETHOD NotifyIME(const IMENotification& aIMENotification) MOZ_OVERRIDE;
|
2011-11-27 03:51:52 -08:00
|
|
|
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
|
|
|
const InputContextAction& aAction);
|
|
|
|
NS_IMETHOD_(InputContext) GetInputContext();
|
2010-08-04 12:47:26 -07:00
|
|
|
|
2014-02-17 16:00:15 -08:00
|
|
|
nsresult NotifyIMEOfTextChange(const IMENotification& aIMENotification);
|
2010-09-23 20:28:15 -07:00
|
|
|
virtual nsIMEUpdatePreference GetIMEUpdatePreference();
|
2010-06-03 13:56:36 -07:00
|
|
|
|
2013-04-24 11:42:40 -07:00
|
|
|
LayerManager* GetLayerManager (PLayerTransactionChild* aShadowManager = nullptr,
|
2014-01-23 10:26:41 -08:00
|
|
|
LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE,
|
2012-07-18 09:31:40 -07:00
|
|
|
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
|
2012-07-30 07:20:58 -07:00
|
|
|
bool* aAllowRetaining = nullptr);
|
2010-06-03 13:56:36 -07:00
|
|
|
|
2010-09-18 04:28:50 -07:00
|
|
|
NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent);
|
2011-11-14 19:12:14 -08:00
|
|
|
|
2012-08-13 03:10:10 -07:00
|
|
|
virtual bool NeedsPaint();
|
2013-12-08 17:40:59 -08:00
|
|
|
virtual void DrawWindowUnderlay(LayerManagerComposite* aManager, nsIntRect aRect);
|
|
|
|
virtual void DrawWindowOverlay(LayerManagerComposite* aManager, nsIntRect aRect);
|
2012-03-13 21:15:11 -07:00
|
|
|
|
2013-04-17 14:39:13 -07:00
|
|
|
virtual mozilla::layers::CompositorParent* NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight) MOZ_OVERRIDE;
|
|
|
|
|
2013-01-10 08:21:10 -08:00
|
|
|
static void SetCompositor(mozilla::layers::LayerManager* aLayerManager,
|
|
|
|
mozilla::layers::CompositorParent* aCompositorParent,
|
2012-07-13 08:25:29 -07:00
|
|
|
mozilla::layers::CompositorChild* aCompositorChild);
|
2012-03-13 21:15:11 -07:00
|
|
|
static void ScheduleComposite();
|
2012-04-20 08:46:30 -07:00
|
|
|
static void ScheduleResumeComposition(int width, int height);
|
2013-02-04 12:13:17 -08:00
|
|
|
static void ForceIsFirstPaint();
|
2012-10-25 09:23:47 -07:00
|
|
|
static float ComputeRenderIntegrity();
|
2013-07-30 11:03:43 -07:00
|
|
|
static mozilla::layers::APZCTreeManager* GetAPZCTreeManager();
|
|
|
|
/* RootLayerTreeId() can only be called when GetAPZCTreeManager() returns non-null */
|
|
|
|
static uint64_t RootLayerTreeId();
|
2012-04-16 23:04:05 -07:00
|
|
|
|
2012-08-28 22:48:43 -07:00
|
|
|
virtual bool WidgetPaintsBackground();
|
2011-12-21 11:05:23 -08:00
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
protected:
|
|
|
|
void BringToFront();
|
|
|
|
nsWindow *FindTopLevel();
|
2011-09-28 23:19:26 -07:00
|
|
|
bool DrawTo(gfxASurface *targetSurface);
|
2011-11-14 19:12:14 -08:00
|
|
|
bool DrawTo(gfxASurface *targetSurface, const nsIntRect &aRect);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsTopLevel();
|
2012-11-01 13:11:02 -07:00
|
|
|
void RemoveIMEComposition();
|
2012-12-05 08:09:56 -08:00
|
|
|
void PostFlushIMEChanges();
|
|
|
|
void FlushIMEChanges();
|
2010-06-03 13:56:36 -07:00
|
|
|
|
|
|
|
// Call this function when the users activity is the direct cause of an
|
|
|
|
// event (like a keypress or mouse click).
|
|
|
|
void UserActivity();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsVisible;
|
2010-06-03 13:56:36 -07:00
|
|
|
nsTArray<nsWindow*> mChildren;
|
|
|
|
nsWindow* mParent;
|
2011-02-14 17:01:01 -08:00
|
|
|
nsWindow* mFocus;
|
2010-08-25 22:52:08 -07:00
|
|
|
|
2010-07-07 14:34:12 -07:00
|
|
|
double mStartDist;
|
2010-08-25 22:52:08 -07:00
|
|
|
double mLastDist;
|
2010-11-18 09:18:31 -08:00
|
|
|
|
2012-06-29 01:32:21 -07:00
|
|
|
nsCOMPtr<nsIIdleServiceInternal> mIdleService;
|
2010-08-25 22:52:08 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIMEComposing;
|
2012-11-01 13:11:02 -07:00
|
|
|
bool mIMEMaskSelectionUpdate, mIMEMaskTextUpdate;
|
2012-11-16 08:41:54 -08:00
|
|
|
int32_t mIMEMaskEventsCount; // Mask events when > 0
|
2010-08-20 17:07:26 -07:00
|
|
|
nsString mIMEComposingText;
|
2014-03-04 05:48:28 -08:00
|
|
|
nsRefPtr<mozilla::TextRangeArray> mIMERanges;
|
2013-03-05 07:24:35 -08:00
|
|
|
bool mIMEUpdatingContext;
|
2013-03-29 07:54:01 -07:00
|
|
|
nsAutoTArray<mozilla::AndroidGeckoEvent, 8> mIMEKeyEvents;
|
2010-06-03 13:56:36 -07:00
|
|
|
|
2012-12-05 08:09:56 -08:00
|
|
|
struct IMEChange {
|
|
|
|
int32_t mStart, mOldEnd, mNewEnd;
|
|
|
|
|
|
|
|
IMEChange() :
|
|
|
|
mStart(-1), mOldEnd(-1), mNewEnd(-1)
|
|
|
|
{
|
|
|
|
}
|
2014-02-17 16:00:15 -08:00
|
|
|
IMEChange(const IMENotification& aIMENotification)
|
|
|
|
: mStart(aIMENotification.mTextChangeData.mStartOffset)
|
|
|
|
, mOldEnd(aIMENotification.mTextChangeData.mOldEndOffset)
|
|
|
|
, mNewEnd(aIMENotification.mTextChangeData.mNewEndOffset)
|
2012-12-05 08:09:56 -08:00
|
|
|
{
|
2014-02-17 16:00:15 -08:00
|
|
|
MOZ_ASSERT(aIMENotification.mMessage ==
|
|
|
|
mozilla::widget::NOTIFY_IME_OF_TEXT_CHANGE,
|
|
|
|
"IMEChange initialized with wrong notification");
|
|
|
|
MOZ_ASSERT(aIMENotification.mTextChangeData.IsInInt32Range(),
|
|
|
|
"The text change notification is out of range");
|
2012-12-05 08:09:56 -08:00
|
|
|
}
|
|
|
|
bool IsEmpty()
|
|
|
|
{
|
|
|
|
return mStart < 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
nsAutoTArray<IMEChange, 4> mIMETextChanges;
|
2013-01-09 08:57:48 -08:00
|
|
|
bool mIMESelectionChanged;
|
2012-12-05 08:09:56 -08:00
|
|
|
|
2011-11-27 03:51:52 -08:00
|
|
|
InputContext mInputContext;
|
2010-11-22 22:48:45 -08:00
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
static void DumpWindows();
|
|
|
|
static void DumpWindows(const nsTArray<nsWindow*>& wins, int indent = 0);
|
|
|
|
static void LogWindow(nsWindow *win, int index, int indent);
|
|
|
|
|
|
|
|
private:
|
2013-10-01 00:22:58 -07:00
|
|
|
void InitKeyEvent(mozilla::WidgetKeyboardEvent& event,
|
|
|
|
mozilla::AndroidGeckoEvent& key,
|
2012-04-19 10:49:31 -07:00
|
|
|
ANPEvent* pluginEvent);
|
2013-10-01 00:23:02 -07:00
|
|
|
void DispatchMotionEvent(mozilla::WidgetInputEvent &event,
|
2012-01-24 16:31:33 -08:00
|
|
|
mozilla::AndroidGeckoEvent *ae,
|
|
|
|
const nsIntPoint &refPoint);
|
2012-08-22 08:56:38 -07:00
|
|
|
void DispatchGestureEvent(uint32_t msg, uint32_t direction, double delta,
|
|
|
|
const nsIntPoint &refPoint, uint64_t time);
|
2010-06-03 13:56:36 -07:00
|
|
|
void HandleSpecialKey(mozilla::AndroidGeckoEvent *ae);
|
2013-03-20 15:45:07 -07:00
|
|
|
void CreateLayerManager(int aCompositorWidth, int aCompositorHeight);
|
2011-11-14 19:12:14 -08:00
|
|
|
void RedrawAll();
|
|
|
|
|
2013-11-19 07:56:09 -08:00
|
|
|
mozilla::AndroidLayerRendererFrame mLayerRendererFrame;
|
2012-03-13 21:15:11 -07:00
|
|
|
|
2013-08-13 06:32:03 -07:00
|
|
|
static mozilla::StaticRefPtr<mozilla::layers::APZCTreeManager> sApzcTreeManager;
|
|
|
|
static mozilla::StaticRefPtr<mozilla::layers::LayerManager> sLayerManager;
|
|
|
|
static mozilla::StaticRefPtr<mozilla::layers::CompositorParent> sCompositorParent;
|
|
|
|
static mozilla::StaticRefPtr<mozilla::layers::CompositorChild> sCompositorChild;
|
2012-03-28 15:00:32 -07:00
|
|
|
static bool sCompositorPaused;
|
2012-02-09 23:55:13 -08:00
|
|
|
};
|
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
#endif /* NSWINDOW_H_ */
|