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