2008-04-19 08:37:51 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim:expandtab:shiftwidth=4:tabstop=4:
|
|
|
|
*/
|
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/. */
|
2008-04-19 08:37:51 -07:00
|
|
|
|
|
|
|
#ifndef __nsWindow_h__
|
|
|
|
#define __nsWindow_h__
|
|
|
|
|
2010-03-04 13:51:42 -08:00
|
|
|
#include <QKeyEvent>
|
2012-03-22 16:24:40 -07:00
|
|
|
#include <QGestureEvent>
|
2010-03-04 13:51:42 -08:00
|
|
|
#include <qgraphicswidget.h>
|
2010-10-08 23:08:42 -07:00
|
|
|
#include <QTime>
|
2010-03-04 13:51:42 -08:00
|
|
|
|
2008-04-19 08:37:51 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2008-04-19 08:31:50 -07:00
|
|
|
|
2008-04-22 04:21:17 -07:00
|
|
|
#include "nsBaseWidget.h"
|
|
|
|
#include "nsGUIEvent.h"
|
2008-04-19 08:37:51 -07:00
|
|
|
|
2008-04-19 08:31:50 -07:00
|
|
|
#include "nsWeakReference.h"
|
|
|
|
|
2011-10-14 11:11:22 -07:00
|
|
|
#include "nsGkAtoms.h"
|
2012-06-29 01:32:21 -07:00
|
|
|
#include "nsIIdleServiceInternal.h"
|
2012-07-30 17:42:26 -07:00
|
|
|
#include "nsIRunnable.h"
|
|
|
|
#include "nsThreadUtils.h"
|
2008-04-19 08:37:51 -07:00
|
|
|
|
2008-04-22 04:21:17 -07:00
|
|
|
#ifdef MOZ_LOGGING
|
|
|
|
|
|
|
|
// make sure that logging is enabled before including prlog.h
|
|
|
|
#define FORCE_PR_LOG
|
|
|
|
|
|
|
|
#include "prlog.h"
|
2009-01-21 20:15:34 -08:00
|
|
|
#include "nsTArray.h"
|
2008-04-22 04:21:17 -07:00
|
|
|
|
|
|
|
extern PRLogModuleInfo *gWidgetLog;
|
|
|
|
extern PRLogModuleInfo *gWidgetFocusLog;
|
|
|
|
extern PRLogModuleInfo *gWidgetIMLog;
|
|
|
|
extern PRLogModuleInfo *gWidgetDrawLog;
|
|
|
|
|
|
|
|
#define LOG(args) PR_LOG(gWidgetLog, 4, args)
|
|
|
|
#define LOGFOCUS(args) PR_LOG(gWidgetFocusLog, 4, args)
|
|
|
|
#define LOGIM(args) PR_LOG(gWidgetIMLog, 4, args)
|
|
|
|
#define LOGDRAW(args) PR_LOG(gWidgetDrawLog, 4, args)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#ifdef DEBUG_WIDGETS
|
|
|
|
|
|
|
|
#define PR_LOG2(_args) \
|
|
|
|
PR_BEGIN_MACRO \
|
|
|
|
qDebug _args; \
|
|
|
|
PR_END_MACRO
|
|
|
|
|
|
|
|
#define LOG(args) PR_LOG2(args)
|
|
|
|
#define LOGFOCUS(args) PR_LOG2(args)
|
|
|
|
#define LOGIM(args) PR_LOG2(args)
|
|
|
|
#define LOGDRAW(args) PR_LOG2(args)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define LOG(args)
|
|
|
|
#define LOGFOCUS(args)
|
|
|
|
#define LOGIM(args)
|
|
|
|
#define LOGDRAW(args)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* MOZ_LOGGING */
|
|
|
|
|
2008-04-19 08:37:55 -07:00
|
|
|
class QEvent;
|
2010-06-24 03:07:57 -07:00
|
|
|
class QGraphicsView;
|
2008-04-19 08:37:55 -07:00
|
|
|
|
2008-04-20 01:16:40 -07:00
|
|
|
class MozQWidget;
|
|
|
|
|
2010-04-16 10:37:16 -07:00
|
|
|
class nsIdleService;
|
|
|
|
|
2008-04-22 04:21:17 -07:00
|
|
|
class nsWindow : public nsBaseWidget,
|
|
|
|
public nsSupportsWeakReference
|
2008-04-19 08:31:50 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsWindow();
|
|
|
|
virtual ~nsWindow();
|
|
|
|
|
2012-08-15 11:52:42 -07:00
|
|
|
bool DoPaint( QPainter* aPainter, const QStyleOptionGraphicsItem * aOption, QWidget* aWidget);
|
2010-02-16 10:14:20 -08:00
|
|
|
|
2008-04-19 08:37:51 -07:00
|
|
|
static void ReleaseGlobals();
|
2008-04-19 08:31:50 -07:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2008-04-22 04:21:17 -07:00
|
|
|
//
|
2008-04-19 08:37:51 -07:00
|
|
|
// nsIWidget
|
2008-04-22 04:21:17 -07:00
|
|
|
//
|
|
|
|
|
2009-08-04 19:39:05 -07:00
|
|
|
NS_IMETHOD ConfigureChildren(const nsTArray<nsIWidget::Configuration>&);
|
|
|
|
|
2008-04-19 08:37:51 -07:00
|
|
|
NS_IMETHOD Create(nsIWidget *aParent,
|
2009-09-23 23:18:10 -07:00
|
|
|
nsNativeWidget aNativeParent,
|
|
|
|
const nsIntRect &aRect,
|
2011-04-16 18:22:44 -07:00
|
|
|
nsDeviceContext *aContext,
|
2008-04-19 08:37:51 -07:00
|
|
|
nsWidgetInitData *aInitData);
|
2010-08-31 09:35:57 -07:00
|
|
|
|
|
|
|
virtual already_AddRefed<nsIWidget>
|
|
|
|
CreateChild(const nsIntRect& aRect,
|
2011-04-16 18:22:44 -07:00
|
|
|
nsDeviceContext* aContext,
|
2012-07-30 07:20:58 -07:00
|
|
|
nsWidgetInitData* aInitData = nullptr,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aForceUseIWidgetParent = true);
|
2010-08-31 09:35:57 -07:00
|
|
|
|
2008-04-19 08:37:51 -07:00
|
|
|
NS_IMETHOD Destroy(void);
|
|
|
|
NS_IMETHOD SetParent(nsIWidget* aNewParent);
|
2008-04-22 04:21:17 -07:00
|
|
|
virtual nsIWidget *GetParent(void);
|
2010-08-13 02:57:55 -07:00
|
|
|
virtual float GetDPI();
|
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,
|
|
|
|
bool aRepaint);
|
2008-04-19 08:37:51 -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);
|
|
|
|
NS_IMETHOD SetFocus(bool aRaise = false);
|
2009-02-11 05:51:06 -08:00
|
|
|
NS_IMETHOD GetScreenBounds(nsIntRect &aRect);
|
2008-04-19 08:37:51 -07:00
|
|
|
NS_IMETHOD SetForegroundColor(const nscolor &aColor);
|
|
|
|
NS_IMETHOD SetBackgroundColor(const nscolor &aColor);
|
|
|
|
NS_IMETHOD SetCursor(nsCursor aCursor);
|
|
|
|
NS_IMETHOD SetCursor(imgIContainer* aCursor,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aHotspotX, uint32_t aHotspotY);
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD SetHasTransparentBackground(bool aTransparent);
|
|
|
|
NS_IMETHOD GetHasTransparentBackground(bool& aTransparent);
|
|
|
|
NS_IMETHOD HideWindowChrome(bool aShouldHide);
|
|
|
|
NS_IMETHOD MakeFullScreen(bool aFullScreen);
|
2011-12-23 19:52:21 -08:00
|
|
|
NS_IMETHOD Invalidate(const nsIntRect &aRect);
|
2008-04-22 04:21:17 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void* GetNativeData(uint32_t aDataType);
|
2008-04-19 08:37:51 -07:00
|
|
|
NS_IMETHOD SetTitle(const nsAString& aTitle);
|
|
|
|
NS_IMETHOD SetIcon(const nsAString& aIconSpec);
|
2009-02-18 16:11:49 -08:00
|
|
|
virtual nsIntPoint WidgetToScreenOffset();
|
2008-04-22 04:21:17 -07:00
|
|
|
NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, nsEventStatus &aStatus);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD EnableDragDrop(bool aEnable);
|
|
|
|
NS_IMETHOD CaptureMouse(bool aCapture);
|
2008-04-19 08:37:51 -07:00
|
|
|
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
|
2012-10-26 06:15:22 -07:00
|
|
|
bool aDoCapture);
|
2008-04-22 04:21:17 -07:00
|
|
|
|
|
|
|
NS_IMETHOD SetWindowClass(const nsAString& xulWinType);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD GetAttention(int32_t aCycleCount);
|
|
|
|
NS_IMETHOD BeginResizeDrag (nsGUIEvent* aEvent, int32_t aHorizontal, int32_t aVertical);
|
2008-04-19 08:31:50 -07:00
|
|
|
|
2011-11-27 03:51:52 -08:00
|
|
|
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
|
|
|
const InputContextAction& aAction);
|
|
|
|
NS_IMETHOD_(InputContext) GetInputContext();
|
2012-04-11 21:18:35 -07:00
|
|
|
NS_IMETHOD_(bool) HasGLContext();
|
2010-03-12 14:07:32 -08:00
|
|
|
|
2008-04-22 04:21:17 -07:00
|
|
|
//
|
2008-04-19 08:37:51 -07:00
|
|
|
// utility methods
|
2008-04-22 04:21:17 -07:00
|
|
|
//
|
2009-03-27 04:35:27 -07:00
|
|
|
void QWidgetDestroyed();
|
|
|
|
|
2008-04-22 04:21:17 -07:00
|
|
|
/***** from CommonWidget *****/
|
|
|
|
|
|
|
|
// event handling code
|
|
|
|
|
|
|
|
void DispatchActivateEvent(void);
|
|
|
|
void DispatchDeactivateEvent(void);
|
2010-07-28 18:05:56 -07:00
|
|
|
void DispatchActivateEventOnTopLevelWindow(void);
|
|
|
|
void DispatchDeactivateEventOnTopLevelWindow(void);
|
2009-02-11 05:51:06 -08:00
|
|
|
void DispatchResizeEvent(nsIntRect &aRect, nsEventStatus &aStatus);
|
2008-04-22 04:21:17 -07:00
|
|
|
|
|
|
|
nsEventStatus DispatchEvent(nsGUIEvent *aEvent) {
|
|
|
|
nsEventStatus status;
|
|
|
|
DispatchEvent(aEvent, status);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Some of the nsIWidget methods
|
2012-07-22 22:19:08 -07:00
|
|
|
virtual bool IsEnabled() const;
|
2008-04-22 04:21:17 -07:00
|
|
|
|
|
|
|
// called when we are destroyed
|
|
|
|
void OnDestroy(void);
|
|
|
|
|
|
|
|
// called to check and see if a widget's dimensions are sane
|
2011-09-28 23:19:26 -07:00
|
|
|
bool AreBoundsSane(void);
|
2008-04-22 04:21:17 -07:00
|
|
|
|
2010-09-18 04:28:50 -07:00
|
|
|
NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent);
|
2011-01-19 22:27:47 -08:00
|
|
|
|
|
|
|
QWidget* GetViewWidget();
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t GetGLFrameBufferFormat() MOZ_OVERRIDE;
|
2011-01-19 22:27:47 -08:00
|
|
|
|
2008-04-19 08:31:50 -07:00
|
|
|
protected:
|
2008-04-22 04:21:17 -07:00
|
|
|
nsCOMPtr<nsIWidget> mParent;
|
|
|
|
// Is this a toplevel window?
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsTopLevel;
|
2008-04-22 04:21:17 -07:00
|
|
|
// Has this widget been destroyed yet?
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsDestroyed;
|
2008-04-22 04:21:17 -07:00
|
|
|
|
|
|
|
// This flag tracks if we're hidden or shown.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsShown;
|
2008-04-22 04:21:17 -07:00
|
|
|
// is this widget enabled?
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mEnabled;
|
2008-04-22 04:21:17 -07:00
|
|
|
// Has anyone set an x/y location for this widget yet? Toplevels
|
|
|
|
// shouldn't be automatically set to 0,0 for first show.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mPlaced;
|
2008-04-22 04:21:17 -07:00
|
|
|
|
2010-02-04 06:43:52 -08:00
|
|
|
// Remember the last sizemode so that we can restore it when
|
|
|
|
// leaving fullscreen
|
|
|
|
nsSizeMode mLastSizeMode;
|
|
|
|
|
2011-11-27 03:51:52 -08:00
|
|
|
InputContext mInputContext;
|
2010-11-22 22:48:45 -08:00
|
|
|
|
2008-04-19 08:37:51 -07:00
|
|
|
/**
|
|
|
|
* Event handlers (proxied from the actual qwidget).
|
|
|
|
* They follow normal Qt widget semantics.
|
|
|
|
*/
|
2009-07-15 05:20:21 -07:00
|
|
|
void Initialize(MozQWidget *widget);
|
2008-04-19 08:37:51 -07:00
|
|
|
friend class nsQtEventDispatcher;
|
|
|
|
friend class InterceptContainer;
|
|
|
|
friend class MozQWidget;
|
|
|
|
|
2010-02-16 10:14:20 -08:00
|
|
|
virtual nsEventStatus OnMoveEvent(QGraphicsSceneHoverEvent *);
|
|
|
|
virtual nsEventStatus OnResizeEvent(QGraphicsSceneResizeEvent *);
|
2008-04-22 04:21:18 -07:00
|
|
|
virtual nsEventStatus OnCloseEvent(QCloseEvent *);
|
2010-02-16 10:14:20 -08:00
|
|
|
virtual nsEventStatus OnEnterNotifyEvent(QGraphicsSceneHoverEvent *);
|
|
|
|
virtual nsEventStatus OnLeaveNotifyEvent(QGraphicsSceneHoverEvent *);
|
2011-02-03 13:27:01 -08:00
|
|
|
virtual nsEventStatus OnMotionNotifyEvent(QPointF, Qt::KeyboardModifiers);
|
2010-02-16 10:14:20 -08:00
|
|
|
virtual nsEventStatus OnButtonPressEvent(QGraphicsSceneMouseEvent *);
|
|
|
|
virtual nsEventStatus OnButtonReleaseEvent(QGraphicsSceneMouseEvent *);
|
2010-04-21 15:54:25 -07:00
|
|
|
virtual nsEventStatus OnMouseDoubleClickEvent(QGraphicsSceneMouseEvent *);
|
2010-02-16 10:14:20 -08:00
|
|
|
virtual nsEventStatus OnFocusInEvent(QEvent *);
|
|
|
|
virtual nsEventStatus OnFocusOutEvent(QEvent *);
|
2008-04-20 01:16:40 -07:00
|
|
|
virtual nsEventStatus OnKeyPressEvent(QKeyEvent *);
|
|
|
|
virtual nsEventStatus OnKeyReleaseEvent(QKeyEvent *);
|
2010-02-16 10:14:20 -08:00
|
|
|
virtual nsEventStatus OnScrollEvent(QGraphicsSceneWheelEvent *);
|
2008-04-20 01:16:40 -07:00
|
|
|
|
2010-02-16 10:14:20 -08:00
|
|
|
virtual nsEventStatus contextMenuEvent(QGraphicsSceneContextMenuEvent *);
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual nsEventStatus imComposeEvent(QInputMethodEvent *, bool &handled);
|
2010-02-16 10:14:20 -08:00
|
|
|
virtual nsEventStatus OnDragEnter (QGraphicsSceneDragDropEvent *);
|
|
|
|
virtual nsEventStatus OnDragMotionEvent(QGraphicsSceneDragDropEvent *);
|
|
|
|
virtual nsEventStatus OnDragLeaveEvent(QGraphicsSceneDragDropEvent *);
|
|
|
|
virtual nsEventStatus OnDragDropEvent (QGraphicsSceneDragDropEvent *);
|
2008-04-20 01:16:40 -07:00
|
|
|
virtual nsEventStatus showEvent(QShowEvent *);
|
|
|
|
virtual nsEventStatus hideEvent(QHideEvent *);
|
|
|
|
|
2010-03-12 14:11:42 -08:00
|
|
|
//Gestures are only supported in qt > 4.6
|
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0))
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual nsEventStatus OnTouchEvent(QTouchEvent *event, bool &handled);
|
2010-10-08 23:08:42 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual nsEventStatus OnGestureEvent(QGestureEvent *event, bool &handled);
|
2012-08-22 08:56:38 -07:00
|
|
|
nsEventStatus DispatchGestureEvent(uint32_t aMsg, uint32_t aDirection,
|
2010-10-08 23:08:42 -07:00
|
|
|
double aDelta, const nsIntPoint& aRefPoint);
|
|
|
|
|
2010-03-12 14:11:42 -08:00
|
|
|
double DistanceBetweenPoints(const QPointF &aFirstPoint, const QPointF &aSecondPoint);
|
|
|
|
#endif
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void NativeResize(int32_t aWidth,
|
|
|
|
int32_t aHeight,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aRepaint);
|
2008-04-19 08:37:51 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void NativeResize(int32_t aX,
|
|
|
|
int32_t aY,
|
|
|
|
int32_t aWidth,
|
|
|
|
int32_t aHeight,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aRepaint);
|
2008-04-19 08:37:51 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void NativeShow (bool aAction);
|
2008-04-19 08:37:51 -07:00
|
|
|
|
|
|
|
enum PluginType {
|
|
|
|
PluginType_NONE = 0, /* do not have any plugin */
|
|
|
|
PluginType_XEMBED, /* the plugin support xembed */
|
|
|
|
PluginType_NONXEMBED /* the plugin does not support xembed */
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetPluginType(PluginType aPluginType);
|
|
|
|
|
|
|
|
void ThemeChanged(void);
|
|
|
|
|
2010-02-16 10:14:20 -08:00
|
|
|
gfxASurface* GetThebesSurface();
|
2008-04-19 08:37:51 -07:00
|
|
|
|
|
|
|
private:
|
2011-01-18 00:51:04 -08:00
|
|
|
typedef struct {
|
|
|
|
QPointF centerPoint;
|
|
|
|
QPointF touchPoint;
|
|
|
|
double delta;
|
|
|
|
bool needDispatch;
|
|
|
|
double startDistance;
|
|
|
|
double prevDistance;
|
|
|
|
} MozCachedTouchEvent;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
QPointF pos;
|
|
|
|
Qt::KeyboardModifiers modifiers;
|
|
|
|
bool needDispatch;
|
|
|
|
} MozCachedMoveEvent;
|
|
|
|
|
2012-10-26 06:15:22 -07:00
|
|
|
bool CheckForRollup(double aMouseX, double aMouseY, bool aIsWheel);
|
2010-02-16 10:14:20 -08:00
|
|
|
void* SetupPluginPort(void);
|
2009-01-21 20:15:34 -08:00
|
|
|
nsresult SetWindowIconList(const nsTArray<nsCString> &aIconList);
|
2008-04-19 08:37:51 -07:00
|
|
|
void SetDefaultIcon(void);
|
2010-02-16 10:14:20 -08:00
|
|
|
void InitButtonEvent(nsMouseEvent &event, QGraphicsSceneMouseEvent *aEvent, int aClickCount = 1);
|
2011-07-13 18:58:07 -07:00
|
|
|
nsEventStatus DispatchCommandEvent(nsIAtom* aCommand);
|
2012-08-22 08:56:38 -07:00
|
|
|
nsEventStatus DispatchContentCommandEvent(int32_t aMsg);
|
2011-09-25 12:03:22 -07:00
|
|
|
MozQWidget* createQWidget(MozQWidget* parent,
|
|
|
|
nsNativeWidget nativeParent,
|
|
|
|
nsWidgetInitData* aInitData);
|
2011-11-27 03:51:52 -08:00
|
|
|
void SetSoftwareKeyboardState(bool aOpen, const InputContextAction& aAction);
|
2012-11-03 21:00:08 -07:00
|
|
|
void ClearCachedResources();
|
2010-02-16 10:14:20 -08:00
|
|
|
|
|
|
|
MozQWidget* mWidget;
|
2008-04-19 08:37:51 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mIsVisible : 1,
|
2010-02-16 10:14:20 -08:00
|
|
|
mActivatePending : 1;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mSizeState;
|
2010-02-16 10:14:20 -08:00
|
|
|
PluginType mPluginType;
|
2008-04-19 08:37:51 -07:00
|
|
|
|
2008-04-19 08:31:50 -07:00
|
|
|
nsRefPtr<gfxASurface> mThebesSurface;
|
2012-06-29 01:32:21 -07:00
|
|
|
nsCOMPtr<nsIIdleServiceInternal> mIdleService;
|
2008-04-19 08:37:51 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsTransparent;
|
2012-07-30 17:42:26 -07:00
|
|
|
|
2008-04-19 08:37:51 -07:00
|
|
|
// all of our DND stuff
|
|
|
|
// this is the last window that had a drag event happen on it.
|
|
|
|
void InitDragEvent (nsMouseEvent &aEvent);
|
|
|
|
|
|
|
|
// this is everything we need to be able to fire motion events
|
|
|
|
// repeatedly
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mKeyDownFlags[8];
|
2008-04-19 08:37:51 -07:00
|
|
|
|
|
|
|
/* Helper methods for DOM Key Down event suppression. */
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t* GetFlagWord32(uint32_t aKeyCode, uint32_t* aMask) {
|
2008-04-19 08:37:51 -07:00
|
|
|
/* Mozilla DOM Virtual Key Code is from 0 to 224. */
|
|
|
|
NS_ASSERTION((aKeyCode <= 0xFF), "Invalid DOM Key Code");
|
|
|
|
aKeyCode &= 0xFF;
|
|
|
|
|
|
|
|
/* 32 = 2^5 = 0x20 */
|
2012-08-22 08:56:38 -07:00
|
|
|
*aMask = uint32_t(1) << (aKeyCode & 0x1F);
|
2008-04-19 08:37:51 -07:00
|
|
|
return &mKeyDownFlags[(aKeyCode >> 5)];
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
bool IsKeyDown(uint32_t aKeyCode) {
|
|
|
|
uint32_t mask;
|
|
|
|
uint32_t* flag = GetFlagWord32(aKeyCode, &mask);
|
2008-04-19 08:37:51 -07:00
|
|
|
return ((*flag) & mask) != 0;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void SetKeyDownFlag(uint32_t aKeyCode) {
|
|
|
|
uint32_t mask;
|
|
|
|
uint32_t* flag = GetFlagWord32(aKeyCode, &mask);
|
2008-04-19 08:37:51 -07:00
|
|
|
*flag |= mask;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void ClearKeyDownFlag(uint32_t aKeyCode) {
|
|
|
|
uint32_t mask;
|
|
|
|
uint32_t* flag = GetFlagWord32(aKeyCode, &mask);
|
2008-04-19 08:37:51 -07:00
|
|
|
*flag &= ~mask;
|
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mQCursor;
|
2008-04-19 08:37:51 -07:00
|
|
|
|
2010-04-16 10:37:16 -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-01-18 00:51:04 -08:00
|
|
|
inline void ProcessMotionEvent() {
|
|
|
|
if (mPinchEvent.needDispatch) {
|
|
|
|
double distance = DistanceBetweenPoints(mPinchEvent.centerPoint, mPinchEvent.touchPoint);
|
|
|
|
distance *= 2;
|
|
|
|
mPinchEvent.delta = distance - mPinchEvent.prevDistance;
|
|
|
|
nsIntPoint centerPoint(mPinchEvent.centerPoint.x(), mPinchEvent.centerPoint.y());
|
|
|
|
DispatchGestureEvent(NS_SIMPLE_GESTURE_MAGNIFY_UPDATE,
|
|
|
|
0, mPinchEvent.delta, centerPoint);
|
|
|
|
mPinchEvent.prevDistance = distance;
|
|
|
|
}
|
|
|
|
if (mMoveEvent.needDispatch) {
|
2011-10-17 07:59:28 -07:00
|
|
|
nsMouseEvent event(true, NS_MOUSE_MOVE, this, nsMouseEvent::eReal);
|
2011-01-18 00:51:04 -08:00
|
|
|
|
|
|
|
event.refPoint.x = nscoord(mMoveEvent.pos.x());
|
|
|
|
event.refPoint.y = nscoord(mMoveEvent.pos.y());
|
|
|
|
|
2012-04-24 20:00:02 -07:00
|
|
|
event.InitBasicModifiers(mMoveEvent.modifiers & Qt::ControlModifier,
|
|
|
|
mMoveEvent.modifiers & Qt::AltModifier,
|
|
|
|
mMoveEvent.modifiers & Qt::ShiftModifier,
|
|
|
|
mMoveEvent.modifiers & Qt::MetaModifier);
|
2011-01-18 00:51:04 -08:00
|
|
|
event.clickCount = 0;
|
|
|
|
|
|
|
|
DispatchEvent(&event);
|
|
|
|
mMoveEvent.needDispatch = false;
|
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
mTimerStarted = false;
|
2011-01-18 00:51:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void DispatchMotionToMainThread() {
|
|
|
|
if (!mTimerStarted) {
|
|
|
|
nsCOMPtr<nsIRunnable> event =
|
|
|
|
NS_NewRunnableMethod(this, &nsWindow::ProcessMotionEvent);
|
|
|
|
NS_DispatchToMainThread(event);
|
2011-10-17 07:59:28 -07:00
|
|
|
mTimerStarted = true;
|
2011-01-18 00:51:04 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-25 12:45:37 -08:00
|
|
|
// Remember dirty area caused by ::Scroll
|
|
|
|
QRegion mDirtyScrollArea;
|
2010-03-12 14:11:42 -08:00
|
|
|
|
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0))
|
2010-10-08 23:08:42 -07:00
|
|
|
QTime mLastMultiTouchTime;
|
2010-03-25 17:33:31 -07:00
|
|
|
#endif
|
2010-03-21 19:55:36 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mNeedsResize;
|
|
|
|
bool mNeedsMove;
|
|
|
|
bool mListenForResizes;
|
|
|
|
bool mNeedsShow;
|
|
|
|
bool mGesturesCancelled;
|
2011-01-18 00:51:04 -08:00
|
|
|
MozCachedTouchEvent mPinchEvent;
|
|
|
|
MozCachedMoveEvent mMoveEvent;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mTimerStarted;
|
2008-04-19 08:31:50 -07:00
|
|
|
};
|
|
|
|
|
2008-04-19 08:37:51 -07:00
|
|
|
class nsChildWindow : public nsWindow
|
2008-04-19 08:31:50 -07:00
|
|
|
{
|
|
|
|
public:
|
2008-04-19 08:37:51 -07:00
|
|
|
nsChildWindow();
|
|
|
|
~nsChildWindow();
|
2008-04-19 08:31:50 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mChildID;
|
2008-04-19 08:31:50 -07:00
|
|
|
};
|
|
|
|
|
2008-04-19 08:37:51 -07:00
|
|
|
class nsPopupWindow : public nsWindow
|
2008-04-19 08:31:50 -07:00
|
|
|
{
|
|
|
|
public:
|
2010-02-16 10:14:20 -08:00
|
|
|
nsPopupWindow ();
|
|
|
|
~nsPopupWindow ();
|
2008-04-19 08:31:50 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mChildID;
|
2008-04-19 08:31:50 -07:00
|
|
|
};
|
2008-04-19 08:37:51 -07:00
|
|
|
#endif /* __nsWindow_h__ */
|
2008-04-19 08:31:50 -07:00
|
|
|
|