2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 22:01:16 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2004-04-18 22:01:16 +00:00
|
|
|
* 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/
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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.
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 22:01:16 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
2000-03-21 03:42:00 +00:00
|
|
|
* Robert O'Callahan <roc+moz@cs.cmu.edu>
|
2001-03-14 02:34:46 +00:00
|
|
|
* Dean Tessman <dean_tessman@hotmail.com>
|
2002-12-06 03:41:43 +00:00
|
|
|
* Makoto Kato <m_kato@ga2.so-net.ne.jp>
|
2004-07-27 19:14:44 +00:00
|
|
|
* Dainis Jonitis <Dainis_Jonitis@swh-t.lv>
|
2004-09-12 05:00:57 +00:00
|
|
|
* Masayuki Nakano <masayuki@d-toybox.com>
|
2009-02-10 20:56:51 +00:00
|
|
|
* Ningjie Chen <chenn@email.uc.edu>
|
2009-06-29 19:36:16 +00:00
|
|
|
* Jim Mathies <jmathies@mozilla.com>.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 22:01:16 +00:00
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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
|
2004-04-18 22:01:16 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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
|
2004-04-18 22:01:16 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2000-03-21 03:42:00 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
#ifndef Window_h__
|
|
|
|
#define Window_h__
|
|
|
|
|
2009-06-30 06:00:16 +00:00
|
|
|
/*
|
|
|
|
* nsWindow - Native window management and event handling.
|
|
|
|
*/
|
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
#include "nsBaseWidget.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsdefs.h"
|
|
|
|
#include "nsToolkit.h"
|
1998-04-17 23:45:07 +00:00
|
|
|
#include "nsString.h"
|
2008-04-18 14:36:05 +00:00
|
|
|
#include "nsTArray.h"
|
2009-06-29 19:36:16 +00:00
|
|
|
#include "gfxWindowsSurface.h"
|
|
|
|
#include "nsWindowDbg.h"
|
2009-06-24 00:26:11 +00:00
|
|
|
#include "cairo.h"
|
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
#if !defined(WINCE)
|
|
|
|
#include "nsWinGesture.h"
|
|
|
|
#endif
|
2005-03-15 22:13:12 +00:00
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
#if defined(WINCE)
|
|
|
|
#include "nsWindowCE.h"
|
|
|
|
#endif
|
2009-05-03 22:20:11 +00:00
|
|
|
|
2009-08-13 23:04:39 +00:00
|
|
|
#include "WindowHook.h"
|
2009-10-06 02:26:54 +00:00
|
|
|
#include "TaskbarWindowPreview.h"
|
2009-08-13 23:04:39 +00:00
|
|
|
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2003-04-01 20:02:51 +00:00
|
|
|
#include "OLEACC.H"
|
2001-04-17 23:06:38 +00:00
|
|
|
#include "nsIAccessible.h"
|
2001-08-17 03:13:07 +00:00
|
|
|
#endif
|
2001-04-17 23:06:38 +00:00
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
/**
|
|
|
|
* Forward class definitions
|
2004-05-20 03:14:41 +00:00
|
|
|
*/
|
2009-06-29 19:36:16 +00:00
|
|
|
|
|
|
|
class nsNativeDragTarget;
|
|
|
|
class nsIRollupListener;
|
|
|
|
class nsIFile;
|
|
|
|
class imgIContainer;
|
2008-08-30 08:57:48 +00:00
|
|
|
|
1998-04-14 23:20:49 +00:00
|
|
|
/**
|
2004-09-03 08:44:23 +00:00
|
|
|
* Native WIN32 window wrapper.
|
1998-04-14 23:20:49 +00:00
|
|
|
*/
|
|
|
|
|
2009-08-04 22:15:19 +00:00
|
|
|
class nsWindow : public nsBaseWidget
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2009-08-13 23:04:39 +00:00
|
|
|
typedef mozilla::widget::WindowHook WindowHook;
|
2009-10-06 02:26:54 +00:00
|
|
|
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_WIN7
|
|
|
|
typedef mozilla::widget::TaskbarWindowPreview TaskbarWindowPreview;
|
|
|
|
#endif
|
1998-04-13 20:24:54 +00:00
|
|
|
public:
|
2004-09-03 08:44:23 +00:00
|
|
|
nsWindow();
|
|
|
|
virtual ~nsWindow();
|
|
|
|
|
2007-08-07 15:18:36 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
friend class nsWindowGfx;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nsIWidget interface
|
|
|
|
*/
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_IMETHOD Create(nsIWidget *aParent,
|
2009-09-24 06:18:10 +00:00
|
|
|
nsNativeWidget aNativeParent,
|
2009-01-15 03:27:09 +00:00
|
|
|
const nsIntRect &aRect,
|
2004-09-03 08:44:23 +00:00
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
|
|
|
nsIDeviceContext *aContext,
|
|
|
|
nsIAppShell *aAppShell = nsnull,
|
|
|
|
nsIToolkit *aToolkit = nsnull,
|
|
|
|
nsWidgetInitData *aInitData = nsnull);
|
|
|
|
NS_IMETHOD Destroy();
|
|
|
|
NS_IMETHOD SetParent(nsIWidget *aNewParent);
|
|
|
|
virtual nsIWidget* GetParent(void);
|
|
|
|
NS_IMETHOD Show(PRBool bState);
|
|
|
|
NS_IMETHOD IsVisible(PRBool & aState);
|
|
|
|
NS_IMETHOD ConstrainPosition(PRBool aAllowSlop, PRInt32 *aX, PRInt32 *aY);
|
|
|
|
NS_IMETHOD Move(PRInt32 aX, PRInt32 aY);
|
|
|
|
NS_IMETHOD Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint);
|
|
|
|
NS_IMETHOD Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint);
|
2009-10-06 16:11:59 +00:00
|
|
|
#if !defined(WINCE)
|
|
|
|
NS_IMETHOD BeginResizeDrag(nsGUIEvent* aEvent, PRInt32 aHorizontal, PRInt32 aVertical);
|
|
|
|
#endif
|
2009-06-29 19:36:16 +00:00
|
|
|
NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, nsIWidget *aWidget, PRBool aActivate);
|
|
|
|
NS_IMETHOD SetSizeMode(PRInt32 aMode);
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_IMETHOD Enable(PRBool aState);
|
|
|
|
NS_IMETHOD IsEnabled(PRBool *aState);
|
|
|
|
NS_IMETHOD SetFocus(PRBool aRaise);
|
2009-01-15 03:27:09 +00:00
|
|
|
NS_IMETHOD GetBounds(nsIntRect &aRect);
|
|
|
|
NS_IMETHOD GetScreenBounds(nsIntRect &aRect);
|
2009-06-29 19:36:16 +00:00
|
|
|
NS_IMETHOD GetClientBounds(nsIntRect &aRect);
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_IMETHOD SetBackgroundColor(const nscolor &aColor);
|
2005-07-01 04:29:42 +00:00
|
|
|
NS_IMETHOD SetCursor(imgIContainer* aCursor,
|
|
|
|
PRUint32 aHotspotX, PRUint32 aHotspotY);
|
2009-06-29 19:36:16 +00:00
|
|
|
NS_IMETHOD SetCursor(nsCursor aCursor);
|
2009-07-22 00:44:55 +00:00
|
|
|
virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations);
|
2009-07-08 16:13:13 +00:00
|
|
|
NS_IMETHOD MakeFullScreen(PRBool aFullScreen);
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_IMETHOD HideWindowChrome(PRBool aShouldHide);
|
|
|
|
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
|
2009-01-15 03:27:09 +00:00
|
|
|
NS_IMETHOD Invalidate(const nsIntRect & aRect, PRBool aIsSynchronous);
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_IMETHOD Update();
|
2009-08-14 02:09:51 +00:00
|
|
|
virtual void Scroll(const nsIntPoint& aDelta,
|
|
|
|
const nsTArray<nsIntRect>& aDestRects,
|
2009-07-22 00:45:13 +00:00
|
|
|
const nsTArray<Configuration>& aReconfigureChildren);
|
2009-06-29 19:36:16 +00:00
|
|
|
virtual void* GetNativeData(PRUint32 aDataType);
|
|
|
|
virtual void FreeNativeData(void * data, PRUint32 aDataType);
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_IMETHOD SetTitle(const nsAString& aTitle);
|
|
|
|
NS_IMETHOD SetIcon(const nsAString& aIconSpec);
|
2009-02-19 00:11:49 +00:00
|
|
|
virtual nsIntPoint WidgetToScreenOffset();
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
|
|
|
|
NS_IMETHOD EnableDragDrop(PRBool aEnable);
|
2009-06-29 19:36:16 +00:00
|
|
|
NS_IMETHOD CaptureMouse(PRBool aCapture);
|
2009-12-22 23:49:33 +00:00
|
|
|
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, nsIMenuRollup * aMenuRollup,
|
|
|
|
PRBool aDoCapture, PRBool aConsumeRollupEvent);
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_IMETHOD GetAttention(PRInt32 aCycleCount);
|
2009-04-21 23:53:52 +00:00
|
|
|
virtual PRBool HasPendingInputEvent();
|
2006-01-31 01:04:41 +00:00
|
|
|
gfxASurface *GetThebesSurface();
|
2009-07-15 09:54:30 +00:00
|
|
|
NS_IMETHOD OnDefaultButtonLoaded(const nsIntRect &aButtonRect);
|
2009-09-24 10:58:04 +00:00
|
|
|
NS_IMETHOD OverrideSystemMouseScrollSpeed(PRInt32 aOriginalDelta, PRBool aIsHorizontal, PRInt32 &aOverriddenDelta);
|
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
virtual nsresult SynthesizeNativeKeyEvent(PRInt32 aNativeKeyboardLayout,
|
|
|
|
PRInt32 aNativeKeyCode,
|
|
|
|
PRUint32 aModifierFlags,
|
|
|
|
const nsAString& aCharacters,
|
|
|
|
const nsAString& aUnmodifiedCharacters);
|
2009-10-07 11:14:12 +00:00
|
|
|
virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint,
|
|
|
|
PRUint32 aNativeMessage,
|
|
|
|
PRUint32 aModifierFlags);
|
2009-06-29 19:36:16 +00:00
|
|
|
NS_IMETHOD ResetInputState();
|
|
|
|
NS_IMETHOD SetIMEOpenState(PRBool aState);
|
|
|
|
NS_IMETHOD GetIMEOpenState(PRBool* aState);
|
|
|
|
NS_IMETHOD SetIMEEnabled(PRUint32 aState);
|
|
|
|
NS_IMETHOD GetIMEEnabled(PRUint32* aState);
|
|
|
|
NS_IMETHOD CancelIMEComposition();
|
|
|
|
NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode, PRBool* aLEDState);
|
2004-07-27 19:14:44 +00:00
|
|
|
#ifdef MOZ_XUL
|
2008-08-13 00:44:14 +00:00
|
|
|
virtual void SetTransparencyMode(nsTransparencyMode aMode);
|
|
|
|
virtual nsTransparencyMode GetTransparencyMode();
|
2009-06-29 19:36:16 +00:00
|
|
|
#endif // MOZ_XUL
|
2009-02-10 20:56:51 +00:00
|
|
|
#ifdef NS_ENABLE_TSF
|
2009-06-29 19:36:16 +00:00
|
|
|
NS_IMETHOD OnIMEFocusChange(PRBool aFocus);
|
|
|
|
NS_IMETHOD OnIMETextChange(PRUint32 aStart, PRUint32 aOldEnd, PRUint32 aNewEnd);
|
|
|
|
NS_IMETHOD OnIMESelectionChange(void);
|
|
|
|
#endif // NS_ENABLE_TSF
|
2009-02-10 20:56:51 +00:00
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
/**
|
|
|
|
* Statics used in other classes
|
|
|
|
*/
|
|
|
|
static PRInt32 GetWindowsVersion();
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
/**
|
|
|
|
* Event helpers
|
|
|
|
*/
|
|
|
|
void InitEvent(nsGUIEvent& event, nsIntPoint* aPoint = nsnull);
|
2006-11-16 21:35:39 +00:00
|
|
|
virtual PRBool DispatchMouseEvent(PRUint32 aEventType, WPARAM wParam,
|
|
|
|
LPARAM lParam,
|
|
|
|
PRBool aIsContextMenuKey = PR_FALSE,
|
|
|
|
PRInt16 aButton = nsMouseEvent::eLeftButton);
|
2009-02-10 20:56:51 +00:00
|
|
|
virtual PRBool DispatchWindowEvent(nsGUIEvent* event);
|
|
|
|
virtual PRBool DispatchWindowEvent(nsGUIEvent*event, nsEventStatus &aStatus);
|
2009-06-29 19:36:16 +00:00
|
|
|
virtual PRBool DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode,
|
|
|
|
const nsTArray<nsAlternativeCharCode>* aAlternativeChars,
|
|
|
|
UINT aVirtualCharCode, const MSG *aMsg,
|
|
|
|
const nsModifierKeyState &aModKeyState,
|
|
|
|
PRUint32 aFlags = 0);
|
|
|
|
void SuppressBlurEvents(PRBool aSuppress); // Called from nsFilePicker
|
|
|
|
PRBool BlurEventsSuppressed();
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2009-01-15 03:27:09 +00:00
|
|
|
virtual PRBool DispatchAccessibleEvent(PRUint32 aEventType, nsIAccessible** aAccessible, nsIntPoint* aPoint = nsnull);
|
2006-04-18 19:08:34 +00:00
|
|
|
already_AddRefed<nsIAccessible> GetRootAccessible();
|
2009-06-29 19:36:16 +00:00
|
|
|
#endif // ACCESSIBILITY
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Window utilities
|
|
|
|
*/
|
|
|
|
static void GlobalMsgWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|
|
|
nsWindow* GetTopLevelWindow(PRBool aStopOnDialogOrPopup);
|
|
|
|
static HWND GetTopLevelHWND(HWND aWnd, PRBool aStopOnDialogOrPopup = PR_FALSE);
|
|
|
|
HWND GetWindowHandle() { return mWnd; }
|
|
|
|
WNDPROC GetPrevWindowProc() { return mPrevWndProc; }
|
2009-08-13 23:04:39 +00:00
|
|
|
static nsWindow* GetNSWindowPtr(HWND aWnd);
|
|
|
|
WindowHook& GetWindowHook() { return mWindowHook; }
|
2009-05-03 22:20:11 +00:00
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
/**
|
|
|
|
* Misc.
|
|
|
|
*/
|
2009-09-03 00:40:10 +00:00
|
|
|
virtual PRBool AutoErase(HDC dc);
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntPoint* GetLastPoint() { return &mLastPoint; }
|
2004-09-03 08:44:23 +00:00
|
|
|
PRInt32 GetNewCmdMenuId() { mMenuCmdId++; return mMenuCmdId; }
|
2009-05-03 22:20:11 +00:00
|
|
|
PRBool GetIMEEnabled() { return mIMEEnabled; }
|
2009-06-29 19:36:16 +00:00
|
|
|
// needed in nsIMM32Handler.cpp
|
|
|
|
PRBool PluginHasFocus() { return mIMEEnabled == nsIWidget::IME_STATUS_PLUGIN; }
|
|
|
|
virtual void SetUpForPaint(HDC aHDC);
|
2009-05-03 22:20:11 +00:00
|
|
|
|
2009-10-06 02:26:54 +00:00
|
|
|
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_WIN7
|
|
|
|
PRBool HasTaskbarIconBeenCreated() { return mHasTaskbarIconBeenCreated; }
|
|
|
|
// Called when either the nsWindow or an nsITaskbarTabPreview receives the noticiation that this window
|
|
|
|
// has its icon placed on the taskbar.
|
|
|
|
void SetHasTaskbarIconBeenCreated(PRBool created = PR_TRUE) { mHasTaskbarIconBeenCreated = created; }
|
|
|
|
|
|
|
|
// Getter/setter for the nsITaskbarWindowPreview for this nsWindow
|
|
|
|
already_AddRefed<nsITaskbarWindowPreview> GetTaskbarPreview() {
|
|
|
|
nsCOMPtr<nsITaskbarWindowPreview> preview(do_QueryReferent(mTaskbarPreview));
|
|
|
|
return preview.forget();
|
|
|
|
}
|
|
|
|
void SetTaskbarPreview(nsITaskbarWindowPreview *preview) { mTaskbarPreview = do_GetWeakReference(preview); }
|
|
|
|
#endif
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
protected:
|
2005-02-23 07:07:51 +00:00
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
/**
|
|
|
|
* Callbacks
|
|
|
|
*/
|
|
|
|
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|
|
|
static BOOL CALLBACK BroadcastMsgToChildren(HWND aWnd, LPARAM aMsg);
|
|
|
|
static BOOL CALLBACK BroadcastMsg(HWND aTopWindow, LPARAM aMsg);
|
|
|
|
static BOOL CALLBACK DispatchStarvedPaints(HWND aTopWindow, LPARAM aMsg);
|
2004-09-03 08:44:23 +00:00
|
|
|
static LRESULT CALLBACK MozSpecialMsgFilter(int code, WPARAM wParam, LPARAM lParam);
|
|
|
|
static LRESULT CALLBACK MozSpecialWndProc(int code, WPARAM wParam, LPARAM lParam);
|
|
|
|
static LRESULT CALLBACK MozSpecialMouseProc(int code, WPARAM wParam, LPARAM lParam);
|
|
|
|
static VOID CALLBACK HookTimerForPopups( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime );
|
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
/**
|
|
|
|
* Window utilities
|
|
|
|
*/
|
2004-09-03 08:44:23 +00:00
|
|
|
static BOOL SetNSWindowPtr(HWND aWnd, nsWindow * ptr);
|
2009-06-29 19:36:16 +00:00
|
|
|
LPARAM lParamToScreen(LPARAM lParam);
|
|
|
|
LPARAM lParamToClient(LPARAM lParam);
|
2009-04-19 19:15:25 +00:00
|
|
|
nsWindow* GetParentWindow(PRBool aIncludeOwner);
|
2009-06-29 19:36:16 +00:00
|
|
|
virtual void SubclassWindow(BOOL bState);
|
|
|
|
void GetNonClientBounds(nsIntRect &aRect);
|
|
|
|
PRBool CanTakeFocus();
|
2009-10-07 04:19:04 +00:00
|
|
|
#if !defined(WINCE)
|
|
|
|
static void InitTrackPointHack();
|
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
/**
|
|
|
|
* Event processing helpers
|
|
|
|
*/
|
2004-09-03 08:44:23 +00:00
|
|
|
void DispatchPendingEvents();
|
2009-06-29 19:36:16 +00:00
|
|
|
PRBool DispatchPluginEvent(const MSG &aMsg);
|
|
|
|
PRBool DispatchFocusToTopLevelWindow(PRUint32 aEventType);
|
|
|
|
PRBool DispatchFocus(PRUint32 aEventType);
|
|
|
|
PRBool DispatchStandardEvent(PRUint32 aMsg);
|
|
|
|
PRBool DispatchCommandEvent(PRUint32 aEventCommand);
|
|
|
|
void RelayMouseEvent(UINT aMsg, WPARAM wParam, LPARAM lParam);
|
|
|
|
void RemoveMessageAndDispatchPluginEvent(UINT aFirstMsg, UINT aLastMsg);
|
|
|
|
static MSG InitMSG(UINT aMessage, WPARAM wParam, LPARAM lParam);
|
2009-05-03 22:20:11 +00:00
|
|
|
virtual PRBool ProcessMessage(UINT msg, WPARAM &wParam,
|
|
|
|
LPARAM &lParam, LRESULT *aRetValue);
|
2008-12-15 03:54:54 +00:00
|
|
|
PRBool ProcessMessageForPlugin(const MSG &aMsg,
|
2009-06-29 19:36:16 +00:00
|
|
|
LRESULT *aRetValue, PRBool &aCallDefWndProc);
|
2008-12-15 03:54:54 +00:00
|
|
|
LRESULT ProcessCharMessage(const MSG &aMsg,
|
|
|
|
PRBool *aEventDispatched);
|
|
|
|
LRESULT ProcessKeyUpMessage(const MSG &aMsg,
|
|
|
|
PRBool *aEventDispatched);
|
|
|
|
LRESULT ProcessKeyDownMessage(const MSG &aMsg,
|
|
|
|
PRBool *aEventDispatched);
|
2009-06-29 19:36:16 +00:00
|
|
|
static PRBool EventIsInsideWindow(UINT Msg, nsWindow* aWindow);
|
|
|
|
// Convert nsEventStatus value to a windows boolean
|
|
|
|
static PRBool ConvertStatus(nsEventStatus aStatus);
|
|
|
|
static void PostSleepWakeNotification(const char* aNotification);
|
2009-08-31 22:19:06 +00:00
|
|
|
PRBool HandleScrollingPlugins(UINT aMsg, WPARAM aWParam,
|
|
|
|
LPARAM aLParam,
|
2009-11-19 23:43:34 +00:00
|
|
|
PRBool& aResult,
|
|
|
|
LRESULT* aRetValue,
|
|
|
|
PRBool& aQuitProcessing);
|
2008-12-15 03:54:54 +00:00
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
/**
|
|
|
|
* Event handlers
|
|
|
|
*/
|
2004-09-03 08:44:23 +00:00
|
|
|
virtual void OnDestroy();
|
|
|
|
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
2009-01-15 03:27:09 +00:00
|
|
|
virtual PRBool OnResize(nsIntRect &aWindowRect);
|
2009-05-03 22:20:11 +00:00
|
|
|
LRESULT OnChar(const MSG &aMsg,
|
|
|
|
nsModifierKeyState &aModKeyState,
|
|
|
|
PRBool *aEventDispatched,
|
2008-12-15 03:54:54 +00:00
|
|
|
PRUint32 aFlags = 0);
|
2009-05-03 22:20:11 +00:00
|
|
|
LRESULT OnKeyDown(const MSG &aMsg,
|
|
|
|
nsModifierKeyState &aModKeyState,
|
|
|
|
PRBool *aEventDispatched,
|
2008-12-15 03:54:54 +00:00
|
|
|
nsFakeCharMessage* aFakeCharMessage);
|
2009-05-03 22:20:11 +00:00
|
|
|
LRESULT OnKeyUp(const MSG &aMsg,
|
|
|
|
nsModifierKeyState &aModKeyState,
|
|
|
|
PRBool *aEventDispatched);
|
2008-12-15 03:54:54 +00:00
|
|
|
LRESULT OnCharRaw(UINT charCode, UINT aScanCode,
|
2009-05-03 22:20:11 +00:00
|
|
|
nsModifierKeyState &aModKeyState,
|
2008-12-15 03:54:54 +00:00
|
|
|
PRUint32 aFlags = 0,
|
|
|
|
const MSG *aMsg = nsnull,
|
|
|
|
PRBool *aEventDispatched = nsnull);
|
2009-08-31 22:19:06 +00:00
|
|
|
virtual PRBool OnScroll(UINT aMsg, WPARAM aWParam, LPARAM aLParam);
|
2004-09-03 08:44:23 +00:00
|
|
|
virtual HBRUSH OnControlColor();
|
2009-06-29 19:36:16 +00:00
|
|
|
PRBool OnGesture(WPARAM wParam, LPARAM lParam);
|
|
|
|
PRBool OnHotKey(WPARAM wParam, LPARAM lParam);
|
|
|
|
BOOL OnInputLangChange(HKL aHKL);
|
|
|
|
void OnSettingsChange(WPARAM wParam, LPARAM lParam);
|
|
|
|
virtual PRBool OnPaint(HDC aDC = nsnull);
|
2009-08-11 17:29:53 +00:00
|
|
|
void OnWindowPosChanged(WINDOWPOS *wp, PRBool& aResult);
|
2009-06-29 19:36:16 +00:00
|
|
|
#if defined(CAIRO_HAS_DDRAW_SURFACE)
|
|
|
|
PRBool OnPaintImageDDraw16();
|
|
|
|
#endif // defined(CAIRO_HAS_DDRAW_SURFACE)
|
|
|
|
PRBool OnMouseWheel(UINT msg, WPARAM wParam, LPARAM lParam,
|
|
|
|
PRBool& result, PRBool& getWheelInfo,
|
|
|
|
LRESULT *aRetValue);
|
2009-07-09 00:26:30 +00:00
|
|
|
#if !defined(WINCE)
|
2009-06-29 19:36:16 +00:00
|
|
|
void OnWindowPosChanging(LPWINDOWPOS& info);
|
|
|
|
#endif // !defined(WINCE)
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
/**
|
|
|
|
* Methods for derived classes
|
|
|
|
*/
|
|
|
|
virtual PRInt32 GetHeight(PRInt32 aProposedHeight);
|
|
|
|
virtual LPCWSTR WindowClass();
|
|
|
|
virtual LPCWSTR WindowPopupClass();
|
|
|
|
virtual DWORD WindowStyle();
|
|
|
|
virtual DWORD WindowExStyle();
|
2008-05-07 04:46:37 +00:00
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
/**
|
|
|
|
* XP and Vista theming support for windows with rounded edges
|
|
|
|
*/
|
|
|
|
void ClearThemeRegion();
|
|
|
|
void SetThemeRegion();
|
2009-03-25 00:51:57 +00:00
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
/**
|
|
|
|
* Popup hooks
|
|
|
|
*/
|
|
|
|
static void ScheduleHookTimer(HWND aWnd, UINT aMsgId);
|
|
|
|
static void RegisterSpecialDropdownHooks();
|
|
|
|
static void UnregisterSpecialDropdownHooks();
|
|
|
|
static BOOL DealWithPopups(HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inLParam, LRESULT* outResult);
|
1999-07-09 12:23:24 +00:00
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
/**
|
|
|
|
* Window transparency helpers
|
|
|
|
*/
|
|
|
|
#ifdef MOZ_XUL
|
2009-03-27 00:15:41 +00:00
|
|
|
private:
|
2009-06-29 19:36:16 +00:00
|
|
|
void SetWindowTranslucencyInner(nsTransparencyMode aMode);
|
|
|
|
nsTransparencyMode GetWindowTranslucencyInner() const { return mTransparencyMode; }
|
|
|
|
void ResizeTranslucentWindow(PRInt32 aNewWidth, PRInt32 aNewHeight, PRBool force = PR_FALSE);
|
|
|
|
nsresult UpdateTranslucentWindow();
|
|
|
|
void SetupTranslucentWindowMemoryBitmap(nsTransparencyMode aMode);
|
1998-04-13 20:24:54 +00:00
|
|
|
protected:
|
2009-06-29 19:36:16 +00:00
|
|
|
#endif // MOZ_XUL
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2010-02-09 22:34:38 +00:00
|
|
|
#ifdef MOZ_IPC
|
|
|
|
static bool IsAsyncResponseEvent(UINT aMsg, LRESULT& aResult);
|
|
|
|
static void IPCWindowProcHandler(HWND& hWnd, UINT& msg, WPARAM& wParam, LPARAM& lParam);
|
|
|
|
#endif // MOZ_IPC
|
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
/**
|
|
|
|
* Misc.
|
|
|
|
*/
|
|
|
|
UINT MapFromNativeToDOM(UINT aNativeKeyCode);
|
|
|
|
void StopFlashing();
|
|
|
|
static PRBool IsTopLevelMouseExit(HWND aWnd);
|
|
|
|
static void SetupKeyModifiersSequence(nsTArray<KeyPair>* aArray, PRUint32 aModifiers);
|
2009-07-22 00:44:55 +00:00
|
|
|
nsresult SetWindowClipRegion(const nsTArray<nsIntRect>& aRects,
|
|
|
|
PRBool aIntersectWithExisting);
|
2009-08-20 22:15:01 +00:00
|
|
|
nsCOMPtr<nsIRegion> GetRegionToPaint(PRBool aForceFullRepaint,
|
|
|
|
PAINTSTRUCT ps, HDC aDC);
|
2009-11-12 01:11:57 +00:00
|
|
|
#if !defined(WINCE)
|
|
|
|
static void ActivateOtherWindowHelper(HWND aWnd);
|
|
|
|
#endif
|
2009-06-29 19:36:16 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
static STDMETHODIMP_(LRESULT) LresultFromObject(REFIID riid, WPARAM wParam, LPUNKNOWN pAcc);
|
|
|
|
#endif // ACCESSIBILITY
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
protected:
|
|
|
|
nsIntSize mLastSize;
|
|
|
|
nsIntPoint mLastPoint;
|
|
|
|
HWND mWnd;
|
|
|
|
WNDPROC mPrevWndProc;
|
|
|
|
HBRUSH mBrush;
|
|
|
|
PRPackedBool mIsTopWidgetWindow;
|
|
|
|
PRPackedBool mHas3DBorder;
|
2009-07-13 15:58:19 +00:00
|
|
|
PRPackedBool mInDtor;
|
2009-06-29 19:36:16 +00:00
|
|
|
PRPackedBool mIsVisible;
|
|
|
|
PRPackedBool mIsInMouseCapture;
|
|
|
|
PRPackedBool mUnicodeWidget;
|
|
|
|
PRPackedBool mPainting;
|
|
|
|
char mLeadByte;
|
|
|
|
PRUint32 mBlurSuppressLevel;
|
|
|
|
nsContentType mContentType;
|
|
|
|
PRInt32 mMenuCmdId;
|
|
|
|
DWORD_PTR mOldStyle;
|
|
|
|
DWORD_PTR mOldExStyle;
|
|
|
|
HIMC mOldIMC;
|
|
|
|
PRUint32 mIMEEnabled;
|
|
|
|
nsNativeDragTarget* mNativeDragTarget;
|
|
|
|
HKL mLastKeyboardLayout;
|
|
|
|
nsPopupType mPopupType;
|
2009-08-13 20:54:09 +00:00
|
|
|
PRPackedBool mDisplayPanFeedback;
|
2009-08-13 23:04:39 +00:00
|
|
|
WindowHook mWindowHook;
|
2009-06-29 19:36:16 +00:00
|
|
|
static PRUint32 sInstanceCount;
|
|
|
|
static TriStateBool sCanQuit;
|
|
|
|
static nsWindow* sCurrentWindow;
|
|
|
|
static BOOL sIsRegistered;
|
|
|
|
static BOOL sIsPopupClassRegistered;
|
|
|
|
static BOOL sIsOleInitialized;
|
|
|
|
static HCURSOR sHCursor;
|
|
|
|
static imgIContainer* sCursorImgContainer;
|
|
|
|
static PRBool sSwitchKeyboardLayout;
|
|
|
|
static PRBool sJustGotDeactivate;
|
|
|
|
static PRBool sJustGotActivate;
|
|
|
|
static int sTrimOnMinimize;
|
2009-10-07 04:19:04 +00:00
|
|
|
static PRBool sTrackPointHack;
|
2010-01-26 21:40:15 +00:00
|
|
|
#ifdef MOZ_IPC
|
|
|
|
static PRUint32 sOOPPPluginFocusEvent;
|
|
|
|
#endif
|
2009-06-29 19:36:16 +00:00
|
|
|
|
|
|
|
// Hook Data Memebers for Dropdowns. sProcessHook Tells the
|
|
|
|
// hook methods whether they should be processing the hook
|
|
|
|
// messages.
|
|
|
|
static HHOOK sMsgFilterHook;
|
|
|
|
static HHOOK sCallProcHook;
|
|
|
|
static HHOOK sCallMouseHook;
|
|
|
|
static PRPackedBool sProcessHook;
|
|
|
|
static UINT sRollupMsgId;
|
|
|
|
static HWND sRollupMsgWnd;
|
|
|
|
static UINT sHookTimerId;
|
|
|
|
|
|
|
|
// Rollup Listener
|
|
|
|
static nsIWidget* sRollupWidget;
|
|
|
|
static PRBool sRollupConsumeEvent;
|
|
|
|
static nsIRollupListener* sRollupListener;
|
2009-12-22 23:49:33 +00:00
|
|
|
static nsIMenuRollup* sMenuRollup;
|
2009-06-29 19:36:16 +00:00
|
|
|
|
|
|
|
// Mouse Clicks - static variable definitions for figuring
|
|
|
|
// out 1 - 3 Clicks.
|
|
|
|
static POINT sLastMousePoint;
|
|
|
|
static POINT sLastMouseMovePoint;
|
|
|
|
static LONG sLastMouseDownTime;
|
|
|
|
static LONG sLastClickCount;
|
|
|
|
static BYTE sLastMouseButton;
|
|
|
|
|
|
|
|
// Graphics
|
|
|
|
HDC mPaintDC; // only set during painting
|
2009-07-08 23:34:02 +00:00
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
// Transparency
|
|
|
|
#ifdef MOZ_XUL
|
|
|
|
// Use layered windows to support full 256 level alpha translucency
|
|
|
|
nsRefPtr<gfxWindowsSurface> mTransparentSurface;
|
|
|
|
HDC mMemoryDC;
|
|
|
|
nsTransparencyMode mTransparencyMode;
|
|
|
|
#endif // MOZ_XUL
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
// Win7 Gesture processing and management
|
|
|
|
#if !defined(WINCE)
|
|
|
|
nsWinGesture mGesture;
|
|
|
|
#endif // !defined(WINCE)
|
2002-02-27 02:18:12 +00:00
|
|
|
|
2009-10-06 02:26:54 +00:00
|
|
|
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_WIN7
|
|
|
|
// Weak ref to the nsITaskbarWindowPreview associated with this window
|
|
|
|
nsWeakPtr mTaskbarPreview;
|
|
|
|
// True if the taskbar (possibly through the tab preview) tells us that the
|
|
|
|
// icon has been created on the taskbar.
|
|
|
|
PRBool mHasTaskbarIconBeenCreated;
|
|
|
|
#endif
|
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
#if defined(WINCE_HAVE_SOFTKB)
|
|
|
|
static PRBool sSoftKeyboardState;
|
|
|
|
#endif // defined(WINCE_HAVE_SOFTKB)
|
2005-04-13 05:52:02 +00:00
|
|
|
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2009-06-29 19:36:16 +00:00
|
|
|
static BOOL sIsAccessibilityOn;
|
|
|
|
static HINSTANCE sAccLib;
|
|
|
|
static LPFNLRESULTFROMOBJECT sLresultFromObject;
|
|
|
|
#endif // ACCESSIBILITY
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
2009-06-29 19:36:16 +00:00
|
|
|
/**
|
|
|
|
* A child window is a window with different style.
|
|
|
|
*/
|
1998-04-13 20:24:54 +00:00
|
|
|
class ChildWindow : public nsWindow {
|
|
|
|
|
|
|
|
public:
|
2004-09-03 08:44:23 +00:00
|
|
|
ChildWindow() {}
|
2006-11-16 21:35:39 +00:00
|
|
|
PRBool DispatchMouseEvent(PRUint32 aEventType, WPARAM wParam, LPARAM lParam,
|
|
|
|
PRBool aIsContextMenuKey = PR_FALSE,
|
|
|
|
PRInt16 aButton = nsMouseEvent::eLeftButton);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
protected:
|
2004-09-03 08:44:23 +00:00
|
|
|
virtual DWORD WindowStyle();
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
2009-07-08 16:13:13 +00:00
|
|
|
#endif // Window_h__
|