2010-06-03 13:56:36 -07:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (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.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Android code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Mozilla Foundation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2010
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Vladimir Vukicevic <vladimir@pobox.com>
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#ifndef NSWINDOW_H_
|
|
|
|
#define NSWINDOW_H_
|
|
|
|
|
|
|
|
#include "nsBaseWidget.h"
|
|
|
|
#include "gfxPoint.h"
|
|
|
|
|
|
|
|
#include "nsTArray.h"
|
|
|
|
|
2011-11-14 19:12:14 -08:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "nsAccessible.h"
|
|
|
|
#endif
|
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
class gfxASurface;
|
|
|
|
class nsIdleService;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
class AndroidGeckoEvent;
|
|
|
|
class AndroidKeyEvent;
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2010-06-03 13:56:36 -07:00
|
|
|
|
|
|
|
nsWindow* FindWindowForPoint(const nsIntPoint& pt);
|
|
|
|
|
|
|
|
void OnAndroidEvent(mozilla::AndroidGeckoEvent *ae);
|
|
|
|
void OnDraw(mozilla::AndroidGeckoEvent *ae);
|
|
|
|
void OnMotionEvent(mozilla::AndroidGeckoEvent *ae);
|
2010-07-07 14:34:12 -07:00
|
|
|
void OnMultitouchEvent(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);
|
|
|
|
|
|
|
|
void InitEvent(nsGUIEvent& event, nsIntPoint* aPoint = 0);
|
|
|
|
|
|
|
|
//
|
|
|
|
// nsIWidget
|
|
|
|
//
|
|
|
|
|
|
|
|
NS_IMETHOD Create(nsIWidget *aParent,
|
|
|
|
nsNativeWidget aNativeParent,
|
|
|
|
const nsIntRect &aRect,
|
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
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();
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD Show(bool aState);
|
|
|
|
NS_IMETHOD SetModal(bool aModal);
|
|
|
|
NS_IMETHOD IsVisible(bool & aState);
|
|
|
|
NS_IMETHOD ConstrainPosition(bool aAllowSlop,
|
2010-06-03 13:56:36 -07:00
|
|
|
PRInt32 *aX,
|
|
|
|
PRInt32 *aY);
|
|
|
|
NS_IMETHOD Move(PRInt32 aX,
|
|
|
|
PRInt32 aY);
|
|
|
|
NS_IMETHOD Resize(PRInt32 aWidth,
|
|
|
|
PRInt32 aHeight,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aRepaint);
|
2010-06-03 13:56:36 -07:00
|
|
|
NS_IMETHOD Resize(PRInt32 aX,
|
|
|
|
PRInt32 aY,
|
|
|
|
PRInt32 aWidth,
|
|
|
|
PRInt32 aHeight,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aRepaint);
|
2010-06-03 13:56:36 -07:00
|
|
|
NS_IMETHOD SetZIndex(PRInt32 aZIndex);
|
|
|
|
NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
|
|
|
|
nsIWidget *aWidget,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aActivate);
|
2010-06-03 13:56:36 -07:00
|
|
|
NS_IMETHOD SetSizeMode(PRInt32 aMode);
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD Enable(bool aState);
|
|
|
|
NS_IMETHOD IsEnabled(bool *aState);
|
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();
|
|
|
|
NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, nsEventStatus &aStatus);
|
|
|
|
nsEventStatus DispatchEvent(nsGUIEvent *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 SetForegroundColor(const nscolor &aColor) { return NS_ERROR_NOT_IMPLEMENTED; }
|
|
|
|
NS_IMETHOD SetBackgroundColor(const nscolor &aColor) { return NS_ERROR_NOT_IMPLEMENTED; }
|
|
|
|
NS_IMETHOD SetCursor(nsCursor aCursor) { return NS_ERROR_NOT_IMPLEMENTED; }
|
|
|
|
NS_IMETHOD SetCursor(imgIContainer* aCursor,
|
|
|
|
PRUint32 aHotspotX,
|
|
|
|
PRUint32 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; }
|
2010-06-03 13:56:36 -07:00
|
|
|
virtual void* GetNativeData(PRUint32 aDataType);
|
|
|
|
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,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aDoCapture,
|
|
|
|
bool aConsumeRollupEvent) { return NS_ERROR_NOT_IMPLEMENTED; }
|
2010-06-03 13:56:36 -07:00
|
|
|
|
|
|
|
NS_IMETHOD GetAttention(PRInt32 aCycleCount) { return NS_ERROR_NOT_IMPLEMENTED; }
|
|
|
|
NS_IMETHOD BeginResizeDrag(nsGUIEvent* aEvent, PRInt32 aHorizontal, PRInt32 aVertical) { return NS_ERROR_NOT_IMPLEMENTED; }
|
|
|
|
|
2010-08-04 12:47:26 -07:00
|
|
|
NS_IMETHOD ResetInputState();
|
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
|
|
|
NS_IMETHOD CancelIMEComposition();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD OnIMEFocusChange(bool aFocus);
|
2010-08-04 12:47:26 -07:00
|
|
|
NS_IMETHOD OnIMETextChange(PRUint32 aStart, PRUint32 aOldEnd, PRUint32 aNewEnd);
|
|
|
|
NS_IMETHOD OnIMESelectionChange(void);
|
2010-09-23 20:28:15 -07:00
|
|
|
virtual nsIMEUpdatePreference GetIMEUpdatePreference();
|
2010-06-03 13:56:36 -07:00
|
|
|
|
2011-08-12 07:12:03 -07:00
|
|
|
LayerManager* GetLayerManager (PLayersChild* aShadowManager = nsnull,
|
|
|
|
LayersBackend aBackendHint = LayerManager::LAYERS_NONE,
|
|
|
|
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
|
|
|
|
bool* aAllowRetaining = nsnull);
|
2010-06-03 13:56:36 -07:00
|
|
|
gfxASurface* GetThebesSurface();
|
|
|
|
|
2010-09-18 04:28:50 -07:00
|
|
|
NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent);
|
2011-11-14 19:12:14 -08:00
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
static bool sAccessibilityEnabled;
|
|
|
|
#endif
|
|
|
|
|
2011-12-21 11:05:23 -08:00
|
|
|
#ifdef MOZ_JAVA_COMPOSITOR
|
|
|
|
static void BindToTexture();
|
|
|
|
static bool HasDirectTexture();
|
|
|
|
#endif
|
|
|
|
|
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();
|
2010-08-04 12:47:26 -07:00
|
|
|
void OnIMEAddRange(mozilla::AndroidGeckoEvent *ae);
|
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
|
|
|
|
|
|
|
bool mGestureFinished;
|
2010-07-07 14:34:12 -07:00
|
|
|
double mStartDist;
|
2010-08-25 22:52:08 -07:00
|
|
|
double mLastDist;
|
|
|
|
nsAutoPtr<nsIntPoint> mStartPoint;
|
|
|
|
|
2010-11-18 09:18:31 -08:00
|
|
|
// Multitouch swipe thresholds in screen pixels
|
|
|
|
double mSwipeMaxPinchDelta;
|
|
|
|
double mSwipeMinDistance;
|
|
|
|
|
2010-06-03 13:56:36 -07:00
|
|
|
nsCOMPtr<nsIdleService> mIdleService;
|
2010-08-25 22:52:08 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIMEComposing;
|
2010-08-20 17:07:26 -07:00
|
|
|
nsString mIMEComposingText;
|
2011-09-22 02:17:40 -07:00
|
|
|
nsString mIMELastDispatchedComposingText;
|
2010-08-04 12:47:26 -07:00
|
|
|
nsAutoTArray<nsTextRange, 4> mIMERanges;
|
2010-06-03 13:56:36 -07: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:
|
|
|
|
void InitKeyEvent(nsKeyEvent& event, mozilla::AndroidGeckoEvent& key);
|
2010-08-25 22:52:08 -07:00
|
|
|
void DispatchGestureEvent(mozilla::AndroidGeckoEvent *ae);
|
|
|
|
void DispatchGestureEvent(PRUint32 msg, PRUint32 direction, double delta,
|
|
|
|
const nsIntPoint &refPoint, PRUint64 time);
|
2010-06-03 13:56:36 -07:00
|
|
|
void HandleSpecialKey(mozilla::AndroidGeckoEvent *ae);
|
2011-11-14 19:12:14 -08:00
|
|
|
void RedrawAll();
|
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
nsRefPtr<nsAccessible> mRootAccessible;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request to create the accessible for this window if it is top level.
|
|
|
|
*/
|
|
|
|
void CreateRootAccessible();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate the NS_GETACCESSIBLE event to get accessible for this window
|
|
|
|
* and return it.
|
|
|
|
*/
|
|
|
|
nsAccessible *DispatchAccessibleEvent();
|
|
|
|
#endif // ACCESSIBILITY
|
2010-06-03 13:56:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* NSWINDOW_H_ */
|