2004-01-12 08:25:18 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2005-03-15 22:13:12 +00:00
|
|
|
/* vim:set ts=2 sts=2 sw=2 et cin: */
|
2001-09-28 20:14:13 +00:00
|
|
|
/* ***** 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):
|
2002-02-27 01:30:40 +00:00
|
|
|
* Dean Tessman <dean_tessman@hotmail.com>
|
|
|
|
* Ere Maijala <ere@atp.fi>
|
|
|
|
* Mark Hammond <markh@activestate.com>
|
2000-02-04 00:39:15 +00:00
|
|
|
* Michael Lowe <michael.lowe@bigfoot.com>
|
2000-12-19 03:01:31 +00:00
|
|
|
* Peter Bajusz <hyp-x@inf.bme.hu>
|
2000-12-20 01:43:38 +00:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2000-03-21 03:42:00 +00:00
|
|
|
* Robert O'Callahan <roc+moz@cs.cmu.edu>
|
2002-07-03 00:55:47 +00:00
|
|
|
* Roy Yokoyama <yokoyama@netscape.com>
|
2002-12-06 03:41:43 +00:00
|
|
|
* Makoto Kato <m_kato@ga2.so-net.ne.jp>
|
2004-07-15 20:38:00 +00:00
|
|
|
* Masayuki Nakano <masayuki@d-toybox.com>
|
2004-07-27 19:14:44 +00:00
|
|
|
* Dainis Jonitis <Dainis_Jonitis@swh-t.lv>
|
2005-03-15 22:13:12 +00:00
|
|
|
* Christian Biesinger <cbiesinger@web.de>
|
2006-12-04 23:47:34 +00:00
|
|
|
* Mats Palmgren <mats.palmgren@bredband.net>
|
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 ***** */
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-11-11 22:28:52 +00:00
|
|
|
#if defined(DEBUG_ftang)
|
1999-11-15 20:57:41 +00:00
|
|
|
//#define KE_DEBUG
|
1999-12-01 22:10:13 +00:00
|
|
|
//#define DEBUG_IME
|
1999-11-30 22:09:28 +00:00
|
|
|
//#define DEBUG_IME2
|
1999-11-15 20:57:41 +00:00
|
|
|
//#define DEBUG_KBSTATE
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsWindow.h"
|
1998-07-29 18:51:45 +00:00
|
|
|
#include "nsIAppShell.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsIFontMetrics.h"
|
2004-09-03 08:44:23 +00:00
|
|
|
#include "nsIFontEnumerator.h"
|
2004-04-01 22:51:46 +00:00
|
|
|
#include "nsIPrefBranch.h"
|
|
|
|
#include "nsIPrefService.h"
|
1998-09-28 22:32:48 +00:00
|
|
|
#include "nsFont.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsGUIEvent.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsIDeviceContext.h"
|
2002-01-09 01:30:06 +00:00
|
|
|
#include "nsIScreenManager.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsTransform2D.h"
|
2006-05-10 17:30:15 +00:00
|
|
|
#include "nsThreadUtils.h"
|
2006-02-23 17:02:45 +00:00
|
|
|
#include "nsIObserverService.h"
|
2005-03-15 22:13:12 +00:00
|
|
|
#include "imgIContainer.h"
|
|
|
|
#include "gfxIImageFrame.h"
|
2005-02-01 19:24:59 +00:00
|
|
|
#include "nsNativeCharsetUtils.h"
|
2006-03-16 21:02:22 +00:00
|
|
|
#include "nsKeyboardLayout.h"
|
2006-12-01 11:09:53 +00:00
|
|
|
#include "nsWidgetAtoms.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include <windows.h>
|
2005-08-22 04:18:47 +00:00
|
|
|
#include <process.h>
|
2001-05-11 21:11:38 +00:00
|
|
|
|
2007-05-02 09:24:52 +00:00
|
|
|
#ifndef WINCE
|
|
|
|
// mmsystem.h is needed to build with WIN32_LEAN_AND_MEAN
|
|
|
|
#include <mmsystem.h>
|
|
|
|
#endif
|
|
|
|
|
2006-03-17 21:42:28 +00:00
|
|
|
#ifdef WINCE
|
|
|
|
#include "aygshell.h"
|
|
|
|
#include "imm.h"
|
|
|
|
#include "tpcshell.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2002-10-17 06:47:01 +00:00
|
|
|
// unknwn.h is needed to build with WIN32_LEAN_AND_MEAN
|
|
|
|
#include <unknwn.h>
|
|
|
|
|
1999-03-05 15:34:53 +00:00
|
|
|
//#include <winuser.h>
|
|
|
|
#include <zmouse.h>
|
|
|
|
//#include "sysmets.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsGfxCIID.h"
|
|
|
|
#include "resource.h"
|
1998-04-17 00:16:11 +00:00
|
|
|
#include <commctrl.h>
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "prtime.h"
|
2006-02-15 23:35:53 +00:00
|
|
|
#ifdef MOZ_CAIRO_GFX
|
|
|
|
#include "gfxContext.h"
|
|
|
|
#include "gfxWindowsSurface.h"
|
2005-08-23 02:11:54 +00:00
|
|
|
#else
|
1998-12-15 05:44:21 +00:00
|
|
|
#include "nsIRenderingContextWin.h"
|
2005-08-23 02:11:54 +00:00
|
|
|
#endif
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsIImage.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2003-04-01 20:02:51 +00:00
|
|
|
#include "OLEIDL.H"
|
|
|
|
#include "winable.h"
|
2001-04-01 01:38:35 +00:00
|
|
|
#include "nsIAccessible.h"
|
2003-04-01 20:02:51 +00:00
|
|
|
#include "nsIAccessibleDocument.h"
|
|
|
|
#include "nsIAccessNode.h"
|
|
|
|
#ifndef WM_GETOBJECT
|
|
|
|
#define WM_GETOBJECT 0x03d
|
|
|
|
#endif
|
2001-08-17 03:13:07 +00:00
|
|
|
#endif
|
2001-04-01 01:38:35 +00:00
|
|
|
|
2006-03-02 18:46:31 +00:00
|
|
|
#ifndef WINCE
|
2006-02-27 15:09:37 +00:00
|
|
|
#include <pbt.h>
|
|
|
|
#ifndef PBT_APMRESUMEAUTOMATIC
|
|
|
|
#define PBT_APMRESUMEAUTOMATIC 0x0012
|
|
|
|
#endif
|
2006-03-02 18:46:31 +00:00
|
|
|
#endif
|
2006-02-27 15:09:37 +00:00
|
|
|
|
1999-04-06 20:23:55 +00:00
|
|
|
#include "nsNativeDragTarget.h"
|
1999-09-21 11:22:21 +00:00
|
|
|
#include "nsIRollupListener.h"
|
2000-04-13 20:15:40 +00:00
|
|
|
#include "nsIMenuRollup.h"
|
1999-11-20 22:33:42 +00:00
|
|
|
#include "nsIRegion.h"
|
1999-09-21 11:22:21 +00:00
|
|
|
|
1999-06-25 21:17:52 +00:00
|
|
|
//~~~ windowless plugin support
|
1999-06-11 22:48:50 +00:00
|
|
|
#include "nsplugindefs.h"
|
|
|
|
|
1999-03-23 21:26:20 +00:00
|
|
|
// For clipboard support
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIClipboard.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
1999-07-09 19:41:46 +00:00
|
|
|
|
2000-01-21 21:56:09 +00:00
|
|
|
#include "nsITimer.h"
|
|
|
|
|
2001-12-17 22:51:39 +00:00
|
|
|
#include "nsITheme.h"
|
|
|
|
|
2001-04-14 00:57:30 +00:00
|
|
|
// For SetIcon
|
2003-03-15 01:04:32 +00:00
|
|
|
#include "nsILocalFile.h"
|
|
|
|
#include "nsCRT.h"
|
2001-04-14 00:57:30 +00:00
|
|
|
#include "nsAppDirectoryServiceDefs.h"
|
|
|
|
#include "nsXPIDLString.h"
|
|
|
|
#include "nsIFile.h"
|
|
|
|
|
2002-02-27 02:18:12 +00:00
|
|
|
#include "prprf.h"
|
2002-10-01 02:47:41 +00:00
|
|
|
#include "prmem.h"
|
2002-02-27 02:18:12 +00:00
|
|
|
|
2005-03-15 22:13:12 +00:00
|
|
|
static const char kMozHeapDumpMessageString[] = "MOZ_HeapDump";
|
2002-02-27 02:18:12 +00:00
|
|
|
|
2001-06-19 00:20:10 +00:00
|
|
|
#define kWindowPositionSlop 20
|
2000-08-04 14:48:33 +00:00
|
|
|
|
2000-11-02 05:15:34 +00:00
|
|
|
#ifndef SPI_GETWHEELSCROLLLINES
|
|
|
|
#define SPI_GETWHEELSCROLLLINES 104
|
|
|
|
#endif
|
|
|
|
|
2006-09-08 06:04:44 +00:00
|
|
|
#ifndef WM_MOUSEHWHEEL
|
|
|
|
#define WM_MOUSEHWHEEL 0x020E
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SPI_GETWHEELSCROLLCHARS
|
|
|
|
#define SPI_GETWHEELSCROLLCHARS 0x006C
|
|
|
|
#endif
|
2004-12-09 17:56:46 +00:00
|
|
|
|
2006-11-24 02:10:50 +00:00
|
|
|
#ifndef MAPVK_VSC_TO_VK
|
|
|
|
#define MAPVK_VSC_TO_VK 1
|
|
|
|
#define MAPVK_VK_TO_CHAR 2
|
|
|
|
#endif
|
2007-01-04 18:43:26 +00:00
|
|
|
|
2004-12-09 17:56:46 +00:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
|
2004-07-27 19:14:44 +00:00
|
|
|
#ifndef AC_SRC_ALPHA
|
|
|
|
#define AC_SRC_ALPHA 0x01
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WS_EX_LAYERED
|
|
|
|
#define WS_EX_LAYERED 0x00080000
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ULW_ALPHA
|
|
|
|
#define ULW_ALPHA 0x00000002
|
2004-12-09 17:56:46 +00:00
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
extern "C"
|
|
|
|
WINUSERAPI
|
|
|
|
BOOL WINAPI UpdateLayeredWindow(HWND hWnd, HDC hdcDst, POINT *pptDst,
|
|
|
|
SIZE *psize, HDC hdcSrc, POINT *pptSrc,
|
|
|
|
COLORREF crKey, BLENDFUNCTION *pblend,
|
|
|
|
DWORD dwFlags);
|
|
|
|
#endif
|
2004-12-09 17:56:46 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2006-03-17 21:42:28 +00:00
|
|
|
|
|
|
|
#ifdef WINCE
|
|
|
|
static PRBool gSoftKeyMenuBar = PR_FALSE;
|
|
|
|
static PRBool gOverrideHWKeys = PR_TRUE;
|
|
|
|
|
|
|
|
typedef BOOL (__stdcall *UnregisterFunc1Proc)( UINT, UINT );
|
|
|
|
static UnregisterFunc1Proc gProcUnregisterFunc = NULL;
|
|
|
|
static HINSTANCE gCoreDll = NULL;
|
|
|
|
|
|
|
|
UINT gHardwareKeys[][2] =
|
|
|
|
{
|
|
|
|
{ 0xc1, MOD_WIN },
|
|
|
|
{ 0xc2, MOD_WIN },
|
|
|
|
{ 0xc3, MOD_WIN },
|
|
|
|
{ 0xc4, MOD_WIN },
|
|
|
|
{ 0xc5, MOD_WIN },
|
|
|
|
{ 0xc6, MOD_WIN },
|
|
|
|
|
|
|
|
{ 0x72, 0 },// Answer - 0x72 Modifier - 0
|
|
|
|
{ 0x73, 0 },// Hangup - 0x73 Modifier - 0
|
|
|
|
{ 0x74, 0 },//
|
|
|
|
{ 0x75, 0 },// Volume Up - 0x75 Modifier - 0
|
|
|
|
{ 0x76, 0 },// Volume Down - 0x76 Modifier - 0
|
|
|
|
{ 0, 0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static void MapHardwareButtons(HWND window)
|
|
|
|
{
|
|
|
|
if (!window)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// handle hardware buttons so that they broadcast into our
|
|
|
|
// application. the following code is based on an article
|
|
|
|
// on the Pocket PC Developer Network:
|
|
|
|
//
|
|
|
|
// http://www.pocketpcdn.com/articles/handle_hardware_keys.html
|
|
|
|
|
|
|
|
if (gOverrideHWKeys)
|
|
|
|
{
|
|
|
|
if (!gProcUnregisterFunc)
|
|
|
|
{
|
|
|
|
gCoreDll = LoadLibrary(_T("coredll.dll")); // leak
|
|
|
|
|
|
|
|
if (gCoreDll)
|
|
|
|
gProcUnregisterFunc = (UnregisterFunc1Proc)GetProcAddress( gCoreDll, _T("UnregisterFunc1"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gProcUnregisterFunc)
|
|
|
|
{
|
|
|
|
for (int i=0; gHardwareKeys[i][0]; i++)
|
|
|
|
{
|
|
|
|
UINT mod = gHardwareKeys[i][1];
|
|
|
|
UINT kc = gHardwareKeys[i][0];
|
|
|
|
|
|
|
|
gProcUnregisterFunc(mod, kc);
|
|
|
|
RegisterHotKey(window, kc, mod, kc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void UnmapHardwareButtons()
|
|
|
|
{
|
|
|
|
if (!gProcUnregisterFunc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (int i=0; gHardwareKeys[i][0]; i++)
|
|
|
|
{
|
|
|
|
UINT mod = gHardwareKeys[i][1];
|
|
|
|
UINT kc = gHardwareKeys[i][0];
|
|
|
|
|
|
|
|
gProcUnregisterFunc(mod, kc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-17 17:42:20 +00:00
|
|
|
void CreateSoftKeyMenuBar(HWND wnd)
|
2006-03-17 21:42:28 +00:00
|
|
|
{
|
|
|
|
if (!wnd)
|
2006-04-17 17:42:20 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
static HWND gSoftKeyMenuBar = nsnull;
|
|
|
|
|
|
|
|
if (gSoftKeyMenuBar != nsnull)
|
|
|
|
return;
|
2006-03-17 21:42:28 +00:00
|
|
|
|
|
|
|
SHMENUBARINFO mbi;
|
|
|
|
ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
|
|
|
|
mbi.cbSize = sizeof(SHMENUBARINFO);
|
|
|
|
mbi.hwndParent = wnd;
|
|
|
|
|
|
|
|
// On windows ce smartphone, events never occur if the
|
|
|
|
// menubar is empty. This doesn't work:
|
|
|
|
// mbi.dwFlags = SHCMBF_EMPTYBAR;
|
|
|
|
|
|
|
|
mbi.nToolBarId = IDC_DUMMY_CE_MENUBAR;
|
|
|
|
mbi.hInstRes = GetModuleHandle(NULL);
|
|
|
|
|
|
|
|
if (!SHCreateMenuBar(&mbi))
|
2006-04-17 17:42:20 +00:00
|
|
|
return;
|
2006-03-17 21:42:28 +00:00
|
|
|
|
2006-04-25 18:34:31 +00:00
|
|
|
SetWindowPos(mbi.hwndMB, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE);
|
2006-03-17 21:42:28 +00:00
|
|
|
|
|
|
|
SendMessage(mbi.hwndMB, SHCMBM_OVERRIDEKEY, VK_TBACK,
|
|
|
|
MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY,
|
|
|
|
SHMBOF_NODEFAULT | SHMBOF_NOTIFY));
|
|
|
|
|
|
|
|
SendMessage(mbi.hwndMB, SHCMBM_OVERRIDEKEY, VK_TSOFT1,
|
|
|
|
MAKELPARAM (SHMBOF_NODEFAULT | SHMBOF_NOTIFY,
|
|
|
|
SHMBOF_NODEFAULT | SHMBOF_NOTIFY));
|
|
|
|
|
|
|
|
|
|
|
|
SendMessage(mbi.hwndMB, SHCMBM_OVERRIDEKEY, VK_TSOFT2,
|
|
|
|
MAKELPARAM (SHMBOF_NODEFAULT | SHMBOF_NOTIFY,
|
|
|
|
SHMBOF_NODEFAULT | SHMBOF_NOTIFY));
|
|
|
|
|
2006-04-17 17:42:20 +00:00
|
|
|
gSoftKeyMenuBar = mbi.hwndMB;
|
2006-03-17 21:42:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-03-15 22:13:12 +00:00
|
|
|
static PRBool IsCursorTranslucencySupported() {
|
2005-03-16 16:36:15 +00:00
|
|
|
static PRBool didCheck = PR_FALSE;
|
|
|
|
static PRBool isSupported = PR_FALSE;
|
2005-03-15 22:13:12 +00:00
|
|
|
if (!didCheck) {
|
|
|
|
didCheck = PR_TRUE;
|
|
|
|
// Cursor translucency is supported on Windows XP and newer
|
|
|
|
OSVERSIONINFO osversion;
|
|
|
|
memset(&osversion, 0, sizeof(OSVERSIONINFO));
|
|
|
|
osversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
|
|
|
if (GetVersionEx(&osversion))
|
|
|
|
isSupported = osversion.dwMajorVersion > 5 || // Newer Windows versions
|
|
|
|
osversion.dwMajorVersion == 5 &&
|
|
|
|
osversion.dwMinorVersion >= 1; // WinXP, Server 2003
|
|
|
|
}
|
|
|
|
|
|
|
|
return isSupported;
|
|
|
|
}
|
|
|
|
|
2004-12-09 17:56:46 +00:00
|
|
|
|
2005-04-13 05:52:02 +00:00
|
|
|
static PRBool IsWin2k()
|
|
|
|
{
|
|
|
|
static PRBool didCheck = PR_FALSE;
|
|
|
|
static PRBool isWin2k = PR_FALSE;
|
|
|
|
|
|
|
|
if (!didCheck) {
|
|
|
|
didCheck = PR_TRUE;
|
|
|
|
OSVERSIONINFO versionInfo;
|
|
|
|
|
|
|
|
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
|
|
|
if (::GetVersionEx(&versionInfo))
|
|
|
|
isWin2k = versionInfo.dwMajorVersion == 5 &&
|
|
|
|
versionInfo.dwMinorVersion == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return isWin2k;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-16 01:58:17 +00:00
|
|
|
// Pick some random timer ID. Is there a better way?
|
|
|
|
#define NS_FLASH_TIMER_ID 0x011231984
|
|
|
|
|
1999-07-09 19:41:46 +00:00
|
|
|
static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
|
|
|
|
static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
|
1999-03-23 21:26:20 +00:00
|
|
|
|
2001-11-29 09:41:19 +00:00
|
|
|
// When we build we are currently (11/27/01) setting the WINVER to 0x0400
|
|
|
|
// Which means we do not compile in the system resource for the HAND cursor
|
|
|
|
// this enables us still define the resource and if it isn't there then we will
|
|
|
|
// get our own hand cursor.
|
|
|
|
// 32649 is the resource number as defined by WINUSER.H for this cursor
|
|
|
|
// if the resource is defined by the build env. then it will find it when asked
|
|
|
|
// if not, then we get our own cursor.
|
|
|
|
#ifndef IDC_HAND
|
|
|
|
#define IDC_HAND MAKEINTRESOURCE(32649)
|
|
|
|
#endif
|
|
|
|
|
2002-01-09 01:30:06 +00:00
|
|
|
static const char *sScreenManagerContractID = "@mozilla.org/gfx/screenmanager;1";
|
|
|
|
|
2000-05-11 13:39:17 +00:00
|
|
|
////////////////////////////////////////////////////
|
|
|
|
// Manager for Registering and unregistering OLE
|
|
|
|
// This is needed for drag & drop & Clipboard support
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
class OleRegisterMgr {
|
|
|
|
public:
|
|
|
|
~OleRegisterMgr();
|
|
|
|
protected:
|
|
|
|
OleRegisterMgr();
|
|
|
|
|
|
|
|
static OleRegisterMgr mSingleton;
|
|
|
|
};
|
|
|
|
OleRegisterMgr OleRegisterMgr::mSingleton;
|
|
|
|
|
|
|
|
OleRegisterMgr::OleRegisterMgr()
|
|
|
|
{
|
|
|
|
//DWORD dwVer = ::OleBuildVersion();
|
|
|
|
|
2000-05-12 14:01:17 +00:00
|
|
|
if (FAILED(::OleInitialize(NULL))) {
|
2000-05-11 13:39:17 +00:00
|
|
|
NS_ASSERTION(0, "***** OLE has not been initialized!\n");
|
|
|
|
} else {
|
2001-06-20 05:48:45 +00:00
|
|
|
#ifdef DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
//printf("***** OLE has been initialized!\n");
|
2001-06-20 05:48:45 +00:00
|
|
|
#endif
|
2000-05-11 13:39:17 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2000-05-11 13:39:17 +00:00
|
|
|
OleRegisterMgr::~OleRegisterMgr()
|
|
|
|
{
|
2001-06-20 05:48:45 +00:00
|
|
|
#ifdef DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
//printf("***** OLE has been Uninitialized!\n");
|
2001-06-20 05:48:45 +00:00
|
|
|
#endif
|
2000-05-11 13:39:17 +00:00
|
|
|
::OleUninitialize();
|
|
|
|
}
|
|
|
|
|
2000-04-28 20:27:18 +00:00
|
|
|
////////////////////////////////////////////////////
|
2004-07-09 21:39:16 +00:00
|
|
|
// nsWindow Class static variable definitions
|
2000-04-28 20:27:18 +00:00
|
|
|
////////////////////////////////////////////////////
|
2004-09-08 19:30:22 +00:00
|
|
|
PRUint32 nsWindow::sInstanceCount = 0;
|
|
|
|
|
|
|
|
PRBool nsWindow::sIMEIsComposing = PR_FALSE;
|
|
|
|
PRBool nsWindow::sIMEIsStatusChanged = PR_FALSE;
|
|
|
|
|
|
|
|
DWORD nsWindow::sIMEProperty = 0;
|
|
|
|
nsString* nsWindow::sIMECompUnicode = NULL;
|
|
|
|
PRUint8* nsWindow::sIMEAttributeArray = NULL;
|
|
|
|
PRInt32 nsWindow::sIMEAttributeArrayLength = 0;
|
|
|
|
PRInt32 nsWindow::sIMEAttributeArraySize = 0;
|
|
|
|
PRUint32* nsWindow::sIMECompClauseArray = NULL;
|
|
|
|
PRInt32 nsWindow::sIMECompClauseArrayLength = 0;
|
|
|
|
PRInt32 nsWindow::sIMECompClauseArraySize = 0;
|
|
|
|
long nsWindow::sIMECursorPosition = 0;
|
|
|
|
PRUnichar* nsWindow::sIMEReconvertUnicode = NULL;
|
|
|
|
|
|
|
|
RECT* nsWindow::sIMECompCharPos = nsnull;
|
2005-02-01 19:24:59 +00:00
|
|
|
PRInt32 nsWindow::sIMECaretHeight = 0;
|
2004-09-08 19:30:22 +00:00
|
|
|
|
2000-04-28 20:27:18 +00:00
|
|
|
BOOL nsWindow::sIsRegistered = FALSE;
|
2002-01-05 23:50:52 +00:00
|
|
|
BOOL nsWindow::sIsPopupClassRegistered = FALSE;
|
2004-07-09 21:39:16 +00:00
|
|
|
UINT nsWindow::uWM_MSIME_MOUSE = 0; // mouse message for MSIME
|
2002-02-27 02:18:12 +00:00
|
|
|
UINT nsWindow::uWM_HEAP_DUMP = 0; // Heap Dump to a file
|
2002-02-16 01:44:54 +00:00
|
|
|
|
2005-04-13 05:52:02 +00:00
|
|
|
HCURSOR nsWindow::gHCursor = NULL;
|
|
|
|
imgIContainer* nsWindow::gCursorImgContainer = nsnull;
|
|
|
|
|
2002-10-01 03:04:22 +00:00
|
|
|
|
2001-09-25 08:34:42 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
BOOL nsWindow::gIsAccessibilityOn = FALSE;
|
|
|
|
#endif
|
2000-04-28 20:27:18 +00:00
|
|
|
nsWindow* nsWindow::gCurrentWindow = nsnull;
|
|
|
|
////////////////////////////////////////////////////
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
|
2000-04-28 20:27:18 +00:00
|
|
|
////////////////////////////////////////////////////
|
2004-07-09 21:39:16 +00:00
|
|
|
// Rollup Listener - static variable definitions
|
1999-09-21 11:22:21 +00:00
|
|
|
////////////////////////////////////////////////////
|
1999-09-30 14:36:17 +00:00
|
|
|
static nsIRollupListener * gRollupListener = nsnull;
|
|
|
|
static nsIWidget * gRollupWidget = nsnull;
|
|
|
|
static PRBool gRollupConsumeRollupEvent = PR_FALSE;
|
2001-05-25 10:53:32 +00:00
|
|
|
|
|
|
|
// Hook Data Memebers for Dropdowns
|
|
|
|
//
|
2004-09-03 08:44:23 +00:00
|
|
|
// gProcessHook Tells the hook methods whether they should be
|
2001-05-25 10:53:32 +00:00
|
|
|
// processing the hook messages
|
|
|
|
//
|
|
|
|
static HHOOK gMsgFilterHook = NULL;
|
|
|
|
static HHOOK gCallProcHook = NULL;
|
|
|
|
static HHOOK gCallMouseHook = NULL;
|
|
|
|
static PRPackedBool gProcessHook = PR_FALSE;
|
2001-06-14 02:08:39 +00:00
|
|
|
static UINT gRollupMsgId = 0;
|
2005-01-14 19:23:06 +00:00
|
|
|
static HWND gRollupMsgWnd = NULL;
|
2001-06-14 02:08:39 +00:00
|
|
|
static UINT gHookTimerId = 0;
|
2000-04-28 20:27:18 +00:00
|
|
|
////////////////////////////////////////////////////
|
1999-09-21 11:22:21 +00:00
|
|
|
|
2000-04-28 20:27:18 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////
|
2004-09-03 08:44:23 +00:00
|
|
|
// Mouse Clicks - static variable definitions
|
2000-04-28 20:27:18 +00:00
|
|
|
// for figuring out 1 - 3 Clicks
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
static POINT gLastMousePoint;
|
2001-12-06 02:55:06 +00:00
|
|
|
static POINT gLastMouseMovePoint;
|
2000-12-13 11:53:10 +00:00
|
|
|
static LONG gLastMouseDownTime = 0L;
|
|
|
|
static LONG gLastClickCount = 0L;
|
2004-07-09 21:39:16 +00:00
|
|
|
static BYTE gLastMouseButton = 0;
|
2000-04-28 20:27:18 +00:00
|
|
|
////////////////////////////////////////////////////
|
1998-05-29 22:44:13 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// The last user input event time in microseconds. If there are any pending
|
2002-10-01 03:04:22 +00:00
|
|
|
// native toolkit input events it returns the current time. The value is
|
|
|
|
// compatible with PR_IntervalToMicroseconds(PR_IntervalNow()).
|
|
|
|
static PRUint32 gLastInputEventTime = 0;
|
|
|
|
|
2004-04-01 22:51:46 +00:00
|
|
|
static int gTrimOnMinimize = 2; // uninitialized, but still true
|
|
|
|
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
#if 0
|
|
|
|
static PRBool is_vk_down(int vk)
|
|
|
|
{
|
|
|
|
SHORT st = GetKeyState(vk);
|
2001-06-20 05:48:45 +00:00
|
|
|
#ifdef DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("is_vk_down vk=%x st=%x\n",vk, st);
|
2001-06-20 05:48:45 +00:00
|
|
|
#endif
|
2004-03-25 19:43:59 +00:00
|
|
|
return (st < 0);
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
}
|
|
|
|
#define IS_VK_DOWN is_vk_down
|
|
|
|
#else
|
2004-03-25 19:43:59 +00:00
|
|
|
#define IS_VK_DOWN(a) (GetKeyState(a) < 0)
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
#endif
|
|
|
|
|
1998-09-02 21:14:45 +00:00
|
|
|
|
1999-08-06 07:42:35 +00:00
|
|
|
//
|
|
|
|
// input method offsets
|
|
|
|
//
|
2004-09-03 08:44:23 +00:00
|
|
|
#define IME_X_OFFSET 0
|
|
|
|
#define IME_Y_OFFSET 0
|
1999-08-06 07:42:35 +00:00
|
|
|
|
2006-02-10 21:55:02 +00:00
|
|
|
|
|
|
|
|
1999-11-15 20:57:41 +00:00
|
|
|
#define IS_IME_CODEPAGE(cp) ((932==(cp))||(936==(cp))||(949==(cp))||(950==(cp)))
|
|
|
|
|
2002-12-06 03:41:43 +00:00
|
|
|
//
|
|
|
|
// App Command messages for IntelliMouse and Natural Keyboard Pro
|
|
|
|
//
|
|
|
|
// These messages are not included in Visual C++ 6.0, but are in 7.0
|
|
|
|
//
|
|
|
|
#ifndef WM_APPCOMMAND
|
|
|
|
#define WM_APPCOMMAND 0x0319
|
2006-04-19 04:25:16 +00:00
|
|
|
#endif
|
2002-12-06 03:41:43 +00:00
|
|
|
|
2006-04-19 04:25:16 +00:00
|
|
|
#ifndef APPCOMMAND_BROWSER_BACKWARD
|
2002-12-06 03:41:43 +00:00
|
|
|
#define APPCOMMAND_BROWSER_BACKWARD 1
|
|
|
|
#define APPCOMMAND_BROWSER_FORWARD 2
|
|
|
|
#define APPCOMMAND_BROWSER_REFRESH 3
|
|
|
|
#define APPCOMMAND_BROWSER_STOP 4
|
2006-12-01 11:09:53 +00:00
|
|
|
#define APPCOMMAND_BROWSER_SEARCH 5
|
|
|
|
#define APPCOMMAND_BROWSER_FAVORITES 6
|
|
|
|
#define APPCOMMAND_BROWSER_HOME 7
|
2002-12-06 03:41:43 +00:00
|
|
|
// keep these around in case we want them later
|
|
|
|
//#define APPCOMMAND_VOLUME_MUTE 8
|
|
|
|
//#define APPCOMMAND_VOLUME_DOWN 9
|
|
|
|
//#define APPCOMMAND_VOLUME_UP 10
|
|
|
|
//#define APPCOMMAND_MEDIA_NEXTTRACK 11
|
|
|
|
//#define APPCOMMAND_MEDIA_PREVIOUSTRACK 12
|
|
|
|
//#define APPCOMMAND_MEDIA_STOP 13
|
|
|
|
//#define APPCOMMAND_MEDIA_PLAY_PAUSE 14
|
|
|
|
//#define APPCOMMAND_LAUNCH_MAIL 15
|
|
|
|
//#define APPCOMMAND_LAUNCH_MEDIA_SELECT 16
|
|
|
|
//#define APPCOMMAND_LAUNCH_APP1 17
|
|
|
|
//#define APPCOMMAND_LAUNCH_APP2 18
|
|
|
|
//#define APPCOMMAND_BASS_DOWN 19
|
|
|
|
//#define APPCOMMAND_BASS_BOOST 20
|
|
|
|
//#define APPCOMMAND_BASS_UP 21
|
|
|
|
//#define APPCOMMAND_TREBLE_DOWN 22
|
|
|
|
//#define APPCOMMAND_TREBLE_UP 23
|
|
|
|
|
|
|
|
//#define FAPPCOMMAND_MOUSE 0x8000
|
|
|
|
//#define FAPPCOMMAND_KEY 0
|
|
|
|
//#define FAPPCOMMAND_OEM 0x1000
|
|
|
|
#define FAPPCOMMAND_MASK 0xF000
|
|
|
|
|
|
|
|
#define GET_APPCOMMAND_LPARAM(lParam) ((short)(HIWORD(lParam) & ~FAPPCOMMAND_MASK))
|
|
|
|
//#define GET_DEVICE_LPARAM(lParam) ((WORD)(HIWORD(lParam) & FAPPCOMMAND_MASK))
|
|
|
|
//#define GET_MOUSEORKEY_LPARAM GET_DEVICE_LPARAM
|
|
|
|
//#define GET_FLAGS_LPARAM(lParam) (LOWORD(lParam))
|
|
|
|
//#define GET_KEYSTATE_LPARAM(lParam) GET_FLAGS_LPARAM(lParam)
|
|
|
|
|
2006-04-19 04:25:16 +00:00
|
|
|
#endif // #ifndef APPCOMMAND_BROWSER_BACKWARD
|
2000-01-07 00:34:34 +00:00
|
|
|
|
2001-11-16 01:58:17 +00:00
|
|
|
/* This object maintains a correlation between attention timers and the
|
|
|
|
windows to which they belong. It's lighter than a hashtable (expected usage
|
|
|
|
is really just one at a time) and allows nsWindow::GetNSWindowPtr
|
|
|
|
to remain private. */
|
|
|
|
class nsAttentionTimerMonitor {
|
|
|
|
public:
|
|
|
|
nsAttentionTimerMonitor() : mHeadTimer(0) { }
|
|
|
|
~nsAttentionTimerMonitor() {
|
|
|
|
TimerInfo *current, *next;
|
|
|
|
for (current = mHeadTimer; current; current = next) {
|
|
|
|
next = current->next;
|
|
|
|
delete current;
|
|
|
|
}
|
|
|
|
}
|
2004-02-11 03:46:30 +00:00
|
|
|
void AddTimer(HWND timerWindow, HWND flashWindow, PRInt32 maxFlashCount, UINT timerID) {
|
2001-11-16 01:58:17 +00:00
|
|
|
TimerInfo *info;
|
|
|
|
PRBool newInfo = PR_FALSE;
|
|
|
|
info = FindInfo(timerWindow);
|
|
|
|
if (!info) {
|
|
|
|
info = new TimerInfo;
|
|
|
|
newInfo = PR_TRUE;
|
|
|
|
}
|
|
|
|
if (info) {
|
|
|
|
info->timerWindow = timerWindow;
|
|
|
|
info->flashWindow = flashWindow;
|
2004-02-11 03:46:30 +00:00
|
|
|
info->maxFlashCount = maxFlashCount;
|
|
|
|
info->flashCount = 0;
|
2001-11-16 01:58:17 +00:00
|
|
|
info->timerID = timerID;
|
2002-06-29 12:31:15 +00:00
|
|
|
info->hasFlashed = PR_FALSE;
|
2001-11-16 01:58:17 +00:00
|
|
|
info->next = 0;
|
|
|
|
if (newInfo)
|
|
|
|
AppendTimer(info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
HWND GetFlashWindowFor(HWND timerWindow) {
|
|
|
|
TimerInfo *info = FindInfo(timerWindow);
|
|
|
|
return info ? info->flashWindow : 0;
|
|
|
|
}
|
2004-02-11 03:46:30 +00:00
|
|
|
PRInt32 GetMaxFlashCount(HWND timerWindow) {
|
|
|
|
TimerInfo *info = FindInfo(timerWindow);
|
|
|
|
return info ? info->maxFlashCount : -1;
|
|
|
|
}
|
|
|
|
PRInt32 GetFlashCount(HWND timerWindow) {
|
|
|
|
TimerInfo *info = FindInfo(timerWindow);
|
|
|
|
return info ? info->flashCount : -1;
|
|
|
|
}
|
|
|
|
void IncrementFlashCount(HWND timerWindow) {
|
|
|
|
TimerInfo *info = FindInfo(timerWindow);
|
|
|
|
++(info->flashCount);
|
|
|
|
}
|
2001-11-16 01:58:17 +00:00
|
|
|
void KillTimer(HWND timerWindow) {
|
|
|
|
TimerInfo *info = FindInfo(timerWindow);
|
|
|
|
if (info) {
|
|
|
|
// make sure it's unflashed and kill the timer
|
2005-02-23 07:07:51 +00:00
|
|
|
|
2002-06-29 12:31:15 +00:00
|
|
|
if (info->hasFlashed)
|
|
|
|
::FlashWindow(info->flashWindow, FALSE);
|
2005-06-08 16:48:44 +00:00
|
|
|
|
2001-11-16 01:58:17 +00:00
|
|
|
::KillTimer(info->timerWindow, info->timerID);
|
|
|
|
RemoveTimer(info);
|
|
|
|
delete info;
|
|
|
|
}
|
|
|
|
}
|
2002-06-29 12:31:15 +00:00
|
|
|
void SetFlashed(HWND timerWindow) {
|
|
|
|
TimerInfo *info = FindInfo(timerWindow);
|
|
|
|
if (info)
|
|
|
|
info->hasFlashed = PR_TRUE;
|
|
|
|
}
|
2001-11-16 01:58:17 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
struct TimerInfo {
|
|
|
|
HWND timerWindow,
|
|
|
|
flashWindow;
|
|
|
|
UINT timerID;
|
2004-02-11 03:46:30 +00:00
|
|
|
PRInt32 maxFlashCount;
|
|
|
|
PRInt32 flashCount;
|
2002-06-29 12:31:15 +00:00
|
|
|
PRBool hasFlashed;
|
2001-11-16 01:58:17 +00:00
|
|
|
TimerInfo *next;
|
|
|
|
};
|
|
|
|
TimerInfo *FindInfo(HWND timerWindow) {
|
|
|
|
TimerInfo *scan;
|
|
|
|
for (scan = mHeadTimer; scan; scan = scan->next)
|
|
|
|
if (scan->timerWindow == timerWindow)
|
|
|
|
break;
|
|
|
|
return scan;
|
|
|
|
}
|
|
|
|
void AppendTimer(TimerInfo *info) {
|
|
|
|
if (!mHeadTimer)
|
|
|
|
mHeadTimer = info;
|
|
|
|
else {
|
|
|
|
TimerInfo *scan, *last;
|
|
|
|
for (scan = mHeadTimer; scan; scan = scan->next)
|
|
|
|
last = scan;
|
|
|
|
last->next = info;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void RemoveTimer(TimerInfo *info) {
|
|
|
|
TimerInfo *scan, *last = 0;
|
|
|
|
for (scan = mHeadTimer; scan && scan != info; scan = scan->next)
|
|
|
|
last = scan;
|
|
|
|
if (scan) {
|
|
|
|
if (last)
|
|
|
|
last->next = scan->next;
|
|
|
|
else
|
|
|
|
mHeadTimer = scan->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TimerInfo *mHeadTimer;
|
|
|
|
};
|
|
|
|
|
|
|
|
static nsAttentionTimerMonitor *gAttentionTimerMonitor = 0;
|
|
|
|
|
2005-08-13 18:00:33 +00:00
|
|
|
HWND nsWindow::GetTopLevelHWND(HWND aWnd, PRBool aStopOnFirstTopLevel)
|
|
|
|
{
|
|
|
|
HWND curWnd = aWnd;
|
|
|
|
HWND topWnd = NULL;
|
|
|
|
|
|
|
|
while (curWnd)
|
|
|
|
{
|
|
|
|
topWnd = curWnd;
|
|
|
|
|
2005-08-14 04:01:58 +00:00
|
|
|
#ifndef WINCE
|
2005-08-13 18:00:33 +00:00
|
|
|
if (aStopOnFirstTopLevel)
|
|
|
|
{
|
2006-04-04 20:57:13 +00:00
|
|
|
DWORD style = ::GetWindowLongW(curWnd, GWL_STYLE);
|
2005-08-13 18:00:33 +00:00
|
|
|
|
|
|
|
if (!(style & WS_CHILDWINDOW)) // first top-level window
|
|
|
|
break;
|
|
|
|
}
|
2005-08-14 04:01:58 +00:00
|
|
|
#endif
|
2005-08-13 18:00:33 +00:00
|
|
|
|
|
|
|
curWnd = ::GetParent(curWnd); // Parent or owner (if has no parent)
|
|
|
|
}
|
|
|
|
|
|
|
|
return topWnd;
|
|
|
|
}
|
|
|
|
|
2002-06-04 17:47:54 +00:00
|
|
|
// Code to dispatch WM_SYSCOLORCHANGE message to all child windows.
|
2004-09-03 08:44:23 +00:00
|
|
|
// WM_SYSCOLORCHANGE is only sent to top-level windows, but the
|
2002-06-04 17:47:54 +00:00
|
|
|
// cross platform API requires that NS_SYSCOLORCHANGE message be sent to
|
|
|
|
// all child windows as well. When running in an embedded application
|
2004-09-03 08:44:23 +00:00
|
|
|
// we may not receive a WM_SYSCOLORCHANGE message because the top
|
2002-06-04 17:47:54 +00:00
|
|
|
// level window is owned by the embeddor. Note: this code can be used to
|
2004-09-03 08:44:23 +00:00
|
|
|
// dispatch other global messages (i.e messages that must be sent to all
|
|
|
|
// nsIWidget instances.
|
2002-06-04 17:47:54 +00:00
|
|
|
|
|
|
|
// Enumerate all child windows sending aMsg to each of them
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
BOOL CALLBACK nsWindow::BroadcastMsgToChildren(HWND aWnd, LPARAM aMsg)
|
2002-06-04 17:47:54 +00:00
|
|
|
{
|
2006-04-04 20:57:13 +00:00
|
|
|
WNDPROC winProc = (WNDPROC)::GetWindowLongW(aWnd, GWL_WNDPROC);
|
2004-09-03 08:44:23 +00:00
|
|
|
if (winProc == &nsWindow::WindowProc) {
|
|
|
|
// it's one of our windows so go ahead and send a message to it
|
2006-04-04 20:57:13 +00:00
|
|
|
::CallWindowProcW(winProc, aWnd, aMsg, 0, 0);
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
2002-06-04 17:47:54 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Enumerate all top level windows specifying that the children of each
|
2004-09-03 08:44:23 +00:00
|
|
|
// top level window should be enumerated. Do *not* send the message to
|
|
|
|
// each top level window since it is assumed that the toolkit will send
|
|
|
|
// aMsg to them directly.
|
2002-06-04 17:47:54 +00:00
|
|
|
|
|
|
|
BOOL CALLBACK nsWindow::BroadcastMsg(HWND aTopWindow, LPARAM aMsg)
|
|
|
|
{
|
|
|
|
// Iterate each of aTopWindows child windows sending the aMsg
|
|
|
|
// to each of them.
|
|
|
|
EnumChildWindows(aTopWindow, nsWindow::BroadcastMsgToChildren, aMsg);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This method is called from nsToolkit::WindowProc to forward global
|
|
|
|
// messages which need to be dispatched to all child windows.
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
void nsWindow::GlobalMsgWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
2002-06-04 17:47:54 +00:00
|
|
|
{
|
|
|
|
switch (msg) {
|
|
|
|
case WM_SYSCOLORCHANGE:
|
|
|
|
// System color changes are posted to top-level windows only.
|
2004-09-03 08:44:23 +00:00
|
|
|
// The NS_SYSCOLORCHANGE must be dispatched to all child
|
|
|
|
// windows as well.
|
2002-06-04 17:47:54 +00:00
|
|
|
::EnumThreadWindows(GetCurrentThreadId(), nsWindow::BroadcastMsg, msg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// End of the methods to dispatch global messages
|
|
|
|
|
1999-11-15 20:57:41 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// nsISupport stuff
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_IMPL_ADDREF(nsWindow)
|
|
|
|
NS_IMPL_RELEASE(nsWindow)
|
2007-07-04 02:15:31 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
1999-11-15 20:57:41 +00:00
|
|
|
{
|
2007-07-04 02:15:31 +00:00
|
|
|
NS_PRECONDITION(aInstancePtr, "null out param");
|
1999-11-15 20:57:41 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIKBStateControl))) {
|
2007-07-04 02:15:31 +00:00
|
|
|
*aInstancePtr = NS_STATIC_CAST(nsIKBStateControl*, this);
|
|
|
|
NS_ADDREF(NS_STATIC_CAST(nsBaseWidget*, this));
|
2004-09-03 08:44:23 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-11-15 20:57:41 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
return nsBaseWidget::QueryInterface(aIID,aInstancePtr);
|
1999-11-15 20:57:41 +00:00
|
|
|
}
|
1998-11-04 21:43:47 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// nsWindow constructor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2005-07-15 02:35:19 +00:00
|
|
|
nsWindow::nsWindow() : nsBaseWidget()
|
2001-08-17 03:13:07 +00:00
|
|
|
#else
|
|
|
|
nsWindow::nsWindow() : nsBaseWidget()
|
|
|
|
#endif
|
1998-11-04 21:43:47 +00:00
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
mWnd = 0;
|
2006-01-31 01:04:41 +00:00
|
|
|
mPaintDC = 0;
|
2004-09-03 08:44:23 +00:00
|
|
|
mPrevWndProc = NULL;
|
|
|
|
mBackground = ::GetSysColor(COLOR_BTNFACE);
|
|
|
|
mBrush = ::CreateSolidBrush(NSRGB_2_COLOREF(mBackground));
|
|
|
|
mForeground = ::GetSysColor(COLOR_WINDOWTEXT);
|
|
|
|
mIsShiftDown = PR_FALSE;
|
|
|
|
mIsControlDown = PR_FALSE;
|
|
|
|
mIsAltDown = PR_FALSE;
|
|
|
|
mIsDestroying = PR_FALSE;
|
|
|
|
mOnDestroyCalled = PR_FALSE;
|
|
|
|
mDeferredPositioner = NULL;
|
|
|
|
mLastPoint.x = 0;
|
|
|
|
mLastPoint.y = 0;
|
|
|
|
mPreferredWidth = 0;
|
|
|
|
mPreferredHeight = 0;
|
|
|
|
mFont = nsnull;
|
|
|
|
mIsVisible = PR_FALSE;
|
|
|
|
mHas3DBorder = PR_FALSE;
|
2004-07-27 19:14:44 +00:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
mIsTranslucent = PR_FALSE;
|
2004-12-09 17:56:46 +00:00
|
|
|
mIsTopTranslucent = PR_FALSE;
|
2007-04-02 18:53:43 +00:00
|
|
|
#ifdef MOZ_CAIRO_GFX
|
|
|
|
mTranslucentSurface = nsnull;
|
|
|
|
#endif
|
2006-04-04 20:57:13 +00:00
|
|
|
mMemoryDC = NULL;
|
|
|
|
mMemoryBitmap = NULL;
|
|
|
|
mMemoryBits = NULL;
|
2004-07-27 19:14:44 +00:00
|
|
|
mAlphaMask = nsnull;
|
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
mWindowType = eWindowType_child;
|
|
|
|
mBorderStyle = eBorderStyle_default;
|
|
|
|
mUnicodeWidget = PR_TRUE;
|
|
|
|
mIsInMouseCapture = PR_FALSE;
|
|
|
|
mIsInMouseWheelProcessing = PR_FALSE;
|
|
|
|
mLastSize.width = 0;
|
|
|
|
mLastSize.height = 0;
|
|
|
|
mOldStyle = 0;
|
|
|
|
mOldExStyle = 0;
|
2005-04-21 20:53:00 +00:00
|
|
|
mPainting = 0;
|
2005-11-17 16:33:57 +00:00
|
|
|
mOldIMC = NULL;
|
2007-04-15 13:43:55 +00:00
|
|
|
mIMEEnabled = nsIKBStateControl::IME_STATUS_ENABLED;
|
2004-09-03 08:44:23 +00:00
|
|
|
|
|
|
|
mLeadByte = '\0';
|
|
|
|
mBlurEventSuppressionLevel = 0;
|
1999-11-29 21:14:43 +00:00
|
|
|
|
2000-08-04 21:43:29 +00:00
|
|
|
static BOOL gbInitGlobalValue = FALSE;
|
2004-09-03 08:44:23 +00:00
|
|
|
if (! gbInitGlobalValue) {
|
2000-08-04 21:43:29 +00:00
|
|
|
gbInitGlobalValue = TRUE;
|
|
|
|
gKeyboardLayout = GetKeyboardLayout(0);
|
|
|
|
|
|
|
|
// mouse message of MSIME98/2000
|
|
|
|
nsWindow::uWM_MSIME_MOUSE = ::RegisterWindowMessage(RWM_MOUSE);
|
2002-02-27 02:18:12 +00:00
|
|
|
|
|
|
|
// Heap dump
|
2005-02-23 07:07:51 +00:00
|
|
|
#ifndef WINCE
|
2002-02-27 02:18:12 +00:00
|
|
|
nsWindow::uWM_HEAP_DUMP = ::RegisterWindowMessage(kMozHeapDumpMessageString);
|
2005-02-23 07:07:51 +00:00
|
|
|
#endif
|
2000-08-04 21:43:29 +00:00
|
|
|
}
|
1999-03-19 23:36:20 +00:00
|
|
|
|
1999-06-17 23:23:11 +00:00
|
|
|
mNativeDragTarget = nsnull;
|
1999-10-02 00:13:23 +00:00
|
|
|
mIsTopWidgetWindow = PR_FALSE;
|
2004-12-09 19:01:35 +00:00
|
|
|
mLastKeyboardLayout = 0;
|
2003-03-14 23:35:18 +00:00
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
sInstanceCount++;
|
|
|
|
|
2005-07-24 19:36:18 +00:00
|
|
|
#ifdef WINCE
|
|
|
|
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
|
|
|
if (prefs) {
|
|
|
|
nsCOMPtr<nsIPrefBranch> prefBranch;
|
|
|
|
prefs->GetBranch(0, getter_AddRefs(prefBranch));
|
|
|
|
if (prefBranch)
|
|
|
|
{
|
|
|
|
prefBranch->GetBoolPref("config.wince.overrideHWKeys", &gOverrideHWKeys);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
1998-11-04 21:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-01 22:10:13 +00:00
|
|
|
HKL nsWindow::gKeyboardLayout = 0;
|
2004-12-09 19:01:35 +00:00
|
|
|
PRBool nsWindow::gSwitchKeyboardLayout = PR_FALSE;
|
2006-03-16 21:02:22 +00:00
|
|
|
static KeyboardLayout gKbdLayout;
|
1999-12-01 22:10:13 +00:00
|
|
|
|
1998-11-04 21:43:47 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// nsWindow destructor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsWindow::~nsWindow()
|
|
|
|
{
|
|
|
|
mIsDestroying = PR_TRUE;
|
|
|
|
if (gCurrentWindow == this) {
|
|
|
|
gCurrentWindow = nsnull;
|
|
|
|
}
|
|
|
|
|
2006-02-22 21:08:40 +00:00
|
|
|
MouseTrailer* mtrailer = nsToolkit::gMouseTrailer;
|
|
|
|
if (mtrailer) {
|
|
|
|
if (mtrailer->GetMouseTrailerWindow() == mWnd)
|
|
|
|
mtrailer->DestroyTimer();
|
|
|
|
|
|
|
|
if (mtrailer->GetCaptureWindow() == mWnd)
|
|
|
|
mtrailer->SetCaptureWindow(nsnull);
|
2005-12-02 12:08:32 +00:00
|
|
|
}
|
1998-11-04 21:43:47 +00:00
|
|
|
|
|
|
|
// If the widget was released without calling Destroy() then the native
|
|
|
|
// window still exists, and we need to destroy it
|
|
|
|
if (NULL != mWnd) {
|
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
//XXX Temporary: Should not be caching the font
|
|
|
|
delete mFont;
|
1999-06-29 20:31:22 +00:00
|
|
|
|
2005-04-13 05:52:02 +00:00
|
|
|
if (mCursor == -1) {
|
2006-02-23 09:36:43 +00:00
|
|
|
// A successfull SetCursor call will destroy the custom cursor, if it's ours
|
2005-04-13 05:52:02 +00:00
|
|
|
SetCursor(eCursor_standard);
|
|
|
|
}
|
|
|
|
|
1999-06-29 20:31:22 +00:00
|
|
|
//
|
|
|
|
// delete any of the IME structures that we allocated
|
|
|
|
//
|
2004-09-08 19:30:22 +00:00
|
|
|
sInstanceCount--;
|
|
|
|
if (sInstanceCount == 0) {
|
|
|
|
if (sIMECompUnicode)
|
|
|
|
delete sIMECompUnicode;
|
|
|
|
if (sIMEAttributeArray)
|
|
|
|
delete [] sIMEAttributeArray;
|
|
|
|
if (sIMECompClauseArray)
|
|
|
|
delete [] sIMECompClauseArray;
|
|
|
|
if (sIMEReconvertUnicode)
|
|
|
|
nsMemory::Free(sIMEReconvertUnicode);
|
2005-04-13 05:52:02 +00:00
|
|
|
|
|
|
|
NS_IF_RELEASE(gCursorImgContainer);
|
2004-09-08 19:30:22 +00:00
|
|
|
}
|
1999-11-01 21:53:06 +00:00
|
|
|
|
|
|
|
NS_IF_RELEASE(mNativeDragTarget);
|
2006-01-28 18:18:45 +00:00
|
|
|
|
1998-11-04 21:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-06-21 20:37:50 +00:00
|
|
|
NS_METHOD nsWindow::CaptureMouse(PRBool aCapture)
|
|
|
|
{
|
2006-02-22 21:08:40 +00:00
|
|
|
if (!nsToolkit::gMouseTrailer) {
|
|
|
|
NS_ERROR("nsWindow::CaptureMouse called after nsToolkit destroyed");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (aCapture) {
|
2006-02-22 21:08:40 +00:00
|
|
|
nsToolkit::gMouseTrailer->SetCaptureWindow(mWnd);
|
1999-09-09 13:38:30 +00:00
|
|
|
::SetCapture(mWnd);
|
1999-06-21 20:37:50 +00:00
|
|
|
} else {
|
2006-02-22 21:08:40 +00:00
|
|
|
nsToolkit::gMouseTrailer->SetCaptureWindow(NULL);
|
1999-09-09 13:38:30 +00:00
|
|
|
::ReleaseCapture();
|
1999-06-21 20:37:50 +00:00
|
|
|
}
|
1999-08-05 14:56:21 +00:00
|
|
|
mIsInMouseCapture = aCapture;
|
1999-06-21 20:37:50 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-05-14 21:34:08 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Default for height modification is to do nothing
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
PRInt32 nsWindow::GetHeight(PRInt32 aProposedHeight)
|
|
|
|
{
|
|
|
|
return(aProposedHeight);
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-05-13 03:39:08 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Deferred Window positioning
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-05-05 23:41:16 +00:00
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::BeginResizingChildren(void)
|
1998-05-13 03:39:08 +00:00
|
|
|
{
|
|
|
|
if (NULL == mDeferredPositioner)
|
|
|
|
mDeferredPositioner = ::BeginDeferWindowPos(1);
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-05-13 03:39:08 +00:00
|
|
|
}
|
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::EndResizingChildren(void)
|
1998-05-13 03:39:08 +00:00
|
|
|
{
|
|
|
|
if (NULL != mDeferredPositioner) {
|
|
|
|
::EndDeferWindowPos(mDeferredPositioner);
|
|
|
|
mDeferredPositioner = NULL;
|
|
|
|
}
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-05-13 03:39:08 +00:00
|
|
|
}
|
1998-05-05 23:41:16 +00:00
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect)
|
1998-05-05 23:41:16 +00:00
|
|
|
{
|
|
|
|
POINT point;
|
|
|
|
point.x = aOldRect.x;
|
|
|
|
point.y = aOldRect.y;
|
2004-09-03 08:44:23 +00:00
|
|
|
::ClientToScreen(mWnd, &point);
|
1998-05-05 23:41:16 +00:00
|
|
|
aNewRect.x = point.x;
|
|
|
|
aNewRect.y = point.y;
|
|
|
|
aNewRect.width = aOldRect.width;
|
|
|
|
aNewRect.height = aOldRect.height;
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-05-05 23:41:16 +00:00
|
|
|
}
|
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect)
|
1998-05-05 23:41:16 +00:00
|
|
|
{
|
|
|
|
POINT point;
|
|
|
|
point.x = aOldRect.x;
|
|
|
|
point.y = aOldRect.y;
|
2004-09-03 08:44:23 +00:00
|
|
|
::ScreenToClient(mWnd, &point);
|
1998-05-05 23:41:16 +00:00
|
|
|
aNewRect.x = point.x;
|
|
|
|
aNewRect.y = point.y;
|
|
|
|
aNewRect.width = aOldRect.width;
|
|
|
|
aNewRect.height = aOldRect.height;
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
1998-05-04 19:25:25 +00:00
|
|
|
|
2005-12-02 12:08:32 +00:00
|
|
|
LPARAM nsWindow::lParamToScreen(LPARAM lParam)
|
|
|
|
{
|
|
|
|
POINT pt;
|
|
|
|
pt.x = GET_X_LPARAM(lParam);
|
|
|
|
pt.y = GET_Y_LPARAM(lParam);
|
|
|
|
::ClientToScreen(mWnd, &pt);
|
|
|
|
return MAKELPARAM(pt.x, pt.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
LPARAM nsWindow::lParamToClient(LPARAM lParam)
|
|
|
|
{
|
|
|
|
POINT pt;
|
|
|
|
pt.x = GET_X_LPARAM(lParam);
|
|
|
|
pt.y = GET_Y_LPARAM(lParam);
|
|
|
|
::ScreenToClient(mWnd, &pt);
|
|
|
|
return MAKELPARAM(pt.x, pt.y);
|
|
|
|
}
|
|
|
|
|
1998-04-24 23:09:11 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Initialize an event to dispatch
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2004-01-12 08:25:18 +00:00
|
|
|
void nsWindow::InitEvent(nsGUIEvent& event, nsPoint* aPoint)
|
1998-04-24 23:09:11 +00:00
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_ADDREF(event.widget);
|
1998-04-24 23:09:11 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (nsnull == aPoint) { // use the point from the event
|
|
|
|
// get the message position in client coordinates and in twips
|
2005-08-31 20:23:09 +00:00
|
|
|
if (mWnd != NULL) {
|
1998-04-24 23:09:11 +00:00
|
|
|
|
2005-08-31 20:23:09 +00:00
|
|
|
DWORD pos = ::GetMessagePos();
|
|
|
|
POINT cpos;
|
|
|
|
|
|
|
|
cpos.x = GET_X_LPARAM(pos);
|
|
|
|
cpos.y = GET_Y_LPARAM(pos);
|
1998-04-24 23:09:11 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
::ScreenToClient(mWnd, &cpos);
|
2005-08-23 03:57:07 +00:00
|
|
|
event.refPoint.x = cpos.x;
|
|
|
|
event.refPoint.y = cpos.y;
|
2004-09-03 08:44:23 +00:00
|
|
|
} else {
|
2005-08-23 03:57:07 +00:00
|
|
|
event.refPoint.x = 0;
|
|
|
|
event.refPoint.y = 0;
|
1998-05-29 22:44:13 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
else { // use the point override if provided
|
2005-08-23 03:57:07 +00:00
|
|
|
event.refPoint.x = aPoint->x;
|
|
|
|
event.refPoint.y = aPoint->y;
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
1998-04-24 23:09:11 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
event.time = ::GetMessageTime();
|
1998-05-29 22:44:13 +00:00
|
|
|
|
2005-08-23 03:57:07 +00:00
|
|
|
mLastPoint = event.refPoint;
|
1998-04-24 23:09:11 +00:00
|
|
|
}
|
|
|
|
|
2003-02-24 20:15:59 +00:00
|
|
|
/* In some circumstances (opening dependent windows) it makes more sense
|
|
|
|
(and fixes a crash bug) to not blur the parent window. */
|
|
|
|
void nsWindow::SuppressBlurEvents(PRBool aSuppress)
|
|
|
|
{
|
|
|
|
if (aSuppress)
|
|
|
|
++mBlurEventSuppressionLevel; // for this widget
|
|
|
|
else {
|
|
|
|
NS_ASSERTION(mBlurEventSuppressionLevel > 0, "unbalanced blur event suppression");
|
|
|
|
if (mBlurEventSuppressionLevel > 0)
|
|
|
|
--mBlurEventSuppressionLevel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsWindow::BlurEventsSuppressed()
|
|
|
|
{
|
|
|
|
// are they suppressed in this window?
|
|
|
|
if (mBlurEventSuppressionLevel > 0)
|
|
|
|
return PR_TRUE;
|
|
|
|
|
|
|
|
// are they suppressed by any container widget?
|
|
|
|
HWND parentWnd = ::GetParent(mWnd);
|
|
|
|
if (parentWnd) {
|
|
|
|
nsWindow *parent = GetNSWindowPtr(parentWnd);
|
|
|
|
if (parent)
|
|
|
|
return parent->BlurEventsSuppressed();
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1998-04-24 23:09:11 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
2004-09-03 08:44:23 +00:00
|
|
|
// Invokes callback and ProcessEvent method on Event Listener object
|
1998-04-24 23:09:11 +00:00
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
1998-10-07 22:11:37 +00:00
|
|
|
NS_IMETHODIMP nsWindow::DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus)
|
1998-04-24 23:09:11 +00:00
|
|
|
{
|
1999-09-09 03:47:26 +00:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
debug_DumpEvent(stdout,
|
|
|
|
event->widget,
|
|
|
|
event,
|
2000-09-03 00:31:01 +00:00
|
|
|
nsCAutoString("something"),
|
1999-09-09 03:47:26 +00:00
|
|
|
(PRInt32) mWnd);
|
|
|
|
#endif // NS_DEBUG
|
|
|
|
|
1998-10-07 22:11:37 +00:00
|
|
|
aStatus = nsEventStatus_eIgnore;
|
2003-02-24 20:15:59 +00:00
|
|
|
|
|
|
|
// skip processing of suppressed blur events
|
|
|
|
if ((event->message == NS_DEACTIVATE || event->message == NS_LOSTFOCUS) &&
|
|
|
|
BlurEventsSuppressed())
|
|
|
|
return NS_OK;
|
|
|
|
|
1998-04-24 23:09:11 +00:00
|
|
|
if (nsnull != mEventCallback) {
|
1998-10-07 22:11:37 +00:00
|
|
|
aStatus = (*mEventCallback)(event);
|
1998-04-24 23:09:11 +00:00
|
|
|
}
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// Dispatch to event listener if event was not consumed
|
1998-10-07 22:11:37 +00:00
|
|
|
if ((aStatus != nsEventStatus_eIgnore) && (nsnull != mEventListener)) {
|
|
|
|
aStatus = mEventListener->ProcessEvent(*event);
|
1998-04-24 23:09:11 +00:00
|
|
|
}
|
1999-04-06 00:11:43 +00:00
|
|
|
|
|
|
|
// the window can be destroyed during processing of seemingly innocuous events like, say,
|
|
|
|
// mousedowns due to the magic of scripting. mousedowns will return nsEventStatus_eIgnore,
|
|
|
|
// which causes problems with the deleted window. therefore:
|
|
|
|
if (mOnDestroyCalled)
|
|
|
|
aStatus = nsEventStatus_eConsumeNoDefault;
|
1998-10-07 22:11:37 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool nsWindow::DispatchWindowEvent(nsGUIEvent* event)
|
|
|
|
{
|
|
|
|
nsEventStatus status;
|
|
|
|
DispatchEvent(event, status);
|
|
|
|
return ConvertStatus(status);
|
1998-04-24 23:09:11 +00:00
|
|
|
}
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
PRBool nsWindow::DispatchWindowEvent(nsGUIEvent* event, nsEventStatus &aStatus) {
|
1999-11-12 02:06:52 +00:00
|
|
|
DispatchEvent(event, aStatus);
|
|
|
|
return ConvertStatus(aStatus);
|
|
|
|
}
|
|
|
|
|
1998-05-04 19:25:25 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Dispatch standard event
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
PRBool nsWindow::DispatchStandardEvent(PRUint32 aMsg)
|
|
|
|
{
|
2005-04-28 23:48:28 +00:00
|
|
|
nsGUIEvent event(PR_TRUE, aMsg, this);
|
2004-01-12 08:25:18 +00:00
|
|
|
InitEvent(event);
|
1998-10-07 22:11:37 +00:00
|
|
|
|
1998-10-08 00:04:21 +00:00
|
|
|
PRBool result = DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
return result;
|
1998-05-04 19:25:25 +00:00
|
|
|
}
|
1998-04-24 23:09:11 +00:00
|
|
|
|
2002-12-06 03:41:43 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Dispatch app command event
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2006-12-01 11:09:53 +00:00
|
|
|
PRBool nsWindow::DispatchCommandEvent(PRUint32 aEventCommand)
|
2002-12-06 03:41:43 +00:00
|
|
|
{
|
2006-12-01 11:09:53 +00:00
|
|
|
nsCOMPtr<nsIAtom> command;
|
|
|
|
switch (aEventCommand) {
|
|
|
|
case APPCOMMAND_BROWSER_BACKWARD:
|
|
|
|
command = nsWidgetAtoms::Back;
|
|
|
|
break;
|
|
|
|
case APPCOMMAND_BROWSER_FORWARD:
|
|
|
|
command = nsWidgetAtoms::Forward;
|
|
|
|
break;
|
|
|
|
case APPCOMMAND_BROWSER_REFRESH:
|
|
|
|
command = nsWidgetAtoms::Reload;
|
|
|
|
break;
|
|
|
|
case APPCOMMAND_BROWSER_STOP:
|
|
|
|
command = nsWidgetAtoms::Stop;
|
|
|
|
break;
|
|
|
|
case APPCOMMAND_BROWSER_SEARCH:
|
|
|
|
command = nsWidgetAtoms::Search;
|
|
|
|
break;
|
|
|
|
case APPCOMMAND_BROWSER_FAVORITES:
|
|
|
|
command = nsWidgetAtoms::Bookmarks;
|
|
|
|
break;
|
|
|
|
case APPCOMMAND_BROWSER_HOME:
|
|
|
|
command = nsWidgetAtoms::Home;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
nsCommandEvent event(PR_TRUE, nsWidgetAtoms::onAppCommand, command, this);
|
2002-12-06 03:41:43 +00:00
|
|
|
|
2004-01-12 08:25:18 +00:00
|
|
|
InitEvent(event);
|
2002-12-06 03:41:43 +00:00
|
|
|
DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
|
2006-12-01 11:09:53 +00:00
|
|
|
return PR_TRUE;
|
2002-12-06 03:41:43 +00:00
|
|
|
}
|
|
|
|
|
1999-09-21 11:22:21 +00:00
|
|
|
//-------------------------------------------------------------------------
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_IMETHODIMP nsWindow::CaptureRollupEvents(nsIRollupListener * aListener,
|
|
|
|
PRBool aDoCapture,
|
1999-09-30 14:36:17 +00:00
|
|
|
PRBool aConsumeRollupEvent)
|
1999-09-21 11:22:21 +00:00
|
|
|
{
|
|
|
|
if (aDoCapture) {
|
1999-11-12 23:46:11 +00:00
|
|
|
/* we haven't bothered carrying a weak reference to gRollupWidget because
|
|
|
|
we believe lifespan is properly scoped. this next assertion helps
|
|
|
|
assure that remains true. */
|
|
|
|
NS_ASSERTION(!gRollupWidget, "rollup widget reassigned before release");
|
1999-09-30 14:36:17 +00:00
|
|
|
gRollupConsumeRollupEvent = aConsumeRollupEvent;
|
1999-09-21 11:22:21 +00:00
|
|
|
NS_IF_RELEASE(gRollupListener);
|
|
|
|
NS_IF_RELEASE(gRollupWidget);
|
|
|
|
gRollupListener = aListener;
|
|
|
|
NS_ADDREF(aListener);
|
|
|
|
gRollupWidget = this;
|
|
|
|
NS_ADDREF(this);
|
2001-05-25 10:53:32 +00:00
|
|
|
|
2005-02-23 07:07:51 +00:00
|
|
|
#ifndef WINCE
|
2001-05-25 10:53:32 +00:00
|
|
|
if (!gMsgFilterHook && !gCallProcHook && !gCallMouseHook) {
|
|
|
|
RegisterSpecialDropdownHooks();
|
|
|
|
}
|
|
|
|
gProcessHook = PR_TRUE;
|
2005-06-29 18:52:08 +00:00
|
|
|
#endif
|
2005-02-23 07:07:51 +00:00
|
|
|
|
1999-09-21 11:22:21 +00:00
|
|
|
} else {
|
|
|
|
NS_IF_RELEASE(gRollupListener);
|
|
|
|
NS_IF_RELEASE(gRollupWidget);
|
2005-02-23 07:07:51 +00:00
|
|
|
|
2005-06-29 18:52:08 +00:00
|
|
|
#ifndef WINCE
|
2001-05-25 10:53:32 +00:00
|
|
|
gProcessHook = PR_FALSE;
|
|
|
|
UnregisterSpecialDropdownHooks();
|
2005-02-23 07:07:51 +00:00
|
|
|
#endif
|
1999-09-21 11:22:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
PRBool
|
|
|
|
nsWindow::EventIsInsideWindow(UINT Msg, nsWindow* aWindow)
|
1999-10-02 00:13:23 +00:00
|
|
|
{
|
|
|
|
RECT r;
|
2001-03-14 02:34:46 +00:00
|
|
|
|
|
|
|
if (Msg == WM_ACTIVATE)
|
2005-08-31 20:23:09 +00:00
|
|
|
#ifndef WINCE
|
2001-03-14 02:34:46 +00:00
|
|
|
// don't care about activation/deactivation
|
|
|
|
return PR_FALSE;
|
2005-08-31 20:23:09 +00:00
|
|
|
#else
|
|
|
|
// but on Windows CE we do care about
|
|
|
|
// activation/deactivation because there doesn't exist
|
|
|
|
// cancelable Mouse Activation events
|
|
|
|
return TRUE;
|
|
|
|
#endif
|
2001-03-14 02:34:46 +00:00
|
|
|
|
1999-10-02 00:13:23 +00:00
|
|
|
::GetWindowRect(aWindow->mWnd, &r);
|
|
|
|
DWORD pos = ::GetMessagePos();
|
|
|
|
POINT mp;
|
2004-05-13 23:13:35 +00:00
|
|
|
mp.x = GET_X_LPARAM(pos);
|
|
|
|
mp.y = GET_Y_LPARAM(pos);
|
1999-10-02 00:13:23 +00:00
|
|
|
|
2001-03-14 02:34:46 +00:00
|
|
|
// was the event inside this window?
|
|
|
|
return (PRBool) PtInRect(&r, mp);
|
1999-10-02 00:13:23 +00:00
|
|
|
}
|
|
|
|
|
2005-08-22 04:18:47 +00:00
|
|
|
static char sPropName[40] = "";
|
2005-02-23 07:07:51 +00:00
|
|
|
static char* GetNSWindowPropName() {
|
2005-08-22 04:18:47 +00:00
|
|
|
if (!*sPropName)
|
|
|
|
{
|
|
|
|
_snprintf(sPropName, 39, "MozillansIWidgetPtr%p", _getpid());
|
|
|
|
sPropName[39] = '\0';
|
|
|
|
}
|
|
|
|
return sPropName;
|
2000-04-27 00:23:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsWindow * nsWindow::GetNSWindowPtr(HWND aWnd) {
|
2005-02-23 07:07:51 +00:00
|
|
|
return (nsWindow *) ::GetPropA(aWnd, GetNSWindowPropName());
|
2000-04-27 00:23:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL nsWindow::SetNSWindowPtr(HWND aWnd, nsWindow * ptr) {
|
|
|
|
if (ptr == NULL) {
|
2005-02-23 07:07:51 +00:00
|
|
|
::RemovePropA(aWnd, GetNSWindowPropName());
|
2000-04-27 00:23:18 +00:00
|
|
|
return TRUE;
|
|
|
|
} else {
|
2005-02-23 07:07:51 +00:00
|
|
|
return ::SetPropA(aWnd, GetNSWindowPropName(), (HANDLE)ptr);
|
2000-04-27 00:23:18 +00:00
|
|
|
}
|
|
|
|
}
|
1999-10-02 00:13:23 +00:00
|
|
|
|
2000-04-13 20:15:40 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// the nsWindow procedure for all nsWindows in this toolkit
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
LRESULT CALLBACK nsWindow::WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
LRESULT popupHandlingResult;
|
2005-01-14 19:23:06 +00:00
|
|
|
if ( DealWithPopups(hWnd, msg, wParam, lParam, &popupHandlingResult) )
|
2004-09-03 08:44:23 +00:00
|
|
|
return popupHandlingResult;
|
|
|
|
|
|
|
|
// Get the window which caused the event and ask it to process the message
|
|
|
|
nsWindow *someWindow = GetNSWindowPtr(hWnd);
|
|
|
|
|
|
|
|
// XXX This fixes 50208 and we are leaving 51174 open to further investigate
|
|
|
|
// why we are hitting this assert
|
|
|
|
if (nsnull == someWindow) {
|
|
|
|
NS_ASSERTION(someWindow, "someWindow is null, cannot call any CallWindowProc");
|
2006-04-04 20:57:13 +00:00
|
|
|
return ::DefWindowProcW(hWnd, msg, wParam, lParam);
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// hold on to the window for the life of this method, in case it gets
|
|
|
|
// deleted during processing. yes, it's a double hack, since someWindow
|
|
|
|
// is not really an interface.
|
|
|
|
nsCOMPtr<nsISupports> kungFuDeathGrip;
|
|
|
|
if (!someWindow->mIsDestroying) // not if we're in the destructor!
|
|
|
|
kungFuDeathGrip = do_QueryInterface((nsBaseWidget*)someWindow);
|
|
|
|
|
|
|
|
// Re-direct a tab change message destined for its parent window to the
|
|
|
|
// the actual window which generated the event.
|
|
|
|
if (msg == WM_NOTIFY) {
|
|
|
|
LPNMHDR pnmh = (LPNMHDR) lParam;
|
|
|
|
if (pnmh->code == TCN_SELCHANGE) {
|
|
|
|
someWindow = GetNSWindowPtr(pnmh->hwndFrom);
|
1998-04-17 00:16:11 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
1998-04-17 00:16:11 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (nsnull != someWindow) {
|
|
|
|
LRESULT retValue;
|
|
|
|
if (PR_TRUE == someWindow->ProcessMessage(msg, wParam, lParam, &retValue)) {
|
|
|
|
return retValue;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-29 06:21:50 +00:00
|
|
|
#if defined(STRICT)
|
2006-04-04 20:57:13 +00:00
|
|
|
return ::CallWindowProcW((WNDPROC)someWindow->GetPrevWindowProc(), hWnd,
|
2004-09-03 08:44:23 +00:00
|
|
|
msg, wParam, lParam);
|
1998-08-29 06:21:50 +00:00
|
|
|
#else
|
2006-04-04 20:57:13 +00:00
|
|
|
return ::CallWindowProcW((FARPROC)someWindow->GetPrevWindowProc(), hWnd,
|
2004-09-03 08:44:23 +00:00
|
|
|
msg, wParam, lParam);
|
1998-08-29 06:21:50 +00:00
|
|
|
#endif
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2000-01-07 00:34:34 +00:00
|
|
|
//
|
2004-09-03 08:44:23 +00:00
|
|
|
// Default Window procedure for AIMM support.
|
2000-01-07 00:34:34 +00:00
|
|
|
//
|
|
|
|
LRESULT CALLBACK nsWindow::DefaultWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2006-04-04 20:57:13 +00:00
|
|
|
//XXX nsWindow::DefaultWindowProc still ever required?
|
|
|
|
return ::DefWindowProcW(hWnd, msg, wParam, lParam);
|
2000-01-07 00:34:34 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2000-04-27 00:23:18 +00:00
|
|
|
static BOOL CALLBACK DummyDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-03-09 23:48:58 +00:00
|
|
|
//WINOLEAPI oleStatus;
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
1998-09-29 21:34:58 +00:00
|
|
|
// Utility method for implementing both Create(nsIWidget ...) and
|
|
|
|
// Create(nsNativeWidget...)
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
nsresult
|
|
|
|
nsWindow::StandardWindowCreate(nsIWidget *aParent,
|
|
|
|
const nsRect &aRect,
|
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
|
|
|
nsIDeviceContext *aContext,
|
|
|
|
nsIAppShell *aAppShell,
|
|
|
|
nsIToolkit *aToolkit,
|
|
|
|
nsWidgetInitData *aInitData,
|
|
|
|
nsNativeWidget aNativeParent)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
nsIWidget *baseParent = aInitData &&
|
|
|
|
(aInitData->mWindowType == eWindowType_dialog ||
|
|
|
|
aInitData->mWindowType == eWindowType_toplevel ||
|
|
|
|
aInitData->mWindowType == eWindowType_invisible) ?
|
|
|
|
nsnull : aParent;
|
1999-10-02 00:13:23 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
mIsTopWidgetWindow = (nsnull == baseParent);
|
2004-07-27 19:14:44 +00:00
|
|
|
mBounds.width = aRect.width;
|
|
|
|
mBounds.height = aRect.height;
|
1999-10-02 00:13:23 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
BaseCreate(baseParent, aRect, aHandleEventFunction, aContext,
|
|
|
|
aAppShell, aToolkit, aInitData);
|
|
|
|
|
|
|
|
// Switch to the "main gui thread" if necessary... This method must
|
|
|
|
// be executed on the "gui thread"...
|
|
|
|
|
|
|
|
nsToolkit* toolkit = (nsToolkit *)mToolkit;
|
|
|
|
if (toolkit && !toolkit->IsGuiThread()) {
|
|
|
|
DWORD args[7];
|
|
|
|
args[0] = (DWORD)aParent;
|
|
|
|
args[1] = (DWORD)&aRect;
|
|
|
|
args[2] = (DWORD)aHandleEventFunction;
|
|
|
|
args[3] = (DWORD)aContext;
|
|
|
|
args[4] = (DWORD)aAppShell;
|
|
|
|
args[5] = (DWORD)aToolkit;
|
|
|
|
args[6] = (DWORD)aInitData;
|
|
|
|
|
|
|
|
if (nsnull != aParent) {
|
|
|
|
// nsIWidget parent dispatch
|
|
|
|
MethodInfo info(this, nsWindow::CREATE, 7, args);
|
|
|
|
toolkit->CallMethod(&info);
|
|
|
|
return NS_OK;
|
1998-09-29 21:34:58 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
else {
|
|
|
|
// Native parent dispatch
|
|
|
|
MethodInfo info(this, nsWindow::CREATE_NATIVE, 5, args);
|
|
|
|
toolkit->CallMethod(&info);
|
|
|
|
return NS_OK;
|
1999-03-09 09:44:27 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
2004-05-04 12:39:42 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
HWND parent;
|
|
|
|
if (nsnull != aParent) { // has a nsIWidget parent
|
|
|
|
parent = ((aParent) ? (HWND)aParent->GetNativeData(NS_NATIVE_WINDOW) : nsnull);
|
|
|
|
} else { // has a nsNative parent
|
|
|
|
parent = (HWND)aNativeParent;
|
|
|
|
}
|
1998-08-19 23:11:41 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (nsnull != aInitData) {
|
|
|
|
SetWindowType(aInitData->mWindowType);
|
|
|
|
SetBorderStyle(aInitData->mBorderStyle);
|
|
|
|
}
|
1999-05-27 21:09:49 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
mContentType = aInitData ? aInitData->mContentType : eContentTypeInherit;
|
2004-05-04 12:39:42 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
DWORD style = WindowStyle();
|
|
|
|
DWORD extendedStyle = WindowExStyle();
|
1999-07-27 22:42:34 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (mWindowType == eWindowType_popup) {
|
2004-10-21 18:35:35 +00:00
|
|
|
NS_ASSERTION(!aParent, "Popups should not be hooked into the nsIWidget hierarchy");
|
2004-09-03 08:44:23 +00:00
|
|
|
// Don't set the parent of a popup window.
|
|
|
|
parent = NULL;
|
|
|
|
} else if (nsnull != aInitData) {
|
|
|
|
// See if the caller wants to explictly set clip children and clip siblings
|
|
|
|
if (aInitData->clipChildren) {
|
|
|
|
style |= WS_CLIPCHILDREN;
|
|
|
|
} else {
|
|
|
|
style &= ~WS_CLIPCHILDREN;
|
1998-11-02 16:58:55 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
if (aInitData->clipSiblings) {
|
|
|
|
style |= WS_CLIPSIBLINGS;
|
|
|
|
}
|
|
|
|
}
|
1998-11-02 16:58:55 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
mHas3DBorder = (extendedStyle & WS_EX_CLIENTEDGE) > 0;
|
|
|
|
|
2006-11-15 12:05:56 +00:00
|
|
|
mWnd = ::CreateWindowExW(extendedStyle,
|
|
|
|
aInitData && aInitData->mDropShadow ?
|
|
|
|
WindowPopupClassW() : WindowClassW(),
|
|
|
|
L"",
|
|
|
|
style,
|
|
|
|
aRect.x,
|
|
|
|
aRect.y,
|
|
|
|
aRect.width,
|
|
|
|
GetHeight(aRect.height),
|
|
|
|
parent,
|
|
|
|
NULL,
|
|
|
|
nsToolkit::mDllInstance,
|
|
|
|
NULL);
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2004-10-11 16:13:48 +00:00
|
|
|
if (!mWnd)
|
|
|
|
return NS_ERROR_FAILURE;
|
2004-09-03 08:44:23 +00:00
|
|
|
|
|
|
|
/*mNativeDragTarget = new nsNativeDragTarget(this);
|
|
|
|
if (NULL != mNativeDragTarget) {
|
|
|
|
mNativeDragTarget->AddRef();
|
|
|
|
if (S_OK == ::CoLockObjectExternal((LPUNKNOWN)mNativeDragTarget,TRUE,FALSE)) {
|
|
|
|
if (S_OK == ::RegisterDragDrop(mWnd, (LPDROPTARGET)mNativeDragTarget)) {
|
2004-04-01 22:51:46 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}*/
|
|
|
|
|
|
|
|
// call the event callback to notify about creation
|
|
|
|
|
|
|
|
DispatchStandardEvent(NS_CREATE);
|
|
|
|
SubclassWindow(TRUE);
|
|
|
|
|
|
|
|
if (gTrimOnMinimize == 2 && mWindowType == eWindowType_invisible) {
|
2005-06-15 00:20:12 +00:00
|
|
|
/* The internal variable set by the config.trim_on_minimize pref
|
|
|
|
has not yet been initialized, and this is the hidden window
|
|
|
|
(conveniently created before any visible windows, and after
|
|
|
|
the profile has been initialized).
|
|
|
|
|
|
|
|
Default config.trim_on_minimize to false, to fix bug 76831
|
|
|
|
for good. If anyone complains about this new default, saying
|
|
|
|
that a Mozilla app hogs too much memory while minimized, they
|
|
|
|
will have that entire bug tattooed on their backside. */
|
|
|
|
|
|
|
|
gTrimOnMinimize = 0;
|
2004-09-03 08:44:23 +00:00
|
|
|
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
|
|
|
if (prefs) {
|
|
|
|
nsCOMPtr<nsIPrefBranch> prefBranch;
|
|
|
|
prefs->GetBranch(0, getter_AddRefs(prefBranch));
|
|
|
|
if (prefBranch) {
|
|
|
|
PRBool trimOnMinimize;
|
|
|
|
if (NS_SUCCEEDED(prefBranch->GetBoolPref("config.trim_on_minimize",
|
|
|
|
&trimOnMinimize))
|
2005-06-15 00:20:12 +00:00
|
|
|
&& trimOnMinimize)
|
|
|
|
gTrimOnMinimize = 1;
|
2004-12-09 19:01:35 +00:00
|
|
|
|
|
|
|
PRBool switchKeyboardLayout;
|
|
|
|
if (NS_SUCCEEDED(prefBranch->GetBoolPref("intl.keyboard.per_window_layout",
|
|
|
|
&switchKeyboardLayout)))
|
|
|
|
gSwitchKeyboardLayout = switchKeyboardLayout;
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-03-17 21:42:28 +00:00
|
|
|
#ifdef WINCE
|
2006-04-17 17:42:20 +00:00
|
|
|
|
|
|
|
if (mWindowType == eWindowType_dialog || mWindowType == eWindowType_toplevel )
|
|
|
|
CreateSoftKeyMenuBar(mWnd);
|
|
|
|
|
|
|
|
MapHardwareButtons(mWnd);
|
2006-03-17 21:42:28 +00:00
|
|
|
#endif
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
return NS_OK;
|
1998-09-29 21:34:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Create the proper widget
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_METHOD nsWindow::Create(nsIWidget *aParent,
|
2004-09-03 08:44:23 +00:00
|
|
|
const nsRect &aRect,
|
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
|
|
|
nsIDeviceContext *aContext,
|
|
|
|
nsIAppShell *aAppShell,
|
|
|
|
nsIToolkit *aToolkit,
|
|
|
|
nsWidgetInitData *aInitData)
|
1998-09-29 21:34:58 +00:00
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
if (aInitData)
|
|
|
|
mUnicodeWidget = aInitData->mUnicode;
|
|
|
|
return(StandardWindowCreate(aParent, aRect, aHandleEventFunction,
|
|
|
|
aContext, aAppShell, aToolkit, aInitData,
|
|
|
|
nsnull));
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// create with a native parent
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-29 21:34:58 +00:00
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::Create(nsNativeWidget aParent,
|
2004-09-03 08:44:23 +00:00
|
|
|
const nsRect &aRect,
|
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
|
|
|
nsIDeviceContext *aContext,
|
|
|
|
nsIAppShell *aAppShell,
|
|
|
|
nsIToolkit *aToolkit,
|
|
|
|
nsWidgetInitData *aInitData)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
if (aInitData)
|
|
|
|
mUnicodeWidget = aInitData->mUnicode;
|
|
|
|
return(StandardWindowCreate(nsnull, aRect, aHandleEventFunction,
|
|
|
|
aContext, aAppShell, aToolkit, aInitData,
|
|
|
|
aParent));
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-09-29 21:34:58 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Close this nsWindow
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::Destroy()
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-08-09 01:37:30 +00:00
|
|
|
// Switch to the "main gui thread" if necessary... This method must
|
|
|
|
// be executed on the "gui thread"...
|
1998-09-23 19:19:23 +00:00
|
|
|
nsToolkit* toolkit = (nsToolkit *)mToolkit;
|
|
|
|
if (toolkit != nsnull && !toolkit->IsGuiThread()) {
|
1998-08-09 01:37:30 +00:00
|
|
|
MethodInfo info(this, nsWindow::DESTROY);
|
1998-09-23 19:19:23 +00:00
|
|
|
toolkit->CallMethod(&info);
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
1998-08-09 01:37:30 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-09 01:37:30 +00:00
|
|
|
// disconnect from the parent
|
|
|
|
if (!mIsDestroying) {
|
1998-09-23 19:19:23 +00:00
|
|
|
nsBaseWidget::Destroy();
|
1998-08-09 01:37:30 +00:00
|
|
|
}
|
1998-05-04 19:25:25 +00:00
|
|
|
|
2001-05-25 18:33:10 +00:00
|
|
|
// just to be safe. If we're going away and for some reason we're still
|
|
|
|
// the rollup widget, rollup and turn off capture.
|
|
|
|
if ( this == gRollupWidget ) {
|
|
|
|
if ( gRollupListener )
|
|
|
|
gRollupListener->Rollup();
|
|
|
|
CaptureRollupEvents(nsnull, PR_FALSE, PR_TRUE);
|
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
|
1999-08-26 14:41:17 +00:00
|
|
|
EnableDragDrop(PR_FALSE);
|
1999-04-06 20:23:55 +00:00
|
|
|
|
1998-08-09 01:37:30 +00:00
|
|
|
// destroy the HWND
|
|
|
|
if (mWnd) {
|
|
|
|
// prevent the widget from causing additional events
|
|
|
|
mEventCallback = nsnull;
|
2001-11-16 01:58:17 +00:00
|
|
|
if (gAttentionTimerMonitor)
|
|
|
|
gAttentionTimerMonitor->KillTimer(mWnd);
|
2002-05-03 18:52:04 +00:00
|
|
|
|
2005-11-17 16:33:57 +00:00
|
|
|
// if IME is disabled, restore it.
|
|
|
|
if (mOldIMC) {
|
2006-04-04 20:57:13 +00:00
|
|
|
mOldIMC = ::ImmAssociateContext(mWnd, mOldIMC);
|
2005-11-17 16:33:57 +00:00
|
|
|
NS_ASSERTION(!mOldIMC, "Another IMC was associated");
|
|
|
|
}
|
|
|
|
|
2003-10-30 01:35:14 +00:00
|
|
|
HICON icon;
|
2006-04-04 20:57:13 +00:00
|
|
|
icon = (HICON) ::SendMessageW(mWnd, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM) 0);
|
2003-10-30 01:35:14 +00:00
|
|
|
if (icon)
|
|
|
|
::DestroyIcon(icon);
|
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
icon = (HICON) ::SendMessageW(mWnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM) 0);
|
2003-10-30 01:35:14 +00:00
|
|
|
if (icon)
|
|
|
|
::DestroyIcon(icon);
|
|
|
|
|
2004-07-27 19:14:44 +00:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
if (mIsTranslucent)
|
|
|
|
{
|
2004-12-09 17:56:46 +00:00
|
|
|
SetupTranslucentWindowMemoryBitmap(PR_FALSE);
|
2004-07-27 19:14:44 +00:00
|
|
|
|
2004-12-09 17:56:46 +00:00
|
|
|
delete [] mAlphaMask;
|
2004-07-27 19:14:44 +00:00
|
|
|
mAlphaMask = nsnull;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-08-09 01:37:30 +00:00
|
|
|
VERIFY(::DestroyWindow(mWnd));
|
2002-05-03 18:52:04 +00:00
|
|
|
|
1998-09-15 03:45:06 +00:00
|
|
|
mWnd = NULL;
|
|
|
|
//our windows can be subclassed by
|
2004-09-03 08:44:23 +00:00
|
|
|
//others and these nameless, faceless others
|
1998-09-15 03:45:06 +00:00
|
|
|
//may not let us know about WM_DESTROY. so,
|
|
|
|
//if OnDestroy() didn't get called, just call
|
|
|
|
//it now. MMP
|
|
|
|
if (PR_FALSE == mOnDestroyCalled)
|
|
|
|
OnDestroy();
|
1998-08-09 01:37:30 +00:00
|
|
|
}
|
1999-04-06 20:23:55 +00:00
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2002-09-12 03:59:15 +00:00
|
|
|
NS_IMETHODIMP nsWindow::SetParent(nsIWidget *aNewParent)
|
|
|
|
{
|
|
|
|
if (aNewParent) {
|
|
|
|
HWND newParent = (HWND)aNewParent->GetNativeData(NS_NATIVE_WINDOW);
|
|
|
|
NS_ASSERTION(newParent, "Parent widget has a null native window handle");
|
|
|
|
::SetParent(mWnd, newParent);
|
2003-03-06 23:07:00 +00:00
|
|
|
|
2002-09-12 03:59:15 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_WARNING("Null aNewParent passed to SetParent");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this nsWindow parent
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsIWidget* nsWindow::GetParent(void)
|
|
|
|
{
|
2004-12-09 17:56:46 +00:00
|
|
|
return GetParent(PR_TRUE);
|
|
|
|
}
|
|
|
|
|
2006-03-22 18:00:28 +00:00
|
|
|
// XXX does anyone pass false for aStopOnFirstTopLevel?
|
2004-12-09 17:56:46 +00:00
|
|
|
nsWindow* nsWindow::GetParent(PRBool aStopOnFirstTopLevel)
|
|
|
|
{
|
|
|
|
if (mIsTopWidgetWindow && aStopOnFirstTopLevel) {
|
2004-09-03 08:44:23 +00:00
|
|
|
// Must use a flag instead of mWindowType to tell if the window is the
|
|
|
|
// owned by the topmost widget, because a child window can be embedded inside
|
|
|
|
// a HWND which is not associated with a nsIWidget.
|
|
|
|
return nsnull;
|
|
|
|
}
|
2004-12-09 17:56:46 +00:00
|
|
|
// If this widget has already been destroyed, pretend we have no parent.
|
|
|
|
// This corresponds to code in Destroy which removes the destroyed
|
|
|
|
// widget from its parent's child list.
|
2004-09-03 08:44:23 +00:00
|
|
|
if (mIsDestroying || mOnDestroyCalled)
|
|
|
|
return nsnull;
|
1999-10-02 00:13:23 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
nsWindow* widget = nsnull;
|
|
|
|
if (mWnd) {
|
|
|
|
HWND parent = ::GetParent(mWnd);
|
|
|
|
if (parent) {
|
|
|
|
widget = GetNSWindowPtr(parent);
|
|
|
|
if (widget) {
|
|
|
|
// If the widget is in the process of being destroyed then
|
|
|
|
// do NOT return it
|
|
|
|
if (widget->mIsDestroying) {
|
|
|
|
widget = nsnull;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-12-09 17:56:46 +00:00
|
|
|
return widget;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Hide or show this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2006-06-19 05:58:00 +00:00
|
|
|
#ifndef WINCE
|
2006-07-20 04:01:52 +00:00
|
|
|
PRBool gWindowsVisible;
|
2006-06-19 05:58:00 +00:00
|
|
|
|
2006-06-24 16:49:17 +00:00
|
|
|
static BOOL CALLBACK gEnumWindowsProc(HWND hwnd, LPARAM lParam)
|
2006-06-19 05:58:00 +00:00
|
|
|
{
|
|
|
|
DWORD pid;
|
|
|
|
::GetWindowThreadProcessId(hwnd, &pid);
|
|
|
|
if (pid == _getpid() && ::IsWindowVisible(hwnd))
|
|
|
|
{
|
2006-07-20 04:01:52 +00:00
|
|
|
gWindowsVisible = PR_TRUE;
|
2006-06-19 05:58:00 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-07-20 04:01:52 +00:00
|
|
|
PRBool nsWindow::CanTakeFocus()
|
|
|
|
{
|
|
|
|
#ifndef WINCE
|
|
|
|
gWindowsVisible = PR_FALSE;
|
|
|
|
EnumWindows(gEnumWindowsProc, 0);
|
|
|
|
if (!gWindowsVisible) {
|
|
|
|
return PR_TRUE;
|
|
|
|
} else {
|
|
|
|
HWND fgWnd = ::GetForegroundWindow();
|
|
|
|
if (!fgWnd) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
DWORD pid;
|
|
|
|
GetWindowThreadProcessId(fgWnd, &pid);
|
|
|
|
if (pid == _getpid()) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
#else
|
|
|
|
return PR_TRUE;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::Show(PRBool bState)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2000-12-20 01:43:38 +00:00
|
|
|
if (mWnd) {
|
|
|
|
if (bState) {
|
|
|
|
if (!mIsVisible && mWindowType == eWindowType_toplevel) {
|
|
|
|
switch (mSizeMode) {
|
|
|
|
case nsSizeMode_Maximized :
|
2006-06-19 05:58:00 +00:00
|
|
|
::ShowWindow(mWnd, SW_SHOWMAXIMIZED);
|
2000-12-20 01:43:38 +00:00
|
|
|
break;
|
|
|
|
case nsSizeMode_Minimized :
|
2005-08-16 19:15:06 +00:00
|
|
|
#ifndef WINCE
|
2006-06-19 05:58:00 +00:00
|
|
|
::ShowWindow(mWnd, SW_SHOWMINIMIZED);
|
2005-02-23 07:07:51 +00:00
|
|
|
#endif
|
2000-12-20 01:43:38 +00:00
|
|
|
break;
|
2006-07-20 04:01:52 +00:00
|
|
|
default:
|
|
|
|
if (CanTakeFocus()) {
|
2006-06-19 05:58:00 +00:00
|
|
|
::ShowWindow(mWnd, SW_SHOWNORMAL);
|
2006-07-20 04:01:52 +00:00
|
|
|
} else {
|
|
|
|
// Place the window behind the foreground window
|
2006-10-19 20:01:11 +00:00
|
|
|
// (as long as it is not topmost)
|
2006-07-20 04:01:52 +00:00
|
|
|
HWND wndAfter = ::GetForegroundWindow();
|
|
|
|
if (!wndAfter)
|
|
|
|
wndAfter = HWND_BOTTOM;
|
2006-10-19 20:01:11 +00:00
|
|
|
else if (GetWindowLong(wndAfter, GWL_EXSTYLE) & WS_EX_TOPMOST)
|
|
|
|
wndAfter = HWND_TOP;
|
2006-07-20 04:01:52 +00:00
|
|
|
::SetWindowPos(mWnd, wndAfter, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE |
|
|
|
|
SWP_NOMOVE | SWP_NOACTIVATE);
|
|
|
|
GetAttention(2);
|
2006-06-19 05:58:00 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
2000-12-20 01:43:38 +00:00
|
|
|
} else {
|
|
|
|
DWORD flags = SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW;
|
2001-03-07 00:46:36 +00:00
|
|
|
if (mIsVisible)
|
2000-12-20 01:43:38 +00:00
|
|
|
flags |= SWP_NOZORDER;
|
|
|
|
|
|
|
|
if (mWindowType == eWindowType_popup) {
|
2006-07-25 18:53:38 +00:00
|
|
|
#ifndef WINCE
|
|
|
|
// ensure popups are the topmost of the TOPMOST
|
|
|
|
// layer. Remember not to set the SWP_NOZORDER
|
|
|
|
// flag as that might allow the taskbar to overlap
|
|
|
|
// the popup. However on windows ce, we need to
|
|
|
|
// activate the popup or clicks will not be sent.
|
2000-12-20 01:43:38 +00:00
|
|
|
flags |= SWP_NOACTIVATE;
|
2006-07-25 18:53:38 +00:00
|
|
|
#endif
|
2000-12-20 01:43:38 +00:00
|
|
|
::SetWindowPos(mWnd, HWND_TOPMOST, 0, 0, 0, 0, flags);
|
|
|
|
} else {
|
|
|
|
::SetWindowPos(mWnd, HWND_TOP, 0, 0, 0, 0, flags);
|
|
|
|
}
|
|
|
|
}
|
2003-04-01 20:04:36 +00:00
|
|
|
} else {
|
|
|
|
if (mWindowType != eWindowType_dialog) {
|
|
|
|
::ShowWindow(mWnd, SW_HIDE);
|
|
|
|
} else {
|
2004-09-03 08:44:23 +00:00
|
|
|
::SetWindowPos(mWnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE |
|
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE);
|
2003-04-01 20:04:36 +00:00
|
|
|
}
|
|
|
|
}
|
2000-12-20 01:43:38 +00:00
|
|
|
}
|
2006-06-16 02:27:37 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_XUL
|
|
|
|
if (!mIsVisible && bState && mIsTopTranslucent)
|
|
|
|
Invalidate(PR_FALSE);
|
|
|
|
#endif
|
|
|
|
|
2000-12-20 01:43:38 +00:00
|
|
|
mIsVisible = bState;
|
2003-04-15 08:45:55 +00:00
|
|
|
|
2000-12-20 01:43:38 +00:00
|
|
|
return NS_OK;
|
1998-09-28 22:32:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Return PR_TRUE if the whether the component is visible, PR_FALSE otherwise
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_METHOD nsWindow::IsVisible(PRBool & bState)
|
|
|
|
{
|
|
|
|
bState = mIsVisible;
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2000-04-01 22:16:43 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Position the window behind the given window
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2003-10-07 01:19:59 +00:00
|
|
|
NS_METHOD nsWindow::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
|
|
|
|
nsIWidget *aWidget, PRBool aActivate)
|
2000-04-01 22:16:43 +00:00
|
|
|
{
|
2003-10-07 01:19:59 +00:00
|
|
|
HWND behind = HWND_TOP;
|
|
|
|
if (aPlacement == eZPlacementBottom)
|
|
|
|
behind = HWND_BOTTOM;
|
|
|
|
else if (aPlacement == eZPlacementBelow && aWidget)
|
|
|
|
behind = (HWND)aWidget->GetNativeData(NS_NATIVE_WINDOW);
|
2000-08-30 21:21:39 +00:00
|
|
|
UINT flags = SWP_NOMOVE | SWP_NOREPOSITION | SWP_NOSIZE;
|
|
|
|
if (!aActivate)
|
|
|
|
flags |= SWP_NOACTIVATE;
|
|
|
|
|
2006-07-20 04:01:52 +00:00
|
|
|
if (!CanTakeFocus() && behind == HWND_TOP)
|
|
|
|
{
|
|
|
|
// Can't place the window to top so place it behind the foreground window
|
2006-10-19 20:01:11 +00:00
|
|
|
// (as long as it is not topmost)
|
|
|
|
HWND wndAfter = ::GetForegroundWindow();
|
|
|
|
if (!wndAfter)
|
2006-07-20 04:01:52 +00:00
|
|
|
behind = HWND_BOTTOM;
|
2006-10-19 20:01:11 +00:00
|
|
|
else if (!(GetWindowLong(wndAfter, GWL_EXSTYLE) & WS_EX_TOPMOST))
|
|
|
|
behind = wndAfter;
|
2006-07-20 04:01:52 +00:00
|
|
|
flags |= SWP_NOACTIVATE;
|
|
|
|
}
|
|
|
|
|
2000-08-30 21:21:39 +00:00
|
|
|
::SetWindowPos(mWnd, behind, 0, 0, 0, 0, flags);
|
2000-04-01 22:16:43 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-12-14 22:37:08 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Maximize, minimize or restore the window.
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP nsWindow::SetSizeMode(PRInt32 aMode) {
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
|
2006-08-12 11:39:05 +00:00
|
|
|
// Let's not try and do anything if we're already in that state.
|
|
|
|
// (This is needed to prevent problems when calling window.minimize(), which
|
|
|
|
// calls us directly, and then the OS triggers another call to us.)
|
|
|
|
if (aMode == mSizeMode)
|
|
|
|
return NS_OK;
|
|
|
|
|
2000-12-14 22:37:08 +00:00
|
|
|
// save the requested state
|
|
|
|
rv = nsBaseWidget::SetSizeMode(aMode);
|
2000-12-20 01:43:38 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && mIsVisible) {
|
|
|
|
int mode;
|
2000-12-14 22:37:08 +00:00
|
|
|
|
|
|
|
switch (aMode) {
|
|
|
|
case nsSizeMode_Maximized :
|
|
|
|
mode = SW_MAXIMIZE;
|
|
|
|
break;
|
|
|
|
case nsSizeMode_Minimized :
|
2005-08-16 19:15:06 +00:00
|
|
|
#ifndef WINCE
|
2004-04-01 22:51:46 +00:00
|
|
|
mode = gTrimOnMinimize ? SW_MINIMIZE : SW_SHOWMINIMIZED;
|
2006-08-12 11:39:05 +00:00
|
|
|
if (!gTrimOnMinimize) {
|
|
|
|
// Find the next window that is visible and not minimized.
|
|
|
|
HWND hwndBelow = ::GetNextWindow(mWnd, GW_HWNDNEXT);
|
|
|
|
while (hwndBelow && (!::IsWindowVisible(hwndBelow) ||
|
|
|
|
::IsIconic(hwndBelow))) {
|
|
|
|
hwndBelow = ::GetNextWindow(hwndBelow, GW_HWNDNEXT);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Push ourselves to the bottom of the stack, then activate the
|
|
|
|
// next window.
|
|
|
|
::SetWindowPos(mWnd, HWND_BOTTOM, 0, 0, 0, 0,
|
|
|
|
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
|
|
|
|
if (hwndBelow)
|
|
|
|
::SetForegroundWindow(hwndBelow);
|
2007-05-02 09:24:52 +00:00
|
|
|
|
|
|
|
// Play the minimize sound while we're here, since that is also
|
|
|
|
// forgotten when we use SW_SHOWMINIMIZED.
|
|
|
|
::PlaySound("Minimize", nsnull, SND_ALIAS | SND_NODEFAULT | SND_ASYNC);
|
2006-08-12 11:39:05 +00:00
|
|
|
}
|
2005-02-23 07:07:51 +00:00
|
|
|
#endif
|
2005-08-16 19:15:06 +00:00
|
|
|
break;
|
2000-12-14 22:37:08 +00:00
|
|
|
default :
|
|
|
|
mode = SW_RESTORE;
|
|
|
|
}
|
|
|
|
::ShowWindow(mWnd, mode);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-11-12 23:46:11 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Return PR_TRUE in aForWindow if the given event should be processed
|
|
|
|
// assuming this is a modal window.
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_METHOD nsWindow::ModalEventFilter(PRBool aRealEvent, void *aEvent,
|
|
|
|
PRBool *aForWindow)
|
|
|
|
{
|
|
|
|
if (!aRealEvent) {
|
2000-02-15 05:05:19 +00:00
|
|
|
*aForWindow = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
// this version actually works, but turns out to be unnecessary
|
|
|
|
// if we use the OS properly.
|
|
|
|
MSG *msg = (MSG *) aEvent;
|
1999-11-12 23:46:11 +00:00
|
|
|
|
|
|
|
switch (msg->message) {
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
case WM_LBUTTONDBLCLK:
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
case WM_MBUTTONUP:
|
|
|
|
case WM_MBUTTONDBLCLK:
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
case WM_RBUTTONUP:
|
|
|
|
case WM_RBUTTONDBLCLK:
|
|
|
|
{
|
|
|
|
PRBool acceptEvent;
|
|
|
|
|
|
|
|
// is the event within our window?
|
|
|
|
HWND rollupWindow = NULL;
|
|
|
|
HWND msgWindow = GetTopLevelHWND(msg->hwnd);
|
|
|
|
if (gRollupWidget)
|
|
|
|
rollupWindow = (HWND)gRollupWidget->GetNativeData(NS_NATIVE_WINDOW);
|
|
|
|
acceptEvent = msgWindow && (msgWindow == mWnd || msgWindow == rollupWindow) ?
|
|
|
|
PR_TRUE : PR_FALSE;
|
|
|
|
|
|
|
|
// if not, accept events for any window that hasn't been disabled.
|
|
|
|
if (!acceptEvent) {
|
2006-04-04 20:57:13 +00:00
|
|
|
LONG proc = ::GetWindowLongW(msgWindow, GWL_WNDPROC);
|
2004-09-03 08:44:23 +00:00
|
|
|
if (proc == (LONG)&nsWindow::WindowProc) {
|
|
|
|
nsWindow *msgWin = GetNSWindowPtr(msgWindow);
|
|
|
|
msgWin->IsEnabled(&acceptEvent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
*aForWindow = PR_TRUE;
|
1999-11-12 23:46:11 +00:00
|
|
|
}
|
2000-02-15 05:05:19 +00:00
|
|
|
#else
|
|
|
|
*aForWindow = PR_TRUE;
|
|
|
|
#endif
|
1999-11-12 23:46:11 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-08-04 14:48:33 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Constrain a potential move to fit onscreen
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2002-01-09 01:30:06 +00:00
|
|
|
NS_METHOD nsWindow::ConstrainPosition(PRBool aAllowSlop,
|
|
|
|
PRInt32 *aX, PRInt32 *aY)
|
2000-08-04 14:48:33 +00:00
|
|
|
{
|
2002-01-09 01:30:06 +00:00
|
|
|
if (!mIsTopWidgetWindow) // only a problem for top-level windows
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
PRBool doConstrain = PR_FALSE; // whether we have enough info to do anything
|
|
|
|
|
|
|
|
/* get our playing field. use the current screen, or failing that
|
|
|
|
for any reason, use device caps for the default screen. */
|
|
|
|
RECT screenRect;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIScreenManager> screenmgr = do_GetService(sScreenManagerContractID);
|
|
|
|
if (screenmgr) {
|
|
|
|
nsCOMPtr<nsIScreen> screen;
|
|
|
|
PRInt32 left, top, width, height;
|
|
|
|
|
|
|
|
// zero size rects confuse the screen manager
|
|
|
|
width = mBounds.width > 0 ? mBounds.width : 1;
|
|
|
|
height = mBounds.height > 0 ? mBounds.height : 1;
|
|
|
|
screenmgr->ScreenForRect(*aX, *aY, width, height,
|
2004-09-03 08:44:23 +00:00
|
|
|
getter_AddRefs(screen));
|
2002-01-09 01:30:06 +00:00
|
|
|
if (screen) {
|
|
|
|
screen->GetAvailRect(&left, &top, &width, &height);
|
|
|
|
screenRect.left = left;
|
|
|
|
screenRect.right = left+width;
|
|
|
|
screenRect.top = top;
|
|
|
|
screenRect.bottom = top+height;
|
|
|
|
doConstrain = PR_TRUE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (mWnd) {
|
|
|
|
HDC dc = ::GetDC(mWnd);
|
2004-09-03 08:44:23 +00:00
|
|
|
if (dc) {
|
2002-01-09 01:30:06 +00:00
|
|
|
if (::GetDeviceCaps(dc, TECHNOLOGY) == DT_RASDISPLAY) {
|
|
|
|
::SystemParametersInfo(SPI_GETWORKAREA, 0, &screenRect, 0);
|
|
|
|
doConstrain = PR_TRUE;
|
|
|
|
}
|
|
|
|
::ReleaseDC(mWnd, dc);
|
2000-08-04 14:48:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-01-09 01:30:06 +00:00
|
|
|
|
|
|
|
if (aAllowSlop) {
|
|
|
|
if (*aX < screenRect.left - mBounds.width + kWindowPositionSlop)
|
|
|
|
*aX = screenRect.left - mBounds.width + kWindowPositionSlop;
|
|
|
|
else if (*aX >= screenRect.right - kWindowPositionSlop)
|
|
|
|
*aX = screenRect.right - kWindowPositionSlop;
|
|
|
|
|
|
|
|
if (*aY < screenRect.top - mBounds.height + kWindowPositionSlop)
|
|
|
|
*aY = screenRect.top - mBounds.height + kWindowPositionSlop;
|
|
|
|
else if (*aY >= screenRect.bottom - kWindowPositionSlop)
|
|
|
|
*aY = screenRect.bottom - kWindowPositionSlop;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (*aX < screenRect.left)
|
|
|
|
*aX = screenRect.left;
|
|
|
|
else if (*aX >= screenRect.right - mBounds.width)
|
|
|
|
*aX = screenRect.right - mBounds.width;
|
|
|
|
|
|
|
|
if (*aY < screenRect.top)
|
|
|
|
*aY = screenRect.top;
|
|
|
|
else if (*aY >= screenRect.bottom - mBounds.height)
|
|
|
|
*aY = screenRect.bottom - mBounds.height;
|
|
|
|
}
|
|
|
|
|
2000-08-04 14:48:33 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Move this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1999-07-27 23:26:36 +00:00
|
|
|
NS_METHOD nsWindow::Move(PRInt32 aX, PRInt32 aY)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2003-03-06 10:38:30 +00:00
|
|
|
// Check to see if window needs to be moved first
|
|
|
|
// to avoid a costly call to SetWindowPos. This check
|
2004-09-03 08:44:23 +00:00
|
|
|
// can not be moved to the calling code in nsView, because
|
2003-03-06 10:38:30 +00:00
|
|
|
// some platforms do not position child windows correctly
|
|
|
|
|
|
|
|
// Only perform this check for non-popup windows, since the positioning can
|
|
|
|
// in fact change even when the x/y do not. We always need to perform the
|
|
|
|
// check. See bug #97805 for details.
|
|
|
|
if (mWindowType != eWindowType_popup && (mBounds.x == aX) && (mBounds.y == aY))
|
2000-03-15 01:17:29 +00:00
|
|
|
{
|
2003-03-06 10:38:30 +00:00
|
|
|
// Nothing to do, since it is already positioned correctly.
|
2004-09-03 08:44:23 +00:00
|
|
|
return NS_OK;
|
2003-03-06 10:38:30 +00:00
|
|
|
}
|
|
|
|
|
1998-11-24 14:57:09 +00:00
|
|
|
mBounds.x = aX;
|
|
|
|
mBounds.y = aY;
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (mWnd) {
|
2000-08-04 14:48:33 +00:00
|
|
|
#ifdef DEBUG
|
2004-09-03 08:44:23 +00:00
|
|
|
// complain if a window is moved offscreen (legal, but potentially worrisome)
|
|
|
|
if (mIsTopWidgetWindow) { // only a problem for top-level windows
|
|
|
|
// Make sure this window is actually on the screen before we move it
|
|
|
|
// XXX: Needs multiple monitor support
|
|
|
|
HDC dc = ::GetDC(mWnd);
|
|
|
|
if (dc) {
|
|
|
|
if (::GetDeviceCaps(dc, TECHNOLOGY) == DT_RASDISPLAY) {
|
|
|
|
RECT workArea;
|
|
|
|
::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0);
|
|
|
|
// no annoying assertions. just mention the issue.
|
|
|
|
if (aX < 0 || aX >= workArea.right || aY < 0 || aY >= workArea.bottom)
|
|
|
|
printf("window moved to offscreen position\n");
|
2000-03-14 11:44:04 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
::ReleaseDC(mWnd, dc);
|
2000-03-14 11:44:04 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
2000-08-04 14:48:33 +00:00
|
|
|
#endif
|
2000-03-08 04:41:12 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
nsIWidget *par = GetParent();
|
|
|
|
HDWP deferrer = NULL;
|
1998-05-13 03:39:08 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (nsnull != par) {
|
|
|
|
deferrer = ((nsWindow *)par)->mDeferredPositioner;
|
|
|
|
}
|
1998-06-16 17:16:59 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (NULL != deferrer) {
|
|
|
|
VERIFY(((nsWindow *)par)->mDeferredPositioner = ::DeferWindowPos(deferrer,
|
|
|
|
mWnd, NULL, aX, aY, 0, 0,
|
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE));
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
else {
|
|
|
|
VERIFY(::SetWindowPos(mWnd, NULL, aX, aY, 0, 0,
|
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Resize this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1999-07-27 23:26:36 +00:00
|
|
|
NS_METHOD nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-07-27 23:26:36 +00:00
|
|
|
NS_ASSERTION((aWidth >=0 ) , "Negative width passed to nsWindow::Resize");
|
|
|
|
NS_ASSERTION((aHeight >=0 ), "Negative height passed to nsWindow::Resize");
|
2004-07-27 19:14:44 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_XUL
|
|
|
|
if (mIsTranslucent)
|
|
|
|
ResizeTranslucentWindow(aWidth, aHeight);
|
|
|
|
#endif
|
|
|
|
|
1998-11-24 14:57:09 +00:00
|
|
|
// Set cached value for lightweight and printing
|
|
|
|
mBounds.width = aWidth;
|
|
|
|
mBounds.height = aHeight;
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (mWnd) {
|
|
|
|
nsIWidget *par = GetParent();
|
|
|
|
HDWP deferrer = NULL;
|
1998-05-13 03:39:08 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (nsnull != par) {
|
|
|
|
deferrer = ((nsWindow *)par)->mDeferredPositioner;
|
|
|
|
}
|
1998-06-01 20:26:50 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
UINT flags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE;
|
2005-02-23 07:07:51 +00:00
|
|
|
#ifndef WINCE
|
2004-09-03 08:44:23 +00:00
|
|
|
if (!aRepaint) {
|
|
|
|
flags |= SWP_NOREDRAW;
|
|
|
|
}
|
2005-02-23 07:07:51 +00:00
|
|
|
#endif
|
1998-06-16 17:16:59 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (NULL != deferrer) {
|
|
|
|
VERIFY(((nsWindow *)par)->mDeferredPositioner = ::DeferWindowPos(deferrer,
|
|
|
|
mWnd, NULL, 0, 0, aWidth, GetHeight(aHeight), flags));
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
else {
|
|
|
|
VERIFY(::SetWindowPos(mWnd, NULL, 0, 0, aWidth, GetHeight(aHeight), flags));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aRepaint)
|
|
|
|
Invalidate(PR_FALSE);
|
|
|
|
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Resize this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_METHOD nsWindow::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-07-27 23:26:36 +00:00
|
|
|
NS_ASSERTION((aWidth >=0 ), "Negative width passed to nsWindow::Resize");
|
|
|
|
NS_ASSERTION((aHeight >=0 ), "Negative height passed to nsWindow::Resize");
|
|
|
|
|
2004-07-27 19:14:44 +00:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
if (mIsTranslucent)
|
|
|
|
ResizeTranslucentWindow(aWidth, aHeight);
|
|
|
|
#endif
|
|
|
|
|
1998-11-24 14:57:09 +00:00
|
|
|
// Set cached value for lightweight and printing
|
|
|
|
mBounds.x = aX;
|
|
|
|
mBounds.y = aY;
|
|
|
|
mBounds.width = aWidth;
|
|
|
|
mBounds.height = aHeight;
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (mWnd) {
|
|
|
|
nsIWidget *par = GetParent();
|
|
|
|
HDWP deferrer = NULL;
|
1998-05-13 03:39:08 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (nsnull != par) {
|
|
|
|
deferrer = ((nsWindow *)par)->mDeferredPositioner;
|
|
|
|
}
|
1998-06-01 20:26:50 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
UINT flags = SWP_NOZORDER | SWP_NOACTIVATE;
|
2005-02-23 07:07:51 +00:00
|
|
|
#ifndef WINCE
|
2004-09-03 08:44:23 +00:00
|
|
|
if (!aRepaint) {
|
|
|
|
flags |= SWP_NOREDRAW;
|
|
|
|
}
|
2005-02-23 07:07:51 +00:00
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
if (NULL != deferrer) {
|
|
|
|
VERIFY(((nsWindow *)par)->mDeferredPositioner = ::DeferWindowPos(deferrer,
|
|
|
|
mWnd, NULL, aX, aY, aWidth, GetHeight(aHeight), flags));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
VERIFY(::SetWindowPos(mWnd, NULL, aX, aY, aWidth, GetHeight(aHeight), flags));
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aRepaint)
|
|
|
|
Invalidate(PR_FALSE);
|
2000-02-15 21:40:31 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Enable/disable this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::Enable(PRBool bState)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
if (mWnd) {
|
|
|
|
::EnableWindow(mWnd, bState);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2000-02-15 05:05:19 +00:00
|
|
|
|
2002-02-28 23:10:04 +00:00
|
|
|
NS_METHOD nsWindow::IsEnabled(PRBool *aState)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aState);
|
2007-02-20 19:45:17 +00:00
|
|
|
*aState = !mWnd || (::IsWindowEnabled(mWnd) && ::IsWindowEnabled(::GetAncestor(mWnd, GA_ROOT)));
|
2002-02-28 23:10:04 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Give the focus to this component
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2001-03-19 17:56:04 +00:00
|
|
|
NS_METHOD nsWindow::SetFocus(PRBool aRaise)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
//
|
|
|
|
// Switch to the "main gui thread" if necessary... This method must
|
|
|
|
// be executed on the "gui thread"...
|
|
|
|
//
|
|
|
|
nsToolkit* toolkit = (nsToolkit *)mToolkit;
|
|
|
|
NS_ASSERTION(toolkit != nsnull, "This should never be null!"); // Bug 57044
|
|
|
|
if (toolkit != nsnull && !toolkit->IsGuiThread()) {
|
|
|
|
MethodInfo info(this, nsWindow::SET_FOCUS);
|
|
|
|
toolkit->CallMethod(&info);
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mWnd) {
|
|
|
|
// Uniconify, if necessary
|
|
|
|
HWND toplevelWnd = GetTopLevelHWND(mWnd);
|
|
|
|
if (::IsIconic(toplevelWnd))
|
2006-10-11 17:30:01 +00:00
|
|
|
::ShowWindow(toplevelWnd, SW_RESTORE);
|
2004-09-03 08:44:23 +00:00
|
|
|
::SetFocus(mWnd);
|
2006-03-17 21:42:28 +00:00
|
|
|
|
|
|
|
#ifdef WINCE
|
|
|
|
MapHardwareButtons(mWnd);
|
|
|
|
#endif
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this component dimension
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::GetBounds(nsRect &aRect)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-11-04 21:43:47 +00:00
|
|
|
if (mWnd) {
|
|
|
|
RECT r;
|
|
|
|
VERIFY(::GetWindowRect(mWnd, &r));
|
|
|
|
|
|
|
|
// assign size
|
|
|
|
aRect.width = r.right - r.left;
|
|
|
|
aRect.height = r.bottom - r.top;
|
|
|
|
|
|
|
|
// convert coordinates if parent exists
|
|
|
|
HWND parent = ::GetParent(mWnd);
|
|
|
|
if (parent) {
|
|
|
|
RECT pr;
|
|
|
|
VERIFY(::GetWindowRect(parent, &pr));
|
|
|
|
r.left -= pr.left;
|
|
|
|
r.top -= pr.top;
|
|
|
|
}
|
|
|
|
aRect.x = r.left;
|
|
|
|
aRect.y = r.top;
|
|
|
|
} else {
|
1998-11-24 14:57:09 +00:00
|
|
|
aRect = mBounds;
|
1998-11-04 21:43:47 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-11-04 21:43:47 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-11-04 21:43:47 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this component dimension
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_METHOD nsWindow::GetClientBounds(nsRect &aRect)
|
|
|
|
{
|
|
|
|
if (mWnd) {
|
|
|
|
RECT r;
|
|
|
|
VERIFY(::GetClientRect(mWnd, &r));
|
|
|
|
|
|
|
|
// assign size
|
|
|
|
aRect.x = 0;
|
|
|
|
aRect.y = 0;
|
|
|
|
aRect.width = r.right - r.left;
|
|
|
|
aRect.height = r.bottom - r.top;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
aRect.SetRect(0,0,0,0);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1998-06-16 17:16:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//get the bounds, but don't take into account the client size
|
|
|
|
|
|
|
|
void nsWindow::GetNonClientBounds(nsRect &aRect)
|
|
|
|
{
|
1998-11-04 21:43:47 +00:00
|
|
|
if (mWnd) {
|
2004-09-03 08:44:23 +00:00
|
|
|
RECT r;
|
|
|
|
VERIFY(::GetWindowRect(mWnd, &r));
|
|
|
|
|
|
|
|
// assign size
|
|
|
|
aRect.width = r.right - r.left;
|
|
|
|
aRect.height = r.bottom - r.top;
|
|
|
|
|
|
|
|
// convert coordinates if parent exists
|
|
|
|
HWND parent = ::GetParent(mWnd);
|
|
|
|
if (parent) {
|
|
|
|
RECT pr;
|
|
|
|
VERIFY(::GetWindowRect(parent, &pr));
|
|
|
|
r.left -= pr.left;
|
|
|
|
r.top -= pr.top;
|
|
|
|
}
|
|
|
|
aRect.x = r.left;
|
|
|
|
aRect.y = r.top;
|
1998-11-04 21:43:47 +00:00
|
|
|
} else {
|
2004-09-03 08:44:23 +00:00
|
|
|
aRect.SetRect(0,0,0,0);
|
1998-11-04 21:43:47 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2004-03-03 16:42:51 +00:00
|
|
|
// like GetBounds, but don't offset by the parent
|
|
|
|
NS_METHOD nsWindow::GetScreenBounds(nsRect &aRect)
|
|
|
|
{
|
|
|
|
if (mWnd) {
|
|
|
|
RECT r;
|
|
|
|
VERIFY(::GetWindowRect(mWnd, &r));
|
|
|
|
|
|
|
|
aRect.width = r.right - r.left;
|
|
|
|
aRect.height = r.bottom - r.top;
|
|
|
|
aRect.x = r.left;
|
|
|
|
aRect.y = r.top;
|
|
|
|
} else
|
|
|
|
aRect = mBounds;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set the background color
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::SetBackgroundColor(const nscolor &aColor)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
nsBaseWidget::SetBackgroundColor(aColor);
|
1998-07-21 18:04:18 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (mBrush)
|
|
|
|
::DeleteObject(mBrush);
|
|
|
|
|
|
|
|
mBrush = ::CreateSolidBrush(NSRGB_2_COLOREF(mBackground));
|
2005-02-23 07:07:51 +00:00
|
|
|
#ifndef WINCE
|
2004-09-03 08:44:23 +00:00
|
|
|
if (mWnd != NULL) {
|
|
|
|
SetClassLong(mWnd, GCL_HBRBACKGROUND, (LONG)mBrush);
|
|
|
|
}
|
2005-02-23 07:07:51 +00:00
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this component font
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsIFontMetrics* nsWindow::GetFont(void)
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_NOTYETIMPLEMENTED("GetFont not yet implemented"); // to be implemented
|
|
|
|
return NULL;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set this component font
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::SetFont(const nsFont &aFont)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-11-24 14:57:09 +00:00
|
|
|
// Cache Font for owner draw
|
|
|
|
if (mFont == nsnull) {
|
|
|
|
mFont = new nsFont(aFont);
|
|
|
|
} else {
|
|
|
|
*mFont = aFont;
|
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
|
1998-11-24 14:57:09 +00:00
|
|
|
// Bail out if there is no context
|
|
|
|
if (nsnull == mContext) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1998-11-16 22:18:30 +00:00
|
|
|
|
1998-11-24 14:57:09 +00:00
|
|
|
nsIFontMetrics* metrics;
|
|
|
|
mContext->GetMetricsFor(aFont, metrics);
|
|
|
|
nsFontHandle fontHandle;
|
|
|
|
metrics->GetFontHandle(fontHandle);
|
|
|
|
HFONT hfont = (HFONT)fontHandle;
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// Draw in the new font
|
2006-04-04 20:57:13 +00:00
|
|
|
::SendMessageW(mWnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)0);
|
1998-11-24 14:57:09 +00:00
|
|
|
NS_RELEASE(metrics);
|
|
|
|
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set this component cursor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::SetCursor(nsCursor aCursor)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
// Only change cursor if it's changing
|
1998-11-18 05:25:26 +00:00
|
|
|
|
|
|
|
//XXX mCursor isn't always right. Scrollbars and others change it, too.
|
|
|
|
//XXX If we want this optimization we need a better way to do it.
|
|
|
|
//if (aCursor != mCursor) {
|
2004-09-03 08:44:23 +00:00
|
|
|
HCURSOR newCursor = NULL;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
switch (aCursor) {
|
1998-04-13 20:24:54 +00:00
|
|
|
case eCursor_select:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_IBEAM);
|
|
|
|
break;
|
2004-09-03 08:44:23 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
case eCursor_wait:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_WAIT);
|
|
|
|
break;
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case eCursor_hyperlink:
|
|
|
|
{
|
2001-11-29 09:41:19 +00:00
|
|
|
newCursor = ::LoadCursor(NULL, IDC_HAND);
|
1998-04-13 20:24:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case eCursor_standard:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_ARROW);
|
|
|
|
break;
|
|
|
|
|
2004-09-11 23:24:30 +00:00
|
|
|
case eCursor_n_resize:
|
|
|
|
case eCursor_s_resize:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_SIZENS);
|
1998-07-30 21:25:35 +00:00
|
|
|
break;
|
|
|
|
|
2004-09-11 23:24:30 +00:00
|
|
|
case eCursor_w_resize:
|
|
|
|
case eCursor_e_resize:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_SIZEWE);
|
1998-07-30 21:25:35 +00:00
|
|
|
break;
|
|
|
|
|
2004-09-11 23:24:30 +00:00
|
|
|
case eCursor_nw_resize:
|
|
|
|
case eCursor_se_resize:
|
2000-04-30 15:29:32 +00:00
|
|
|
newCursor = ::LoadCursor(NULL, IDC_SIZENWSE);
|
|
|
|
break;
|
|
|
|
|
2004-09-11 23:24:30 +00:00
|
|
|
case eCursor_ne_resize:
|
|
|
|
case eCursor_sw_resize:
|
2000-04-30 15:29:32 +00:00
|
|
|
newCursor = ::LoadCursor(NULL, IDC_SIZENESW);
|
|
|
|
break;
|
|
|
|
|
2000-03-21 22:06:29 +00:00
|
|
|
case eCursor_crosshair:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_CROSS);
|
|
|
|
break;
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2000-03-21 22:06:29 +00:00
|
|
|
case eCursor_move:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_SIZEALL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_help:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_HELP);
|
|
|
|
break;
|
|
|
|
|
2000-05-07 05:14:43 +00:00
|
|
|
case eCursor_copy: // CSS3
|
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_COPY));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_alias:
|
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_ALIAS));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_cell:
|
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_CELL));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_grab:
|
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_GRAB));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_grabbing:
|
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_GRABBING));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_spinning:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_APPSTARTING);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_context_menu:
|
2004-09-11 23:24:30 +00:00
|
|
|
// XXX this CSS3 cursor needs to be implemented
|
|
|
|
break;
|
|
|
|
|
2003-05-02 22:23:55 +00:00
|
|
|
case eCursor_zoom_in:
|
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_ZOOMIN));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_zoom_out:
|
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_ZOOMOUT));
|
|
|
|
break;
|
|
|
|
|
2004-09-11 23:24:30 +00:00
|
|
|
case eCursor_not_allowed:
|
|
|
|
case eCursor_no_drop:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_NO);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_col_resize:
|
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_COLRESIZE));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_row_resize:
|
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_ROWRESIZE));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_vertical_text:
|
|
|
|
newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_VERTICALTEXT));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_all_scroll:
|
|
|
|
// XXX not 100% appropriate perhaps
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_SIZEALL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_nesw_resize:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_SIZENESW);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_nwse_resize:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_SIZENWSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_ns_resize:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_SIZENS);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eCursor_ew_resize:
|
|
|
|
newCursor = ::LoadCursor(NULL, IDC_SIZEWE);
|
|
|
|
break;
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
default:
|
2005-03-15 22:13:12 +00:00
|
|
|
NS_ERROR("Invalid cursor type");
|
1998-04-13 20:24:54 +00:00
|
|
|
break;
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (NULL != newCursor) {
|
|
|
|
mCursor = aCursor;
|
|
|
|
HCURSOR oldCursor = ::SetCursor(newCursor);
|
2005-04-13 05:52:02 +00:00
|
|
|
|
|
|
|
if (gHCursor == oldCursor) {
|
|
|
|
NS_IF_RELEASE(gCursorImgContainer);
|
2005-10-13 15:07:56 +00:00
|
|
|
if (gHCursor != NULL)
|
|
|
|
::DestroyIcon(gHCursor);
|
2005-04-13 05:52:02 +00:00
|
|
|
gHCursor = NULL;
|
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
2007-02-20 19:45:17 +00:00
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
2002-02-20 03:33:52 +00:00
|
|
|
|
2005-04-13 05:52:02 +00:00
|
|
|
// static
|
|
|
|
PRUint8* nsWindow::Data8BitTo1Bit(PRUint8* aAlphaData,
|
|
|
|
PRUint32 aAlphaBytesPerRow,
|
|
|
|
PRUint32 aWidth, PRUint32 aHeight)
|
|
|
|
{
|
2006-12-04 23:47:34 +00:00
|
|
|
// We need (aWidth + 7) / 8 bytes plus zero-padding up to a multiple of
|
|
|
|
// 4 bytes for each row (HBITMAP requirement). Bug 353553.
|
|
|
|
PRUint32 outBpr = ((aWidth + 31) / 8) & ~3;
|
2005-04-13 05:52:02 +00:00
|
|
|
|
|
|
|
PRUint8* outData = new PRUint8[outBpr * aHeight];
|
|
|
|
if (!outData)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
PRUint8 *outRow = outData,
|
|
|
|
*alphaRow = aAlphaData;
|
|
|
|
|
|
|
|
for (PRUint32 curRow = 0; curRow < aHeight; curRow++) {
|
|
|
|
PRUint8 *arow = alphaRow;
|
2006-12-04 23:47:34 +00:00
|
|
|
PRUint8 *nextOutRow = outRow + outBpr;
|
2005-04-13 05:52:02 +00:00
|
|
|
PRUint8 alphaPixels = 0;
|
|
|
|
PRUint8 offset = 7;
|
|
|
|
|
|
|
|
for (PRUint32 curCol = 0; curCol < aWidth; curCol++) {
|
|
|
|
if (*alphaRow++ > 0)
|
|
|
|
alphaPixels |= (1 << offset);
|
|
|
|
|
|
|
|
if (offset == 0) {
|
|
|
|
*outRow++ = alphaPixels;
|
|
|
|
offset = 7;
|
|
|
|
alphaPixels = 0;
|
|
|
|
} else {
|
|
|
|
offset--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (offset != 7)
|
|
|
|
*outRow++ = alphaPixels;
|
|
|
|
|
|
|
|
alphaRow = arow + aAlphaBytesPerRow;
|
2006-12-04 23:47:34 +00:00
|
|
|
while (outRow != nextOutRow)
|
|
|
|
*outRow++ = 0; // padding
|
2005-04-13 05:52:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return outData;
|
|
|
|
}
|
|
|
|
|
2005-03-15 22:13:12 +00:00
|
|
|
// static
|
|
|
|
PRUint8* nsWindow::DataToAData(PRUint8* aImageData, PRUint32 aImageBytesPerRow,
|
|
|
|
PRUint8* aAlphaData, PRUint32 aAlphaBytesPerRow,
|
|
|
|
PRUint32 aWidth, PRUint32 aHeight)
|
|
|
|
{
|
|
|
|
// We will have 32 bpp, so bytes per row will be 4 * w
|
|
|
|
PRUint32 outBpr = aWidth * 4;
|
|
|
|
|
|
|
|
// Avoid overflows
|
|
|
|
if (aWidth > 0xfff || aHeight > 0xfff)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
PRUint8* outData = new PRUint8[outBpr * aHeight];
|
|
|
|
if (!outData)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
PRUint8 *outRow = outData,
|
|
|
|
*imageRow = aImageData,
|
|
|
|
*alphaRow = aAlphaData;
|
|
|
|
for (PRUint32 curRow = 0; curRow < aHeight; curRow++) {
|
|
|
|
PRUint8 *irow = imageRow, *arow = alphaRow;
|
|
|
|
for (PRUint32 curCol = 0; curCol < aWidth; curCol++) {
|
|
|
|
*outRow++ = *imageRow++; // B
|
|
|
|
*outRow++ = *imageRow++; // G
|
|
|
|
*outRow++ = *imageRow++; // R
|
|
|
|
*outRow++ = *alphaRow++; // A
|
|
|
|
}
|
|
|
|
imageRow = irow + aImageBytesPerRow;
|
|
|
|
alphaRow = arow + aAlphaBytesPerRow;
|
|
|
|
}
|
|
|
|
return outData;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
HBITMAP nsWindow::DataToBitmap(PRUint8* aImageData,
|
|
|
|
PRUint32 aWidth,
|
|
|
|
PRUint32 aHeight,
|
|
|
|
PRUint32 aDepth)
|
|
|
|
{
|
2005-04-13 05:52:02 +00:00
|
|
|
if (aDepth == 8 || aDepth == 4) {
|
|
|
|
NS_WARNING("nsWindow::DataToBitmap can't handle 4 or 8 bit images");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// dc must be a CreateCompatibleDC.
|
|
|
|
// GetDC, cursors, 1 bit masks, and Win9x do not mix for some reason.
|
|
|
|
HDC dc = ::CreateCompatibleDC(NULL);
|
|
|
|
|
|
|
|
// force dc into color/bw mode
|
|
|
|
int planes = ::GetDeviceCaps(dc, PLANES);
|
|
|
|
int bpp = (aDepth == 1) ? 1 : ::GetDeviceCaps(dc, BITSPIXEL);
|
|
|
|
|
|
|
|
HBITMAP tBitmap = ::CreateBitmap(1, 1, planes, bpp, NULL);
|
|
|
|
HBITMAP oldbits = (HBITMAP)::SelectObject(dc, tBitmap);
|
|
|
|
|
2005-07-18 16:04:45 +00:00
|
|
|
#ifndef WINCE
|
2005-03-15 22:13:12 +00:00
|
|
|
if (aDepth == 32 && IsCursorTranslucencySupported()) {
|
|
|
|
// Alpha channel. We need the new header.
|
|
|
|
BITMAPV4HEADER head = { 0 };
|
|
|
|
head.bV4Size = sizeof(head);
|
|
|
|
head.bV4Width = aWidth;
|
|
|
|
head.bV4Height = aHeight;
|
|
|
|
head.bV4Planes = 1;
|
|
|
|
head.bV4BitCount = aDepth;
|
|
|
|
head.bV4V4Compression = BI_BITFIELDS;
|
|
|
|
head.bV4SizeImage = 0; // Uncompressed
|
|
|
|
head.bV4XPelsPerMeter = 0;
|
|
|
|
head.bV4YPelsPerMeter = 0;
|
|
|
|
head.bV4ClrUsed = 0;
|
|
|
|
head.bV4ClrImportant = 0;
|
|
|
|
|
|
|
|
head.bV4RedMask = 0x00FF0000;
|
|
|
|
head.bV4GreenMask = 0x0000FF00;
|
|
|
|
head.bV4BlueMask = 0x000000FF;
|
|
|
|
head.bV4AlphaMask = 0xFF000000;
|
|
|
|
|
|
|
|
HBITMAP bmp = ::CreateDIBitmap(dc,
|
|
|
|
NS_REINTERPRET_CAST(CONST BITMAPINFOHEADER*, &head),
|
|
|
|
CBM_INIT,
|
|
|
|
aImageData,
|
|
|
|
NS_REINTERPRET_CAST(CONST BITMAPINFO*, &head),
|
|
|
|
DIB_RGB_COLORS);
|
2005-04-13 05:52:02 +00:00
|
|
|
|
|
|
|
::SelectObject(dc, oldbits);
|
|
|
|
::DeleteObject(tBitmap);
|
|
|
|
::DeleteDC(dc);
|
2005-03-15 22:13:12 +00:00
|
|
|
return bmp;
|
|
|
|
}
|
2005-07-18 16:04:45 +00:00
|
|
|
#endif
|
2005-04-13 05:52:02 +00:00
|
|
|
|
2005-03-15 22:13:12 +00:00
|
|
|
BITMAPINFOHEADER head = { 0 };
|
|
|
|
|
2005-04-13 05:52:02 +00:00
|
|
|
head.biSize = sizeof(BITMAPINFOHEADER);
|
2005-03-15 22:13:12 +00:00
|
|
|
head.biWidth = aWidth;
|
|
|
|
head.biHeight = aHeight;
|
|
|
|
head.biPlanes = 1;
|
2005-04-13 05:52:02 +00:00
|
|
|
head.biBitCount = (WORD)aDepth;
|
2005-03-15 22:13:12 +00:00
|
|
|
head.biCompression = BI_RGB;
|
|
|
|
head.biSizeImage = 0; // Uncompressed
|
|
|
|
head.biXPelsPerMeter = 0;
|
|
|
|
head.biYPelsPerMeter = 0;
|
2005-04-13 05:52:02 +00:00
|
|
|
head.biClrUsed = 0;
|
2005-03-15 22:13:12 +00:00
|
|
|
head.biClrImportant = 0;
|
|
|
|
|
2005-04-13 05:52:02 +00:00
|
|
|
char reserved_space[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 2];
|
2005-03-15 22:13:12 +00:00
|
|
|
BITMAPINFO& bi = *(BITMAPINFO*)reserved_space;
|
|
|
|
|
|
|
|
bi.bmiHeader = head;
|
|
|
|
|
|
|
|
if (aDepth == 1) {
|
|
|
|
RGBQUAD black = { 0, 0, 0, 0 };
|
|
|
|
RGBQUAD white = { 255, 255, 255, 0 };
|
|
|
|
|
|
|
|
bi.bmiColors[0] = white;
|
|
|
|
bi.bmiColors[1] = black;
|
|
|
|
}
|
|
|
|
|
|
|
|
HBITMAP bmp = ::CreateDIBitmap(dc, &head, CBM_INIT, aImageData, &bi, DIB_RGB_COLORS);
|
2005-04-13 05:52:02 +00:00
|
|
|
|
|
|
|
::SelectObject(dc, oldbits);
|
|
|
|
::DeleteObject(tBitmap);
|
|
|
|
::DeleteDC(dc);
|
2005-03-15 22:13:12 +00:00
|
|
|
return bmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
HBITMAP nsWindow::CreateOpaqueAlphaChannel(PRUint32 aWidth, PRUint32 aHeight)
|
|
|
|
{
|
2006-12-04 23:47:34 +00:00
|
|
|
// Make up an opaque alpha channel.
|
|
|
|
// We need (aWidth + 7) / 8 bytes plus zero-padding up to a multiple of
|
|
|
|
// 4 bytes for each row (HBITMAP requirement). Bug 353553.
|
|
|
|
PRUint32 nonPaddedBytesPerRow = (aWidth + 7) / 8;
|
|
|
|
PRUint32 abpr = (nonPaddedBytesPerRow + 3) & ~3;
|
|
|
|
PRUint32 bufferSize = abpr * aHeight;
|
|
|
|
PRUint8* opaque = (PRUint8*)malloc(bufferSize);
|
2005-03-15 22:13:12 +00:00
|
|
|
if (!opaque)
|
|
|
|
return NULL;
|
|
|
|
|
2006-12-04 23:47:34 +00:00
|
|
|
memset(opaque, 0xff, bufferSize);
|
|
|
|
|
|
|
|
// If we have row padding, set it to zero.
|
|
|
|
if (nonPaddedBytesPerRow != abpr) {
|
|
|
|
PRUint8* p = opaque;
|
|
|
|
PRUint8* end = opaque + bufferSize;
|
|
|
|
while (p != end) {
|
|
|
|
PRUint8* nextRow = p + abpr;
|
|
|
|
p += nonPaddedBytesPerRow;
|
|
|
|
while (p != nextRow)
|
|
|
|
*p++ = 0; // padding
|
|
|
|
}
|
|
|
|
}
|
2005-03-15 22:13:12 +00:00
|
|
|
|
|
|
|
HBITMAP hAlpha = DataToBitmap(opaque, aWidth, aHeight, 1);
|
|
|
|
free(opaque);
|
|
|
|
return hAlpha;
|
|
|
|
}
|
|
|
|
|
2005-07-01 04:29:42 +00:00
|
|
|
NS_IMETHODIMP nsWindow::SetCursor(imgIContainer* aCursor,
|
|
|
|
PRUint32 aHotspotX, PRUint32 aHotspotY)
|
2005-03-15 22:13:12 +00:00
|
|
|
{
|
2005-04-13 05:52:02 +00:00
|
|
|
if (gCursorImgContainer == aCursor && gHCursor) {
|
|
|
|
::SetCursor(gHCursor);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-01-25 02:17:22 +00:00
|
|
|
// Get the image data
|
2006-11-02 21:25:14 +00:00
|
|
|
nsCOMPtr<gfxIImageFrame> frame;
|
|
|
|
aCursor->GetFrameAt(0, getter_AddRefs(frame));
|
|
|
|
if (!frame)
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
|
|
|
PRInt32 width, height;
|
|
|
|
frame->GetWidth(&width);
|
|
|
|
frame->GetHeight(&height);
|
2007-01-25 02:17:22 +00:00
|
|
|
|
|
|
|
// Reject cursors greater than 128 pixels in some direction, to prevent
|
|
|
|
// spoofing.
|
|
|
|
// XXX ideally we should rescale. Also, we could modify the API to
|
|
|
|
// allow trusted content to set larger cursors.
|
|
|
|
if (width > 128 || height > 128)
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
|
|
|
#ifdef MOZ_CAIRO_GFX
|
|
|
|
PRUint32 bpr;
|
|
|
|
gfx_format format;
|
2006-11-02 21:25:14 +00:00
|
|
|
frame->GetImageBytesPerRow(&bpr);
|
|
|
|
frame->GetFormat(&format);
|
|
|
|
|
|
|
|
frame->LockImageData();
|
|
|
|
|
|
|
|
PRUint32 dataLen;
|
|
|
|
PRUint8 *data;
|
|
|
|
nsresult rv = frame->GetImageData(&data, &dataLen);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
frame->UnlockImageData();
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* flip the image so that it is stored bottom-up */
|
|
|
|
PRUint8 *bottomUpData = (PRUint8*)malloc(dataLen);
|
|
|
|
if (!bottomUpData) {
|
|
|
|
frame->UnlockImageData();
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (format == gfxIFormats::RGB_A8 || format == gfxIFormats::BGR_A8) {
|
|
|
|
for (PRInt32 i = 0; i < height; ++i) {
|
|
|
|
PRUint32 srcOffset = i * bpr;
|
|
|
|
PRUint32 dstOffset = dataLen - (bpr * (i + 1));
|
|
|
|
PRUint32 *srcRow = (PRUint32*)(data + srcOffset);
|
|
|
|
PRUint32 *dstRow = (PRUint32*)(bottomUpData + dstOffset);
|
|
|
|
memcpy(dstRow, srcRow, bpr);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (PRInt32 i = 0; i < height; ++i) {
|
|
|
|
PRUint32 srcOffset = i * bpr;
|
|
|
|
PRUint32 dstOffset = dataLen - (bpr * (i + 1));
|
|
|
|
PRUint32 *srcRow = (PRUint32*)(data + srcOffset);
|
|
|
|
PRUint32 *dstRow = (PRUint32*)(bottomUpData + dstOffset);
|
|
|
|
for (PRInt32 x = 0; x < width; ++x) {
|
|
|
|
dstRow[x] = (srcRow[x] & 0xFFFFFF) | (0xFF << 24);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
HBITMAP bmp = DataToBitmap(bottomUpData, width, height, 32);
|
|
|
|
|
|
|
|
free(bottomUpData);
|
|
|
|
|
|
|
|
frame->UnlockImageData();
|
|
|
|
|
|
|
|
ICONINFO info = {0};
|
|
|
|
info.fIcon = FALSE;
|
|
|
|
info.xHotspot = aHotspotX;
|
|
|
|
info.yHotspot = aHotspotY;
|
|
|
|
info.hbmMask = bmp;
|
|
|
|
info.hbmColor = bmp;
|
|
|
|
|
|
|
|
HCURSOR cursor = ::CreateIconIndirect(&info);
|
|
|
|
::DeleteObject(bmp);
|
|
|
|
if (cursor == NULL) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
mCursor = nsCursor(-1);
|
|
|
|
::SetCursor(cursor);
|
|
|
|
|
|
|
|
NS_IF_RELEASE(gCursorImgContainer);
|
|
|
|
gCursorImgContainer = aCursor;
|
|
|
|
NS_ADDREF(gCursorImgContainer);
|
|
|
|
|
|
|
|
if (gHCursor != NULL)
|
|
|
|
::DestroyIcon(gHCursor);
|
|
|
|
gHCursor = cursor;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2005-03-15 22:13:12 +00:00
|
|
|
gfx_format format;
|
|
|
|
nsresult rv = frame->GetFormat(&format);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
if (format != gfxIFormats::BGR_A1 && format != gfxIFormats::BGR_A8 &&
|
|
|
|
format != gfxIFormats::BGR)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
2005-04-13 05:52:02 +00:00
|
|
|
// On Win2k with nVidia video drivers 71.84 at 32 bit color, cursors that
|
|
|
|
// have 8 bit alpha are truncated to 64x64. Skip cursors larger than that.
|
2007-01-25 02:17:22 +00:00
|
|
|
// This is redundant with checks above, but we'll leave it in as a reminder
|
|
|
|
// in case we start accepting larger cursors again
|
2005-04-13 05:52:02 +00:00
|
|
|
if (IsWin2k() && (format == gfxIFormats::BGR_A8) &&
|
|
|
|
(width > 64 || height > 64))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2005-03-15 22:13:12 +00:00
|
|
|
PRUint32 bpr;
|
|
|
|
rv = frame->GetImageBytesPerRow(&bpr);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
frame->LockImageData();
|
|
|
|
PRUint32 dataLen;
|
|
|
|
PRUint8* data;
|
|
|
|
rv = frame->GetImageData(&data, &dataLen);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
frame->UnlockImageData();
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
HBITMAP hBMP = NULL;
|
|
|
|
if (format != gfxIFormats::BGR_A8) {
|
|
|
|
hBMP = DataToBitmap(data, width, height, 24);
|
|
|
|
if (hBMP == NULL) {
|
|
|
|
frame->UnlockImageData();
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HBITMAP hAlpha = NULL;
|
|
|
|
if (format == gfxIFormats::BGR) {
|
|
|
|
hAlpha = CreateOpaqueAlphaChannel(width, height);
|
|
|
|
} else {
|
|
|
|
PRUint32 abpr;
|
|
|
|
rv = frame->GetAlphaBytesPerRow(&abpr);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
frame->UnlockImageData();
|
|
|
|
if (hBMP != NULL)
|
|
|
|
::DeleteObject(hBMP);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint8* adata;
|
|
|
|
frame->LockAlphaData();
|
|
|
|
rv = frame->GetAlphaData(&adata, &dataLen);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
if (hBMP != NULL)
|
|
|
|
::DeleteObject(hBMP);
|
|
|
|
frame->UnlockImageData();
|
|
|
|
frame->UnlockAlphaData();
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (format == gfxIFormats::BGR_A8) {
|
2005-04-13 05:52:02 +00:00
|
|
|
// Convert BGR_A8 to BGRA.
|
|
|
|
// Some platforms (or video cards?) on 32bit color mode will ignore
|
|
|
|
// hAlpha. For them, we could speed up things by creating an opaque alpha
|
|
|
|
// channel, but since we don't know how to determine whether hAlpha is
|
|
|
|
// ignored, create a proper 1 bit alpha channel to supplement the RGBA.
|
|
|
|
// Plus, on non-32bit color and possibly other platforms, the alpha
|
|
|
|
// of RGBA is ignored.
|
2005-03-15 22:13:12 +00:00
|
|
|
PRUint8* bgra8data = DataToAData(data, bpr, adata, abpr, width, height);
|
|
|
|
if (bgra8data) {
|
|
|
|
hBMP = DataToBitmap(bgra8data, width, height, 32);
|
|
|
|
if (hBMP != NULL) {
|
2005-04-13 05:52:02 +00:00
|
|
|
PRUint8* a1data = Data8BitTo1Bit(adata, abpr, width, height);
|
|
|
|
if (a1data) {
|
|
|
|
hAlpha = DataToBitmap(a1data, width, height, 1);
|
|
|
|
delete [] a1data;
|
|
|
|
}
|
2005-03-15 22:13:12 +00:00
|
|
|
}
|
2005-04-13 05:52:02 +00:00
|
|
|
delete [] bgra8data;
|
2005-03-15 22:13:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
hAlpha = DataToBitmap(adata, width, height, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
frame->UnlockAlphaData();
|
|
|
|
}
|
|
|
|
frame->UnlockImageData();
|
|
|
|
if (hBMP == NULL) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
if (hAlpha == NULL) {
|
|
|
|
::DeleteObject(hBMP);
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ICONINFO info = {0};
|
|
|
|
info.fIcon = FALSE;
|
2005-07-01 04:29:42 +00:00
|
|
|
info.xHotspot = aHotspotX;
|
|
|
|
info.yHotspot = aHotspotY;
|
2005-03-15 22:13:12 +00:00
|
|
|
info.hbmMask = hAlpha;
|
|
|
|
info.hbmColor = hBMP;
|
|
|
|
|
|
|
|
HCURSOR cursor = ::CreateIconIndirect(&info);
|
|
|
|
::DeleteObject(hBMP);
|
|
|
|
::DeleteObject(hAlpha);
|
|
|
|
if (cursor == NULL) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
mCursor = nsCursor(-1);
|
|
|
|
::SetCursor(cursor);
|
2005-04-13 05:52:02 +00:00
|
|
|
|
|
|
|
NS_IF_RELEASE(gCursorImgContainer);
|
|
|
|
gCursorImgContainer = aCursor;
|
|
|
|
NS_ADDREF(gCursorImgContainer);
|
|
|
|
|
|
|
|
if (gHCursor != NULL)
|
|
|
|
::DestroyIcon(gHCursor);
|
|
|
|
gHCursor = cursor;
|
|
|
|
|
2006-11-02 21:25:14 +00:00
|
|
|
#endif
|
|
|
|
|
2005-03-15 22:13:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_IMETHODIMP nsWindow::HideWindowChrome(PRBool aShouldHide)
|
2002-02-20 03:33:52 +00:00
|
|
|
{
|
2005-08-12 03:29:18 +00:00
|
|
|
HWND hwnd = GetTopLevelHWND(mWnd, PR_TRUE);
|
2004-08-02 20:08:43 +00:00
|
|
|
if (!GetNSWindowPtr(hwnd))
|
|
|
|
{
|
|
|
|
NS_WARNING("Trying to hide window decorations in an embedded context");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2002-02-20 03:33:52 +00:00
|
|
|
DWORD style, exStyle;
|
|
|
|
if (aShouldHide) {
|
2006-04-04 20:57:13 +00:00
|
|
|
DWORD tempStyle = ::GetWindowLongW(hwnd, GWL_STYLE);
|
|
|
|
DWORD tempExStyle = ::GetWindowLongW(hwnd, GWL_EXSTYLE);
|
2002-02-20 03:33:52 +00:00
|
|
|
|
2004-12-09 17:56:46 +00:00
|
|
|
style = tempStyle & ~(WS_CAPTION | WS_THICKFRAME);
|
2005-10-27 16:22:01 +00:00
|
|
|
exStyle = tempExStyle & ~(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE |
|
2004-12-09 17:56:46 +00:00
|
|
|
WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
|
2004-08-02 20:08:43 +00:00
|
|
|
|
2002-02-20 03:33:52 +00:00
|
|
|
mOldStyle = tempStyle;
|
|
|
|
mOldExStyle = tempExStyle;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!mOldStyle || !mOldExStyle) {
|
2006-04-04 20:57:13 +00:00
|
|
|
mOldStyle = ::GetWindowLongW(hwnd, GWL_STYLE);
|
|
|
|
mOldExStyle = ::GetWindowLongW(hwnd, GWL_EXSTYLE);
|
2002-02-20 03:33:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
style = mOldStyle;
|
|
|
|
exStyle = mOldExStyle;
|
|
|
|
}
|
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
::SetWindowLongW(hwnd, GWL_STYLE, style);
|
|
|
|
::SetWindowLongW(hwnd, GWL_EXSTYLE, exStyle);
|
2002-02-20 03:33:52 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2001-05-01 22:50:16 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Validate a visible area of a widget.
|
|
|
|
//
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_METHOD nsWindow::Validate()
|
|
|
|
{
|
|
|
|
if (mWnd)
|
|
|
|
VERIFY(::ValidateRect(mWnd, NULL));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Invalidate this component visible area
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::Invalidate(PRBool aIsSynchronous)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
if (mWnd)
|
|
|
|
{
|
1999-09-09 03:47:26 +00:00
|
|
|
#ifdef NS_DEBUG
|
2004-09-03 08:44:23 +00:00
|
|
|
debug_DumpInvalidate(stdout,
|
|
|
|
this,
|
|
|
|
nsnull,
|
|
|
|
aIsSynchronous,
|
|
|
|
nsCAutoString("noname"),
|
|
|
|
(PRInt32) mWnd);
|
1999-09-09 03:47:26 +00:00
|
|
|
#endif // NS_DEBUG
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2006-06-16 02:27:37 +00:00
|
|
|
VERIFY(::InvalidateRect(mWnd, NULL, FALSE));
|
|
|
|
|
|
|
|
if (aIsSynchronous) {
|
|
|
|
VERIFY(::UpdateWindow(mWnd));
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
2004-07-27 19:14:44 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-10-09 15:18:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Invalidate this component visible area
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_METHOD nsWindow::Invalidate(const nsRect & aRect, PRBool aIsSynchronous)
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
if (mWnd)
|
1999-09-09 03:47:26 +00:00
|
|
|
{
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
debug_DumpInvalidate(stdout,
|
|
|
|
this,
|
|
|
|
&aRect,
|
|
|
|
aIsSynchronous,
|
2000-09-03 00:46:03 +00:00
|
|
|
nsCAutoString("noname"),
|
1999-09-09 03:47:26 +00:00
|
|
|
(PRInt32) mWnd);
|
|
|
|
#endif // NS_DEBUG
|
|
|
|
|
2006-06-16 02:27:37 +00:00
|
|
|
RECT rect;
|
2004-07-27 19:14:44 +00:00
|
|
|
|
2006-06-16 02:27:37 +00:00
|
|
|
rect.left = aRect.x;
|
|
|
|
rect.top = aRect.y;
|
|
|
|
rect.right = aRect.x + aRect.width;
|
|
|
|
rect.bottom = aRect.y + aRect.height;
|
2004-07-27 19:14:44 +00:00
|
|
|
|
2006-06-16 02:27:37 +00:00
|
|
|
VERIFY(::InvalidateRect(mWnd, &rect, FALSE));
|
|
|
|
|
|
|
|
if (aIsSynchronous) {
|
|
|
|
VERIFY(::UpdateWindow(mWnd));
|
1998-10-09 15:18:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-20 22:33:42 +00:00
|
|
|
nsWindow::InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
if (mWnd) {
|
2006-06-16 02:27:37 +00:00
|
|
|
HRGN nativeRegion;
|
|
|
|
rv = aRegion->GetNativeRegion((void *&)nativeRegion);
|
|
|
|
if (nativeRegion) {
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
VERIFY(::InvalidateRgn(mWnd, nativeRegion, FALSE));
|
|
|
|
|
|
|
|
if (aIsSynchronous) {
|
|
|
|
VERIFY(::UpdateWindow(mWnd));
|
1999-11-20 22:33:42 +00:00
|
|
|
}
|
|
|
|
}
|
2006-06-16 02:27:37 +00:00
|
|
|
} else {
|
|
|
|
rv = NS_ERROR_FAILURE;
|
1999-11-20 22:33:42 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
return rv;
|
1999-11-20 22:33:42 +00:00
|
|
|
}
|
|
|
|
|
1998-10-27 00:16:59 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Force a synchronous repaint of the window
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP nsWindow::Update()
|
|
|
|
{
|
2004-07-27 19:14:44 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
1999-04-06 00:11:43 +00:00
|
|
|
// updates can come through for windows no longer holding an mWnd during
|
|
|
|
// deletes triggered by JavaScript in buttons with mouse feedback
|
|
|
|
if (mWnd)
|
2006-06-16 02:27:37 +00:00
|
|
|
VERIFY(::UpdateWindow(mWnd));
|
|
|
|
|
2004-07-27 19:14:44 +00:00
|
|
|
return rv;
|
1998-10-27 00:16:59 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Return some native data according to aDataType
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void* nsWindow::GetNativeData(PRUint32 aDataType)
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
switch (aDataType) {
|
|
|
|
case NS_NATIVE_WIDGET:
|
|
|
|
case NS_NATIVE_WINDOW:
|
|
|
|
case NS_NATIVE_PLUGIN_PORT:
|
|
|
|
return (void*)mWnd;
|
|
|
|
case NS_NATIVE_GRAPHIC:
|
|
|
|
// XXX: This is sleezy!! Remember to Release the DC after using it!
|
2004-07-27 19:14:44 +00:00
|
|
|
#ifdef MOZ_XUL
|
2006-04-04 20:57:13 +00:00
|
|
|
return (void*)(mIsTranslucent) ?
|
|
|
|
mMemoryDC : ::GetDC(mWnd);
|
2004-07-27 19:14:44 +00:00
|
|
|
#else
|
2004-09-03 08:44:23 +00:00
|
|
|
return (void*)::GetDC(mWnd);
|
2004-07-27 19:14:44 +00:00
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
case NS_NATIVE_COLORMAP:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
return NULL;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-05-27 23:20:09 +00:00
|
|
|
//~~~
|
|
|
|
void nsWindow::FreeNativeData(void * data, PRUint32 aDataType)
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
switch (aDataType)
|
1999-05-27 23:20:09 +00:00
|
|
|
{
|
|
|
|
case NS_NATIVE_GRAPHIC:
|
2004-07-27 19:14:44 +00:00
|
|
|
#ifdef MOZ_XUL
|
2006-04-04 20:57:13 +00:00
|
|
|
if (!mIsTranslucent)
|
2004-09-03 08:44:23 +00:00
|
|
|
::ReleaseDC(mWnd, (HDC)data);
|
2004-07-27 19:14:44 +00:00
|
|
|
#else
|
|
|
|
::ReleaseDC(mWnd, (HDC)data);
|
|
|
|
#endif
|
|
|
|
break;
|
1999-05-27 23:20:09 +00:00
|
|
|
case NS_NATIVE_WIDGET:
|
|
|
|
case NS_NATIVE_WINDOW:
|
|
|
|
case NS_NATIVE_PLUGIN_PORT:
|
|
|
|
case NS_NATIVE_COLORMAP:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set the colormap of the window
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::SetColorMap(nsColorMap *aColorMap)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2001-08-09 20:22:39 +00:00
|
|
|
#if 0
|
2004-09-03 08:44:23 +00:00
|
|
|
if (mPalette != NULL) {
|
|
|
|
::DeleteObject(mPalette);
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
PRUint8 *map = aColorMap->Index;
|
|
|
|
LPLOGPALETTE pLogPal = (LPLOGPALETTE) new char[2 * sizeof(WORD) +
|
|
|
|
aColorMap->NumColors * sizeof(PALETTEENTRY)];
|
|
|
|
pLogPal->palVersion = 0x300;
|
|
|
|
pLogPal->palNumEntries = aColorMap->NumColors;
|
|
|
|
for(int i = 0; i < aColorMap->NumColors; i++)
|
|
|
|
{
|
2001-08-09 20:22:39 +00:00
|
|
|
pLogPal->palPalEntry[i].peRed = *map++;
|
|
|
|
pLogPal->palPalEntry[i].peGreen = *map++;
|
|
|
|
pLogPal->palPalEntry[i].peBlue = *map++;
|
|
|
|
pLogPal->palPalEntry[i].peFlags = 0;
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
mPalette = ::CreatePalette(pLogPal);
|
|
|
|
delete pLogPal;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_ASSERTION(mPalette != NULL, "Null palette");
|
|
|
|
if (mPalette != NULL) {
|
|
|
|
HDC hDC = ::GetDC(mWnd);
|
|
|
|
HPALETTE hOldPalette = ::SelectPalette(hDC, mPalette, TRUE);
|
|
|
|
::RealizePalette(hDC);
|
|
|
|
::SelectPalette(hDC, hOldPalette, TRUE);
|
|
|
|
::ReleaseDC(mWnd, hDC);
|
|
|
|
}
|
2001-08-09 20:22:39 +00:00
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Scroll the bits of a window
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2000-01-15 01:38:50 +00:00
|
|
|
//XXX Scroll is obsolete and should go away soon
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
RECT trect;
|
|
|
|
|
|
|
|
if (nsnull != aClipRect)
|
|
|
|
{
|
|
|
|
trect.left = aClipRect->x;
|
|
|
|
trect.top = aClipRect->y;
|
|
|
|
trect.right = aClipRect->XMost();
|
|
|
|
trect.bottom = aClipRect->YMost();
|
|
|
|
}
|
|
|
|
|
2007-05-28 03:17:20 +00:00
|
|
|
::ScrollWindowEx(mWnd, aDx, aDy, NULL, (nsnull != aClipRect) ? &trect : NULL,
|
1998-07-26 04:24:42 +00:00
|
|
|
NULL, NULL, SW_INVALIDATE | SW_SCROLLCHILDREN);
|
1998-04-13 20:24:54 +00:00
|
|
|
::UpdateWindow(mWnd);
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2000-01-15 01:38:50 +00:00
|
|
|
NS_IMETHODIMP nsWindow::ScrollWidgets(PRInt32 aDx, PRInt32 aDy)
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
// Scroll the entire contents of the window + change the offset of any child windows
|
|
|
|
::ScrollWindowEx(mWnd, aDx, aDy, NULL, NULL, NULL,
|
|
|
|
NULL, SW_INVALIDATE | SW_SCROLLCHILDREN);
|
2000-01-15 01:38:50 +00:00
|
|
|
::UpdateWindow(mWnd); // Force synchronous generation of NS_PAINT
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWindow::ScrollRect(nsRect &aRect, PRInt32 aDx, PRInt32 aDy)
|
|
|
|
{
|
|
|
|
RECT trect;
|
|
|
|
|
|
|
|
trect.left = aRect.x;
|
|
|
|
trect.top = aRect.y;
|
|
|
|
trect.right = aRect.XMost();
|
|
|
|
trect.bottom = aRect.YMost();
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// Scroll the bits in the window defined by trect.
|
|
|
|
// Child windows are not scrolled.
|
|
|
|
::ScrollWindowEx(mWnd, aDx, aDy, &trect, NULL, NULL,
|
|
|
|
NULL, SW_INVALIDATE);
|
2000-01-15 01:38:50 +00:00
|
|
|
::UpdateWindow(mWnd); // Force synchronous generation of NS_PAINT
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-05-04 19:25:25 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Every function that needs a thread switch goes through this function
|
|
|
|
// by calling SendMessage (..WM_CALLMETHOD..) in nsToolkit::CallMethod.
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
BOOL nsWindow::CallMethod(MethodInfo *info)
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
BOOL bRet = TRUE;
|
|
|
|
|
|
|
|
switch (info->methodId) {
|
|
|
|
case nsWindow::CREATE:
|
|
|
|
NS_ASSERTION(info->nArgs == 7, "Wrong number of arguments to CallMethod");
|
|
|
|
Create((nsIWidget*)(info->args[0]),
|
|
|
|
(nsRect&)*(nsRect*)(info->args[1]),
|
|
|
|
(EVENT_CALLBACK)(info->args[2]),
|
|
|
|
(nsIDeviceContext*)(info->args[3]),
|
|
|
|
(nsIAppShell *)(info->args[4]),
|
|
|
|
(nsIToolkit*)(info->args[5]),
|
|
|
|
(nsWidgetInitData*)(info->args[6]));
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case nsWindow::CREATE_NATIVE:
|
|
|
|
NS_ASSERTION(info->nArgs == 7, "Wrong number of arguments to CallMethod");
|
|
|
|
Create((nsNativeWidget)(info->args[0]),
|
|
|
|
(nsRect&)*(nsRect*)(info->args[1]),
|
|
|
|
(EVENT_CALLBACK)(info->args[2]),
|
|
|
|
(nsIDeviceContext*)(info->args[3]),
|
|
|
|
(nsIAppShell *)(info->args[4]),
|
|
|
|
(nsIToolkit*)(info->args[5]),
|
|
|
|
(nsWidgetInitData*)(info->args[6]));
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case nsWindow::DESTROY:
|
|
|
|
NS_ASSERTION(info->nArgs == 0, "Wrong number of arguments to CallMethod");
|
|
|
|
Destroy();
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case nsWindow::SET_FOCUS:
|
|
|
|
NS_ASSERTION(info->nArgs == 0, "Wrong number of arguments to CallMethod");
|
|
|
|
SetFocus(PR_FALSE);
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
default:
|
|
|
|
bRet = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
return bRet;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-03 22:28:00 +00:00
|
|
|
//-------------------------------------------------------------------------
|
2004-09-03 08:44:23 +00:00
|
|
|
void nsWindow::SetUpForPaint(HDC aHDC)
|
1998-08-03 22:28:00 +00:00
|
|
|
{
|
|
|
|
::SetBkColor (aHDC, NSRGB_2_COLOREF(mBackground));
|
|
|
|
::SetTextColor(aHDC, NSRGB_2_COLOREF(mForeground));
|
|
|
|
::SetBkMode (aHDC, TRANSPARENT);
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-03-09 23:48:58 +00:00
|
|
|
//---------------------------------------------------------
|
1999-08-26 14:41:17 +00:00
|
|
|
NS_METHOD nsWindow::EnableDragDrop(PRBool aEnable)
|
1999-03-09 23:48:58 +00:00
|
|
|
{
|
1999-08-26 14:41:17 +00:00
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
2005-02-23 07:07:51 +00:00
|
|
|
#ifndef WINCE
|
1999-08-26 14:41:17 +00:00
|
|
|
if (aEnable) {
|
|
|
|
if (nsnull == mNativeDragTarget) {
|
|
|
|
mNativeDragTarget = new nsNativeDragTarget(this);
|
|
|
|
if (NULL != mNativeDragTarget) {
|
|
|
|
mNativeDragTarget->AddRef();
|
|
|
|
if (S_OK == ::CoLockObjectExternal((LPUNKNOWN)mNativeDragTarget,TRUE,FALSE)) {
|
|
|
|
if (S_OK == ::RegisterDragDrop(mWnd, (LPDROPTARGET)mNativeDragTarget)) {
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
}
|
1999-04-17 13:45:10 +00:00
|
|
|
}
|
1999-08-26 14:41:17 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (nsnull != mWnd && NULL != mNativeDragTarget) {
|
|
|
|
::RevokeDragDrop(mWnd);
|
|
|
|
if (S_OK == ::CoLockObjectExternal((LPUNKNOWN)mNativeDragTarget, FALSE, TRUE)) {
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
NS_RELEASE(mNativeDragTarget);
|
|
|
|
}
|
|
|
|
}
|
2005-02-23 07:07:51 +00:00
|
|
|
#endif
|
1999-08-26 14:41:17 +00:00
|
|
|
return rv;
|
1999-03-09 23:48:58 +00:00
|
|
|
}
|
1999-03-01 16:22:40 +00:00
|
|
|
|
2000-02-02 15:00:59 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
UINT nsWindow::MapFromNativeToDOM(UINT aNativeKeyCode)
|
|
|
|
{
|
2000-05-03 21:34:09 +00:00
|
|
|
switch (aNativeKeyCode) {
|
2006-03-16 21:02:22 +00:00
|
|
|
case VK_OEM_1: return NS_VK_SEMICOLON; // 0xBA, For the US standard keyboard, the ';:' key
|
2006-06-06 01:52:46 +00:00
|
|
|
case VK_OEM_PLUS: return NS_VK_ADD; // 0xBB, For any country/region, the '+' key
|
2006-03-16 21:02:22 +00:00
|
|
|
case VK_OEM_MINUS: return NS_VK_SUBTRACT; // 0xBD, For any country/region, the '-' key
|
2000-02-02 15:00:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return aNativeKeyCode;
|
|
|
|
}
|
1999-04-23 14:30:51 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// OnKey
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2005-01-19 02:38:59 +00:00
|
|
|
PRBool nsWindow::DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode, UINT aVirtualCharCode,
|
|
|
|
LPARAM aKeyData, PRUint32 aFlags)
|
1999-04-23 14:30:51 +00:00
|
|
|
{
|
2005-04-28 23:48:28 +00:00
|
|
|
nsKeyEvent event(PR_TRUE, aEventType, this);
|
2004-01-12 08:25:18 +00:00
|
|
|
nsPoint point(0, 0);
|
1999-04-23 14:30:51 +00:00
|
|
|
|
2004-01-12 08:25:18 +00:00
|
|
|
InitEvent(event, &point); // this add ref's event.widget
|
1999-04-23 14:30:51 +00:00
|
|
|
|
2005-01-19 02:38:59 +00:00
|
|
|
event.flags |= aFlags;
|
2000-05-12 21:54:25 +00:00
|
|
|
event.charCode = aCharCode;
|
|
|
|
event.keyCode = aVirtualCharCode;
|
1999-04-23 14:30:51 +00:00
|
|
|
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
#ifdef KE_DEBUG
|
|
|
|
static cnt=0;
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("%d DispatchKE Type: %s charCode %d keyCode %d ", cnt++,
|
|
|
|
(NS_KEY_PRESS == aEventType) ? "PRESS" : (aEventType == NS_KEY_UP ? "Up" : "Down"),
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
event.charCode, event.keyCode);
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("Shift: %s Control %s Alt: %s \n",
|
|
|
|
(mIsShiftDown ? "D" : "U"), (mIsControlDown ? "D" : "U"), (mIsAltDown ? "D" : "U"));
|
|
|
|
printf("[%c][%c][%c] <== [%c][%c][%c][ space bar ][%c][%c][%c]\n",
|
|
|
|
IS_VK_DOWN(NS_VK_SHIFT) ? 'S' : ' ',
|
|
|
|
IS_VK_DOWN(NS_VK_CONTROL) ? 'C' : ' ',
|
|
|
|
IS_VK_DOWN(NS_VK_ALT) ? 'A' : ' ',
|
|
|
|
IS_VK_DOWN(VK_LSHIFT) ? 'S' : ' ',
|
|
|
|
IS_VK_DOWN(VK_LCONTROL) ? 'C' : ' ',
|
|
|
|
IS_VK_DOWN(VK_LMENU) ? 'A' : ' ',
|
|
|
|
IS_VK_DOWN(VK_RMENU) ? 'A' : ' ',
|
|
|
|
IS_VK_DOWN(VK_RCONTROL) ? 'C' : ' ',
|
|
|
|
IS_VK_DOWN(VK_RSHIFT) ? 'S' : ' ');
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
#endif
|
1999-04-23 14:30:51 +00:00
|
|
|
|
|
|
|
event.isShift = mIsShiftDown;
|
|
|
|
event.isControl = mIsControlDown;
|
2004-09-03 08:44:23 +00:00
|
|
|
event.isMeta = PR_FALSE;
|
1999-04-23 14:30:51 +00:00
|
|
|
event.isAlt = mIsAltDown;
|
|
|
|
|
2001-12-29 22:21:31 +00:00
|
|
|
nsPluginEvent pluginEvent;
|
|
|
|
|
|
|
|
switch (aEventType)
|
|
|
|
{
|
|
|
|
case NS_KEY_UP:
|
|
|
|
pluginEvent.event = WM_KEYUP;
|
|
|
|
break;
|
|
|
|
case NS_KEY_DOWN:
|
|
|
|
pluginEvent.event = WM_KEYDOWN;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-02-02 00:21:53 +00:00
|
|
|
pluginEvent.wParam = aVirtualCharCode;
|
|
|
|
pluginEvent.lParam = aKeyData;
|
2001-12-29 22:21:31 +00:00
|
|
|
|
|
|
|
event.nativeMsg = (void *)&pluginEvent;
|
|
|
|
|
1999-04-23 14:30:51 +00:00
|
|
|
PRBool result = DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2004-04-18 11:03:51 +00:00
|
|
|
BOOL nsWindow::OnKeyDown(UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyData)
|
1999-06-10 21:38:05 +00:00
|
|
|
{
|
2006-12-01 14:40:05 +00:00
|
|
|
#ifdef VK_BROWSER_BACK
|
|
|
|
// VK_BROWSER_BACK and VK_BROWSER_FORWARD are converted to nsCommandEvents
|
2006-12-01 11:09:53 +00:00
|
|
|
if (aVirtualKeyCode == VK_BROWSER_BACK)
|
|
|
|
{
|
|
|
|
DispatchCommandEvent(APPCOMMAND_BROWSER_BACKWARD);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (aVirtualKeyCode == VK_BROWSER_FORWARD)
|
|
|
|
{
|
|
|
|
DispatchCommandEvent(APPCOMMAND_BROWSER_FORWARD);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2006-12-01 14:40:05 +00:00
|
|
|
#endif
|
2006-12-01 11:09:53 +00:00
|
|
|
|
2006-03-16 21:02:22 +00:00
|
|
|
gKbdLayout.OnKeyDown (aVirtualKeyCode);
|
2006-07-17 14:08:27 +00:00
|
|
|
|
|
|
|
// Use only DOMKeyCode for XP processing.
|
|
|
|
// Use aVirtualKeyCode for gKbdLayout and native processing.
|
|
|
|
UINT DOMKeyCode = sIMEIsComposing ?
|
|
|
|
aVirtualKeyCode : MapFromNativeToDOM(aVirtualKeyCode);
|
2000-05-12 21:54:25 +00:00
|
|
|
|
2001-06-20 05:48:45 +00:00
|
|
|
#ifdef DEBUG
|
2006-07-17 14:08:27 +00:00
|
|
|
//printf("In OnKeyDown virt: %d scan: %d\n", DOMKeyCode, aScanCode);
|
2001-06-20 05:48:45 +00:00
|
|
|
#endif
|
1999-09-20 21:07:39 +00:00
|
|
|
|
2006-07-17 14:08:27 +00:00
|
|
|
BOOL noDefault = DispatchKeyEvent(NS_KEY_DOWN, 0, DOMKeyCode, aKeyData);
|
2004-04-18 11:03:51 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// If we won't be getting a WM_CHAR, WM_SYSCHAR or WM_DEADCHAR, synthesize a keypress
|
|
|
|
// for almost all keys
|
2006-07-17 14:08:27 +00:00
|
|
|
switch (DOMKeyCode) {
|
2004-04-18 11:03:51 +00:00
|
|
|
case NS_VK_SHIFT:
|
|
|
|
case NS_VK_CONTROL:
|
|
|
|
case NS_VK_ALT:
|
|
|
|
case NS_VK_CAPS_LOCK:
|
|
|
|
case NS_VK_NUM_LOCK:
|
2005-01-19 02:38:59 +00:00
|
|
|
case NS_VK_SCROLL_LOCK: return noDefault;
|
2004-04-18 11:03:51 +00:00
|
|
|
}
|
1999-09-20 21:07:39 +00:00
|
|
|
|
2005-01-19 02:38:59 +00:00
|
|
|
PRUint32 extraFlags = (noDefault ? NS_EVENT_FLAG_NO_DEFAULT : 0);
|
2004-04-18 11:03:51 +00:00
|
|
|
MSG msg;
|
2006-04-04 20:57:13 +00:00
|
|
|
BOOL gotMsg = ::PeekMessageW(&msg, mWnd, WM_KEYFIRST, WM_KEYLAST, PM_NOREMOVE | PM_NOYIELD);
|
2006-07-17 14:08:27 +00:00
|
|
|
PRBool anyCharMessagesRemoved = PR_FALSE;
|
2004-04-18 11:03:51 +00:00
|
|
|
// Enter and backspace are always handled here to avoid for example the
|
|
|
|
// confusion between ctrl-enter and ctrl-J.
|
2006-07-17 14:08:27 +00:00
|
|
|
if (DOMKeyCode == NS_VK_RETURN || DOMKeyCode == NS_VK_BACK ||
|
|
|
|
((mIsControlDown || mIsAltDown) &&
|
|
|
|
KeyboardLayout::IsPrintableCharKey(aVirtualKeyCode)))
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
{
|
2006-03-16 21:02:22 +00:00
|
|
|
// Remove a possible WM_CHAR or WM_SYSCHAR messages from the message queue.
|
|
|
|
// They can be more than one because of:
|
|
|
|
// * Dead-keys not pairing with base character
|
|
|
|
// * Some keyboard layouts may map up to 4 characters to the single key
|
|
|
|
|
2006-07-17 14:08:27 +00:00
|
|
|
|
2006-03-16 21:02:22 +00:00
|
|
|
while (gotMsg && (msg.message == WM_CHAR || msg.message == WM_SYSCHAR))
|
|
|
|
{
|
2006-04-04 20:57:13 +00:00
|
|
|
::GetMessageW(&msg, mWnd, WM_KEYFIRST, WM_KEYLAST);
|
2006-03-16 21:02:22 +00:00
|
|
|
anyCharMessagesRemoved = PR_TRUE;
|
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
gotMsg = ::PeekMessageW (&msg, mWnd, WM_KEYFIRST, WM_KEYLAST, PM_NOREMOVE | PM_NOYIELD);
|
2006-03-16 21:02:22 +00:00
|
|
|
}
|
|
|
|
|
2006-07-17 14:08:27 +00:00
|
|
|
if (!anyCharMessagesRemoved && DOMKeyCode == NS_VK_BACK) {
|
2004-07-15 20:38:00 +00:00
|
|
|
MSG imeStartCompositionMsg, imeCompositionMsg;
|
2006-04-04 20:57:13 +00:00
|
|
|
if (::PeekMessageW(&imeStartCompositionMsg, mWnd, WM_IME_STARTCOMPOSITION, WM_IME_STARTCOMPOSITION, PM_NOREMOVE | PM_NOYIELD)
|
|
|
|
&& ::PeekMessageW(&imeCompositionMsg, mWnd, WM_IME_COMPOSITION, WM_IME_COMPOSITION, PM_NOREMOVE | PM_NOYIELD)
|
|
|
|
&& ::PeekMessageW(&msg, mWnd, WM_CHAR, WM_CHAR, PM_NOREMOVE | PM_NOYIELD)
|
2004-07-15 20:38:00 +00:00
|
|
|
&& imeStartCompositionMsg.wParam == 0x0 && imeStartCompositionMsg.lParam == 0x0
|
|
|
|
&& imeCompositionMsg.wParam == 0x0 && imeCompositionMsg.lParam == 0x1BF
|
|
|
|
&& msg.wParam == NS_VK_BACK && msg.lParam == 0x1
|
|
|
|
&& imeStartCompositionMsg.time <= imeCompositionMsg.time
|
|
|
|
&& imeCompositionMsg.time <= msg.time) {
|
|
|
|
// This message pattern is "Kakutei-Undo" on ATOK and WXG.
|
|
|
|
// (ATOK and WXG are popular IMEs in Japan)
|
|
|
|
// In this case, the message queue has following messages:
|
|
|
|
// ------------------------------------------------------------------------------------------
|
|
|
|
// WM_KEYDOWN * n (wParam = VK_BACK, lParam = 0x1)
|
|
|
|
// WM_KEYUP * 1 (wParam = VK_BACK, lParam = 0xC0000001) #this is ATOK only
|
|
|
|
// WM_IME_STARTCOMPOSITION * 1 (wParam = 0x0, lParam = 0x0)
|
|
|
|
// WM_IME_COMPOSITION * 1 (wParam = 0x0, lParam = 0x1BF)
|
|
|
|
// WM_CHAR * n (wParam = VK_BACK, lParam = 0x1)
|
|
|
|
// WM_KEYUP * 1 (wParam = VK_BACK, lParam = 0xC00E0001)
|
|
|
|
// ------------------------------------------------------------------------------------------
|
|
|
|
// This message pattern does not match to the above case;
|
|
|
|
// i.e.,WM_KEYDOWN -> WM_CHAR -> WM_KEYDOWN -> WM_CHAR.
|
|
|
|
// For more information of this problem:
|
|
|
|
// http://bugzilla.mozilla.gr.jp/show_bug.cgi?id=2885 (written in Japanese)
|
|
|
|
// http://bugzilla.mozilla.org/show_bug.cgi?id=194559 (written in English)
|
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
::GetMessageW(&msg, mWnd, WM_CHAR, WM_CHAR);
|
2004-07-15 20:38:00 +00:00
|
|
|
}
|
2004-04-18 11:03:51 +00:00
|
|
|
}
|
2001-10-22 22:43:52 +00:00
|
|
|
}
|
2004-04-18 11:03:51 +00:00
|
|
|
else if (gotMsg &&
|
|
|
|
(msg.message == WM_CHAR || msg.message == WM_SYSCHAR || msg.message == WM_DEADCHAR)) {
|
2005-01-19 02:38:59 +00:00
|
|
|
// If prevent default set for keydown, do same for keypress
|
2006-04-04 20:57:13 +00:00
|
|
|
::GetMessageW(&msg, mWnd, msg.message, msg.message);
|
2006-03-16 21:02:22 +00:00
|
|
|
|
2005-05-16 11:17:45 +00:00
|
|
|
if (msg.message == WM_DEADCHAR)
|
|
|
|
return PR_FALSE;
|
2006-03-16 21:02:22 +00:00
|
|
|
|
2005-05-16 11:17:45 +00:00
|
|
|
#ifdef KE_DEBUG
|
|
|
|
printf("%s\tchar=%c\twp=%4x\tlp=%8x\n",
|
|
|
|
(msg.message == WM_SYSCHAR) ? "WM_SYSCHAR" : "WM_CHAR",
|
|
|
|
msg.wParam, msg.wParam, msg.lParam);
|
|
|
|
#endif
|
2006-11-24 02:10:50 +00:00
|
|
|
return OnChar(msg.wParam, msg.lParam, extraFlags);
|
2006-04-24 13:58:38 +00:00
|
|
|
} else if (!mIsControlDown && !mIsAltDown &&
|
2006-05-21 08:16:27 +00:00
|
|
|
(KeyboardLayout::IsPrintableCharKey(aVirtualKeyCode) ||
|
|
|
|
KeyboardLayout::IsNumpadKey(aVirtualKeyCode)))
|
|
|
|
{
|
2006-04-24 13:58:38 +00:00
|
|
|
// If this is simple KeyDown event but next message is not WM_CHAR,
|
|
|
|
// this event may not input text, so we should ignore this event.
|
|
|
|
// See bug 314130.
|
|
|
|
return PR_FALSE;
|
2002-06-12 14:25:02 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2006-03-16 21:02:22 +00:00
|
|
|
if (gKbdLayout.IsDeadKey ())
|
|
|
|
return PR_FALSE;
|
2006-04-24 13:58:38 +00:00
|
|
|
|
2006-03-16 21:02:22 +00:00
|
|
|
PRUint8 shiftStates [5];
|
|
|
|
PRUint16 uniChars [5];
|
|
|
|
PRUint32 numOfUniChars = 0;
|
|
|
|
PRUint32 numOfShiftStates = 0;
|
2004-04-18 11:03:51 +00:00
|
|
|
|
2006-07-17 14:08:27 +00:00
|
|
|
switch (aVirtualKeyCode) {
|
2004-04-18 11:03:51 +00:00
|
|
|
// keys to be sent as characters
|
2006-07-17 14:08:27 +00:00
|
|
|
case VK_ADD: uniChars [0] = '+'; numOfUniChars = 1; break;
|
|
|
|
case VK_SUBTRACT: uniChars [0] = '-'; numOfUniChars = 1; break;
|
|
|
|
case VK_DIVIDE: uniChars [0] = '/'; numOfUniChars = 1; break;
|
|
|
|
case VK_MULTIPLY: uniChars [0] = '*'; numOfUniChars = 1; break;
|
|
|
|
case VK_NUMPAD0:
|
|
|
|
case VK_NUMPAD1:
|
|
|
|
case VK_NUMPAD2:
|
|
|
|
case VK_NUMPAD3:
|
|
|
|
case VK_NUMPAD4:
|
|
|
|
case VK_NUMPAD5:
|
|
|
|
case VK_NUMPAD6:
|
|
|
|
case VK_NUMPAD7:
|
|
|
|
case VK_NUMPAD8:
|
|
|
|
case VK_NUMPAD9:
|
|
|
|
uniChars [0] = aVirtualKeyCode - VK_NUMPAD0 + '0';
|
|
|
|
numOfUniChars = 1;
|
|
|
|
break;
|
2004-04-18 11:03:51 +00:00
|
|
|
default:
|
2006-03-16 21:02:22 +00:00
|
|
|
if (KeyboardLayout::IsPrintableCharKey (aVirtualKeyCode))
|
|
|
|
numOfUniChars = numOfShiftStates = gKbdLayout.GetUniChars (uniChars, shiftStates, NS_ARRAY_LENGTH (uniChars));
|
|
|
|
|
|
|
|
if (mIsControlDown ^ mIsAltDown)
|
|
|
|
{
|
|
|
|
// XXX
|
|
|
|
// For both Alt+key and Ctrl+key combinations we return the latin characters A..Z and
|
|
|
|
// numbers 0..9, ignoring the real characters returned by active keyboard layout.
|
|
|
|
// This is required to make sure that all shortcut keys (e.g. Ctrl+c, Ctrl+1, Alt+f)
|
|
|
|
// work the same way no matter what keyboard layout you are using.
|
|
|
|
|
2006-07-17 14:08:27 +00:00
|
|
|
if ((NS_VK_0 <= DOMKeyCode && DOMKeyCode <= NS_VK_9) ||
|
|
|
|
(NS_VK_A <= DOMKeyCode && DOMKeyCode <= NS_VK_Z))
|
2006-03-16 21:02:22 +00:00
|
|
|
{
|
2006-07-17 14:08:27 +00:00
|
|
|
uniChars [0] = DOMKeyCode;
|
2006-03-16 21:02:22 +00:00
|
|
|
numOfUniChars = 1;
|
|
|
|
numOfShiftStates = 0;
|
2006-07-17 14:08:27 +00:00
|
|
|
|
2006-03-16 21:02:22 +00:00
|
|
|
// For letters take the Shift state into account
|
|
|
|
if (!mIsShiftDown &&
|
2006-07-17 14:08:27 +00:00
|
|
|
NS_VK_A <= DOMKeyCode && DOMKeyCode <= NS_VK_Z)
|
2006-03-16 21:02:22 +00:00
|
|
|
uniChars [0] += 0x20;
|
2006-01-13 21:18:49 +00:00
|
|
|
}
|
2006-07-17 14:08:27 +00:00
|
|
|
else if (!anyCharMessagesRemoved && DOMKeyCode != aVirtualKeyCode) {
|
|
|
|
switch (DOMKeyCode) {
|
|
|
|
case NS_VK_ADD:
|
|
|
|
uniChars [0] = '+'; numOfUniChars = 1; break;
|
|
|
|
case NS_VK_SUBTRACT:
|
|
|
|
uniChars [0] = '-'; numOfUniChars = 1; break;
|
|
|
|
case NS_VK_SEMICOLON:
|
|
|
|
// XXXmnakano I don't know whether this is correct.
|
|
|
|
uniChars [0] = ';';
|
|
|
|
uniChars [1] = ':';
|
|
|
|
numOfUniChars = 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_ERROR("implement me!");
|
|
|
|
}
|
|
|
|
}
|
2006-01-07 18:46:46 +00:00
|
|
|
}
|
2006-01-13 21:18:49 +00:00
|
|
|
}
|
2006-01-07 18:46:46 +00:00
|
|
|
|
2006-03-16 21:02:22 +00:00
|
|
|
if (numOfUniChars)
|
|
|
|
{
|
|
|
|
for (PRUint32 cnt = 0; cnt < numOfUniChars; cnt++)
|
|
|
|
{
|
|
|
|
if (cnt < numOfShiftStates)
|
|
|
|
{
|
|
|
|
// If key in combination with Alt and/or Ctrl produces a different character than without them
|
|
|
|
// then do not report these flags because it is separate keyboard layout shift state.
|
|
|
|
// If dead-key and base character does not produce a valid composite character then both produced
|
|
|
|
// dead-key character and following base character may have different modifier flags, too.
|
|
|
|
mIsShiftDown = (shiftStates [cnt] & eShift) != 0;
|
|
|
|
mIsControlDown = (shiftStates [cnt] & eCtrl) != 0;
|
|
|
|
mIsAltDown = (shiftStates [cnt] & eAlt) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DispatchKeyEvent(NS_KEY_PRESS, uniChars [cnt], 0, aKeyData, extraFlags);
|
|
|
|
}
|
|
|
|
} else
|
2006-07-17 14:08:27 +00:00
|
|
|
DispatchKeyEvent(NS_KEY_PRESS, 0, DOMKeyCode, aKeyData, extraFlags);
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2005-01-19 02:38:59 +00:00
|
|
|
return noDefault;
|
1999-06-10 21:38:05 +00:00
|
|
|
}
|
1999-04-23 14:30:51 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2002-02-02 00:21:53 +00:00
|
|
|
BOOL nsWindow::OnKeyUp( UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyData)
|
1999-04-23 14:30:51 +00:00
|
|
|
{
|
2006-12-01 14:40:05 +00:00
|
|
|
#ifdef VK_BROWSER_BACK
|
2006-12-01 11:09:53 +00:00
|
|
|
if (aVirtualKeyCode == VK_BROWSER_BACK || aVirtualKeyCode == VK_BROWSER_FORWARD)
|
|
|
|
return TRUE;
|
2006-12-01 14:40:05 +00:00
|
|
|
#endif
|
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
aVirtualKeyCode = sIMEIsComposing ? aVirtualKeyCode : MapFromNativeToDOM(aVirtualKeyCode);
|
2002-02-02 00:21:53 +00:00
|
|
|
BOOL result = DispatchKeyEvent(NS_KEY_UP, 0, aVirtualKeyCode, aKeyData);
|
2000-02-12 00:10:22 +00:00
|
|
|
return result;
|
1999-04-23 14:30:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2006-11-24 02:10:50 +00:00
|
|
|
BOOL nsWindow::OnChar(UINT charCode, LPARAM keyData, PRUint32 aFlags)
|
1999-06-04 05:14:01 +00:00
|
|
|
{
|
2005-01-19 02:38:59 +00:00
|
|
|
// These must be checked here too as a lone WM_CHAR could be received
|
|
|
|
// if a child window didn't handle it (for example Alt+Space in a content window)
|
|
|
|
mIsShiftDown = IS_VK_DOWN(NS_VK_SHIFT);
|
|
|
|
mIsControlDown = IS_VK_DOWN(NS_VK_CONTROL);
|
|
|
|
mIsAltDown = IS_VK_DOWN(NS_VK_ALT);
|
|
|
|
|
|
|
|
// ignore [shift+]alt+space so the OS can handle it
|
|
|
|
if (mIsAltDown && !mIsControlDown && IS_VK_DOWN(NS_VK_SPACE)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// WM_CHAR with Control and Alt (== AltGr) down really means a normal character
|
|
|
|
PRBool saveIsAltDown = mIsAltDown;
|
|
|
|
PRBool saveIsControlDown = mIsControlDown;
|
|
|
|
if (mIsAltDown && mIsControlDown)
|
|
|
|
mIsAltDown = mIsControlDown = PR_FALSE;
|
|
|
|
|
2001-10-03 00:00:15 +00:00
|
|
|
wchar_t uniChar;
|
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
if (sIMEIsComposing) {
|
2001-10-03 00:00:15 +00:00
|
|
|
HandleEndComposition();
|
|
|
|
}
|
1999-06-04 05:14:01 +00:00
|
|
|
|
2004-04-18 11:03:51 +00:00
|
|
|
if (mIsControlDown && charCode <= 0x1A) { // Ctrl+A Ctrl+Z, see Programming Windows 3.1 page 110 for details
|
|
|
|
// need to account for shift here. bug 16486
|
|
|
|
if (mIsShiftDown)
|
|
|
|
uniChar = charCode - 1 + 'A';
|
|
|
|
else
|
|
|
|
uniChar = charCode - 1 + 'a';
|
|
|
|
charCode = 0;
|
|
|
|
}
|
|
|
|
else if (mIsControlDown && charCode <= 0x1F) {
|
2002-02-16 01:44:54 +00:00
|
|
|
// Fix for 50255 - <ctrl><[> and <ctrl><]> are not being processed.
|
|
|
|
// also fixes ctrl+\ (x1c), ctrl+^ (x1e) and ctrl+_ (x1f)
|
|
|
|
// for some reason the keypress handler need to have the uniChar code set
|
|
|
|
// with the addition of a upper case A not the lower case.
|
2004-04-18 11:03:51 +00:00
|
|
|
uniChar = charCode - 1 + 'A';
|
|
|
|
charCode = 0;
|
|
|
|
} else { // 0x20 - SPACE, 0x3D - EQUALS
|
|
|
|
if (charCode < 0x20 || (charCode == 0x3D && mIsControlDown)) {
|
2001-05-01 13:29:14 +00:00
|
|
|
uniChar = 0;
|
2004-04-18 11:03:51 +00:00
|
|
|
} else {
|
2006-04-04 20:57:13 +00:00
|
|
|
uniChar = charCode;
|
2004-04-18 11:03:51 +00:00
|
|
|
charCode = 0;
|
2001-05-01 13:29:14 +00:00
|
|
|
}
|
|
|
|
}
|
2005-01-19 02:38:59 +00:00
|
|
|
|
2006-11-24 02:10:50 +00:00
|
|
|
// Keep the characters unshifted for shortcuts and accesskeys and make sure
|
|
|
|
// that numbers are always passed as such (among others: bugs 50255 and 351310)
|
|
|
|
if (uniChar && (mIsControlDown || mIsAltDown)) {
|
|
|
|
UINT virtualKeyCode = ::MapVirtualKey(HIWORD(keyData) & 0xFF, MAPVK_VSC_TO_VK);
|
|
|
|
UINT unshiftedCharCode =
|
|
|
|
virtualKeyCode >= '0' && virtualKeyCode <= '9' ? virtualKeyCode :
|
|
|
|
mIsShiftDown ? ::MapVirtualKey(virtualKeyCode, MAPVK_VK_TO_CHAR) : 0;
|
|
|
|
// ignore diacritics (top bit set) and key mapping errors (char code 0)
|
|
|
|
if ((INT)unshiftedCharCode > 0)
|
|
|
|
uniChar = unshiftedCharCode;
|
|
|
|
}
|
|
|
|
|
2005-05-24 04:48:09 +00:00
|
|
|
// Fix for bug 285161 (and 295095) which was caused by the initial fix for bug 178110.
|
|
|
|
// When pressing (alt|ctrl)+char, the char must be lowercase unless shift is
|
|
|
|
// pressed too.
|
|
|
|
if (!mIsShiftDown && (saveIsAltDown || saveIsControlDown)) {
|
2005-05-20 18:25:19 +00:00
|
|
|
uniChar = towlower(uniChar);
|
|
|
|
}
|
|
|
|
|
2005-01-19 02:38:59 +00:00
|
|
|
PRBool result = DispatchKeyEvent(NS_KEY_PRESS, uniChar, charCode, 0, aFlags);
|
|
|
|
mIsAltDown = saveIsAltDown;
|
|
|
|
mIsControlDown = saveIsControlDown;
|
|
|
|
return result;
|
1999-06-04 05:14:01 +00:00
|
|
|
}
|
|
|
|
|
1999-04-23 14:30:51 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
void nsWindow::ConstrainZLevel(HWND *aAfter)
|
|
|
|
{
|
2005-04-28 23:48:28 +00:00
|
|
|
nsZLevelEvent event(PR_TRUE, NS_SETZLEVEL, this);
|
2000-04-01 22:16:43 +00:00
|
|
|
nsWindow *aboveWindow = 0;
|
|
|
|
|
2004-01-12 08:25:18 +00:00
|
|
|
InitEvent(event);
|
2000-04-01 22:16:43 +00:00
|
|
|
|
|
|
|
if (*aAfter == HWND_BOTTOM)
|
|
|
|
event.mPlacement = nsWindowZBottom;
|
|
|
|
else if (*aAfter == HWND_TOP || *aAfter == HWND_TOPMOST || *aAfter == HWND_NOTOPMOST)
|
|
|
|
event.mPlacement = nsWindowZTop;
|
|
|
|
else {
|
|
|
|
event.mPlacement = nsWindowZRelative;
|
2000-04-27 00:23:18 +00:00
|
|
|
aboveWindow = GetNSWindowPtr(*aAfter);
|
2000-04-01 22:16:43 +00:00
|
|
|
}
|
|
|
|
event.mReqBelow = aboveWindow;
|
2002-02-27 01:30:40 +00:00
|
|
|
event.mActualBelow = nsnull;
|
2000-04-01 22:16:43 +00:00
|
|
|
|
|
|
|
event.mImmediate = PR_FALSE;
|
|
|
|
event.mAdjusted = PR_FALSE;
|
|
|
|
DispatchWindowEvent(&event);
|
|
|
|
|
|
|
|
if (event.mAdjusted) {
|
|
|
|
if (event.mPlacement == nsWindowZBottom)
|
|
|
|
*aAfter = HWND_BOTTOM;
|
|
|
|
else if (event.mPlacement == nsWindowZTop)
|
|
|
|
*aAfter = HWND_TOP;
|
|
|
|
else {
|
|
|
|
*aAfter = (HWND)event.mActualBelow->GetNativeData(NS_NATIVE_WINDOW);
|
|
|
|
}
|
|
|
|
}
|
2002-02-27 01:30:40 +00:00
|
|
|
NS_IF_RELEASE(event.mActualBelow);
|
2000-04-01 22:16:43 +00:00
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
}
|
|
|
|
|
2000-08-30 21:21:39 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Process all nsWindows messages
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2007-06-17 10:59:19 +00:00
|
|
|
static PRBool gJustGotDeactivate = PR_FALSE;
|
|
|
|
static PRBool gJustGotActivate = PR_FALSE;
|
2000-08-30 21:21:39 +00:00
|
|
|
|
2000-05-11 13:39:17 +00:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char * mStr;
|
|
|
|
long mId;
|
|
|
|
} EventMsgInfo;
|
|
|
|
|
|
|
|
EventMsgInfo gAllEvents[] = {
|
2004-09-03 08:44:23 +00:00
|
|
|
{"WM_NULL", 0x0000},
|
|
|
|
{"WM_CREATE", 0x0001},
|
|
|
|
{"WM_DESTROY", 0x0002},
|
|
|
|
{"WM_MOVE", 0x0003},
|
|
|
|
{"WM_SIZE", 0x0005},
|
|
|
|
{"WM_ACTIVATE", 0x0006},
|
|
|
|
{"WM_SETFOCUS", 0x0007},
|
|
|
|
{"WM_KILLFOCUS", 0x0008},
|
|
|
|
{"WM_ENABLE", 0x000A},
|
|
|
|
{"WM_SETREDRAW", 0x000B},
|
|
|
|
{"WM_SETTEXT", 0x000C},
|
|
|
|
{"WM_GETTEXT", 0x000D},
|
|
|
|
{"WM_GETTEXTLENGTH", 0x000E},
|
|
|
|
{"WM_PAINT", 0x000F},
|
|
|
|
{"WM_CLOSE", 0x0010},
|
|
|
|
{"WM_QUERYENDSESSION", 0x0011},
|
|
|
|
{"WM_QUIT", 0x0012},
|
|
|
|
{"WM_QUERYOPEN", 0x0013},
|
|
|
|
{"WM_ERASEBKGND", 0x0014},
|
|
|
|
{"WM_SYSCOLORCHANGE", 0x0015},
|
|
|
|
{"WM_ENDSESSION", 0x0016},
|
|
|
|
{"WM_SHOWWINDOW", 0x0018},
|
|
|
|
{"WM_SETTINGCHANGE", 0x001A},
|
|
|
|
{"WM_DEVMODECHANGE", 0x001B},
|
|
|
|
{"WM_ACTIVATEAPP", 0x001C},
|
|
|
|
{"WM_FONTCHANGE", 0x001D},
|
|
|
|
{"WM_TIMECHANGE", 0x001E},
|
|
|
|
{"WM_CANCELMODE", 0x001F},
|
|
|
|
{"WM_SETCURSOR", 0x0020},
|
|
|
|
{"WM_MOUSEACTIVATE", 0x0021},
|
|
|
|
{"WM_CHILDACTIVATE", 0x0022},
|
|
|
|
{"WM_QUEUESYNC", 0x0023},
|
|
|
|
{"WM_GETMINMAXINFO", 0x0024},
|
|
|
|
{"WM_PAINTICON", 0x0026},
|
|
|
|
{"WM_ICONERASEBKGND", 0x0027},
|
|
|
|
{"WM_NEXTDLGCTL", 0x0028},
|
|
|
|
{"WM_SPOOLERSTATUS", 0x002A},
|
|
|
|
{"WM_DRAWITEM", 0x002B},
|
|
|
|
{"WM_MEASUREITEM", 0x002C},
|
|
|
|
{"WM_DELETEITEM", 0x002D},
|
|
|
|
{"WM_VKEYTOITEM", 0x002E},
|
|
|
|
{"WM_CHARTOITEM", 0x002F},
|
|
|
|
{"WM_SETFONT", 0x0030},
|
|
|
|
{"WM_GETFONT", 0x0031},
|
|
|
|
{"WM_SETHOTKEY", 0x0032},
|
|
|
|
{"WM_GETHOTKEY", 0x0033},
|
|
|
|
{"WM_QUERYDRAGICON", 0x0037},
|
|
|
|
{"WM_COMPAREITEM", 0x0039},
|
|
|
|
{"WM_GETOBJECT", 0x003D},
|
|
|
|
{"WM_COMPACTING", 0x0041},
|
|
|
|
{"WM_COMMNOTIFY", 0x0044},
|
|
|
|
{"WM_WINDOWPOSCHANGING", 0x0046},
|
|
|
|
{"WM_WINDOWPOSCHANGED", 0x0047},
|
|
|
|
{"WM_POWER", 0x0048},
|
|
|
|
{"WM_COPYDATA", 0x004A},
|
|
|
|
{"WM_CANCELJOURNAL", 0x004B},
|
|
|
|
{"WM_NOTIFY", 0x004E},
|
|
|
|
{"WM_INPUTLANGCHANGEREQUEST", 0x0050},
|
|
|
|
{"WM_INPUTLANGCHANGE", 0x0051},
|
|
|
|
{"WM_TCARD", 0x0052},
|
|
|
|
{"WM_HELP", 0x0053},
|
|
|
|
{"WM_USERCHANGED", 0x0054},
|
|
|
|
{"WM_NOTIFYFORMAT", 0x0055},
|
|
|
|
{"WM_CONTEXTMENU", 0x007B},
|
|
|
|
{"WM_STYLECHANGING", 0x007C},
|
|
|
|
{"WM_STYLECHANGED", 0x007D},
|
|
|
|
{"WM_DISPLAYCHANGE", 0x007E},
|
|
|
|
{"WM_GETICON", 0x007F},
|
|
|
|
{"WM_SETICON", 0x0080},
|
|
|
|
{"WM_NCCREATE", 0x0081},
|
|
|
|
{"WM_NCDESTROY", 0x0082},
|
|
|
|
{"WM_NCCALCSIZE", 0x0083},
|
|
|
|
{"WM_NCHITTEST", 0x0084},
|
|
|
|
{"WM_NCPAINT", 0x0085},
|
|
|
|
{"WM_NCACTIVATE", 0x0086},
|
|
|
|
{"WM_GETDLGCODE", 0x0087},
|
|
|
|
{"WM_SYNCPAINT", 0x0088},
|
|
|
|
{"WM_NCMOUSEMOVE", 0x00A0},
|
|
|
|
{"WM_NCLBUTTONDOWN", 0x00A1},
|
|
|
|
{"WM_NCLBUTTONUP", 0x00A2},
|
|
|
|
{"WM_NCLBUTTONDBLCLK", 0x00A3},
|
|
|
|
{"WM_NCRBUTTONDOWN", 0x00A4},
|
|
|
|
{"WM_NCRBUTTONUP", 0x00A5},
|
|
|
|
{"WM_NCRBUTTONDBLCLK", 0x00A6},
|
|
|
|
{"WM_NCMBUTTONDOWN", 0x00A7},
|
|
|
|
{"WM_NCMBUTTONUP", 0x00A8},
|
|
|
|
{"WM_NCMBUTTONDBLCLK", 0x00A9},
|
|
|
|
{"EM_GETSEL", 0x00B0},
|
|
|
|
{"EM_SETSEL", 0x00B1},
|
|
|
|
{"EM_GETRECT", 0x00B2},
|
|
|
|
{"EM_SETRECT", 0x00B3},
|
|
|
|
{"EM_SETRECTNP", 0x00B4},
|
|
|
|
{"EM_SCROLL", 0x00B5},
|
|
|
|
{"EM_LINESCROLL", 0x00B6},
|
|
|
|
{"EM_SCROLLCARET", 0x00B7},
|
|
|
|
{"EM_GETMODIFY", 0x00B8},
|
|
|
|
{"EM_SETMODIFY", 0x00B9},
|
|
|
|
{"EM_GETLINECOUNT", 0x00BA},
|
|
|
|
{"EM_LINEINDEX", 0x00BB},
|
|
|
|
{"EM_SETHANDLE", 0x00BC},
|
|
|
|
{"EM_GETHANDLE", 0x00BD},
|
|
|
|
{"EM_GETTHUMB", 0x00BE},
|
|
|
|
{"EM_LINELENGTH", 0x00C1},
|
|
|
|
{"EM_REPLACESEL", 0x00C2},
|
|
|
|
{"EM_GETLINE", 0x00C4},
|
|
|
|
{"EM_LIMITTEXT", 0x00C5},
|
|
|
|
{"EM_CANUNDO", 0x00C6},
|
|
|
|
{"EM_UNDO", 0x00C7},
|
|
|
|
{"EM_FMTLINES", 0x00C8},
|
|
|
|
{"EM_LINEFROMCHAR", 0x00C9},
|
|
|
|
{"EM_SETTABSTOPS", 0x00CB},
|
|
|
|
{"EM_SETPASSWORDCHAR", 0x00CC},
|
|
|
|
{"EM_EMPTYUNDOBUFFER", 0x00CD},
|
|
|
|
{"EM_GETFIRSTVISIBLELINE", 0x00CE},
|
|
|
|
{"EM_SETREADONLY", 0x00CF},
|
|
|
|
{"EM_SETWORDBREAKPROC", 0x00D0},
|
|
|
|
{"EM_GETWORDBREAKPROC", 0x00D1},
|
|
|
|
{"EM_GETPASSWORDCHAR", 0x00D2},
|
|
|
|
{"EM_SETMARGINS", 0x00D3},
|
|
|
|
{"EM_GETMARGINS", 0x00D4},
|
|
|
|
{"EM_GETLIMITTEXT", 0x00D5},
|
|
|
|
{"EM_POSFROMCHAR", 0x00D6},
|
|
|
|
{"EM_CHARFROMPOS", 0x00D7},
|
|
|
|
{"EM_SETIMESTATUS", 0x00D8},
|
|
|
|
{"EM_GETIMESTATUS", 0x00D9},
|
|
|
|
{"SBM_SETPOS", 0x00E0},
|
|
|
|
{"SBM_GETPOS", 0x00E1},
|
|
|
|
{"SBM_SETRANGE", 0x00E2},
|
|
|
|
{"SBM_SETRANGEREDRAW", 0x00E6},
|
|
|
|
{"SBM_GETRANGE", 0x00E3},
|
|
|
|
{"SBM_ENABLE_ARROWS", 0x00E4},
|
|
|
|
{"SBM_SETSCROLLINFO", 0x00E9},
|
|
|
|
{"SBM_GETSCROLLINFO", 0x00EA},
|
|
|
|
{"WM_KEYDOWN", 0x0100},
|
|
|
|
{"WM_KEYUP", 0x0101},
|
|
|
|
{"WM_CHAR", 0x0102},
|
|
|
|
{"WM_DEADCHAR", 0x0103},
|
|
|
|
{"WM_SYSKEYDOWN", 0x0104},
|
|
|
|
{"WM_SYSKEYUP", 0x0105},
|
|
|
|
{"WM_SYSCHAR", 0x0106},
|
|
|
|
{"WM_SYSDEADCHAR", 0x0107},
|
|
|
|
{"WM_KEYLAST", 0x0108},
|
|
|
|
{"WM_IME_STARTCOMPOSITION", 0x010D},
|
|
|
|
{"WM_IME_ENDCOMPOSITION", 0x010E},
|
|
|
|
{"WM_IME_COMPOSITION", 0x010F},
|
|
|
|
{"WM_INITDIALOG", 0x0110},
|
|
|
|
{"WM_COMMAND", 0x0111},
|
|
|
|
{"WM_SYSCOMMAND", 0x0112},
|
|
|
|
{"WM_TIMER", 0x0113},
|
|
|
|
{"WM_HSCROLL", 0x0114},
|
|
|
|
{"WM_VSCROLL", 0x0115},
|
|
|
|
{"WM_INITMENU", 0x0116},
|
|
|
|
{"WM_INITMENUPOPUP", 0x0117},
|
|
|
|
{"WM_MENUSELECT", 0x011F},
|
|
|
|
{"WM_MENUCHAR", 0x0120},
|
|
|
|
{"WM_ENTERIDLE", 0x0121},
|
|
|
|
{"WM_MENURBUTTONUP", 0x0122},
|
|
|
|
{"WM_MENUDRAG", 0x0123},
|
|
|
|
{"WM_MENUGETOBJECT", 0x0124},
|
|
|
|
{"WM_UNINITMENUPOPUP", 0x0125},
|
|
|
|
{"WM_MENUCOMMAND", 0x0126},
|
|
|
|
{"WM_CTLCOLORMSGBOX", 0x0132},
|
|
|
|
{"WM_CTLCOLOREDIT", 0x0133},
|
|
|
|
{"WM_CTLCOLORLISTBOX", 0x0134},
|
|
|
|
{"WM_CTLCOLORBTN", 0x0135},
|
|
|
|
{"WM_CTLCOLORDLG", 0x0136},
|
|
|
|
{"WM_CTLCOLORSCROLLBAR", 0x0137},
|
|
|
|
{"WM_CTLCOLORSTATIC", 0x0138},
|
|
|
|
{"CB_GETEDITSEL", 0x0140},
|
|
|
|
{"CB_LIMITTEXT", 0x0141},
|
|
|
|
{"CB_SETEDITSEL", 0x0142},
|
|
|
|
{"CB_ADDSTRING", 0x0143},
|
|
|
|
{"CB_DELETESTRING", 0x0144},
|
|
|
|
{"CB_DIR", 0x0145},
|
|
|
|
{"CB_GETCOUNT", 0x0146},
|
|
|
|
{"CB_GETCURSEL", 0x0147},
|
|
|
|
{"CB_GETLBTEXT", 0x0148},
|
|
|
|
{"CB_GETLBTEXTLEN", 0x0149},
|
|
|
|
{"CB_INSERTSTRING", 0x014A},
|
|
|
|
{"CB_RESETCONTENT", 0x014B},
|
|
|
|
{"CB_FINDSTRING", 0x014C},
|
|
|
|
{"CB_SELECTSTRING", 0x014D},
|
|
|
|
{"CB_SETCURSEL", 0x014E},
|
|
|
|
{"CB_SHOWDROPDOWN", 0x014F},
|
|
|
|
{"CB_GETITEMDATA", 0x0150},
|
|
|
|
{"CB_SETITEMDATA", 0x0151},
|
|
|
|
{"CB_GETDROPPEDCONTROLRECT", 0x0152},
|
|
|
|
{"CB_SETITEMHEIGHT", 0x0153},
|
|
|
|
{"CB_GETITEMHEIGHT", 0x0154},
|
|
|
|
{"CB_SETEXTENDEDUI", 0x0155},
|
|
|
|
{"CB_GETEXTENDEDUI", 0x0156},
|
|
|
|
{"CB_GETDROPPEDSTATE", 0x0157},
|
|
|
|
{"CB_FINDSTRINGEXACT", 0x0158},
|
|
|
|
{"CB_SETLOCALE", 0x0159},
|
|
|
|
{"CB_GETLOCALE", 0x015A},
|
|
|
|
{"CB_GETTOPINDEX", 0x015b},
|
|
|
|
{"CB_SETTOPINDEX", 0x015c},
|
|
|
|
{"CB_GETHORIZONTALEXTENT", 0x015d},
|
|
|
|
{"CB_SETHORIZONTALEXTENT", 0x015e},
|
|
|
|
{"CB_GETDROPPEDWIDTH", 0x015f},
|
|
|
|
{"CB_SETDROPPEDWIDTH", 0x0160},
|
|
|
|
{"CB_INITSTORAGE", 0x0161},
|
|
|
|
{"CB_MSGMAX", 0x0162},
|
|
|
|
{"LB_ADDSTRING", 0x0180},
|
|
|
|
{"LB_INSERTSTRING", 0x0181},
|
|
|
|
{"LB_DELETESTRING", 0x0182},
|
|
|
|
{"LB_SELITEMRANGEEX", 0x0183},
|
|
|
|
{"LB_RESETCONTENT", 0x0184},
|
|
|
|
{"LB_SETSEL", 0x0185},
|
|
|
|
{"LB_SETCURSEL", 0x0186},
|
|
|
|
{"LB_GETSEL", 0x0187},
|
|
|
|
{"LB_GETCURSEL", 0x0188},
|
|
|
|
{"LB_GETTEXT", 0x0189},
|
|
|
|
{"LB_GETTEXTLEN", 0x018A},
|
|
|
|
{"LB_GETCOUNT", 0x018B},
|
|
|
|
{"LB_SELECTSTRING", 0x018C},
|
|
|
|
{"LB_DIR", 0x018D},
|
|
|
|
{"LB_GETTOPINDEX", 0x018E},
|
|
|
|
{"LB_FINDSTRING", 0x018F},
|
|
|
|
{"LB_GETSELCOUNT", 0x0190},
|
|
|
|
{"LB_GETSELITEMS", 0x0191},
|
|
|
|
{"LB_SETTABSTOPS", 0x0192},
|
|
|
|
{"LB_GETHORIZONTALEXTENT", 0x0193},
|
|
|
|
{"LB_SETHORIZONTALEXTENT", 0x0194},
|
|
|
|
{"LB_SETCOLUMNWIDTH", 0x0195},
|
|
|
|
{"LB_ADDFILE", 0x0196},
|
|
|
|
{"LB_SETTOPINDEX", 0x0197},
|
|
|
|
{"LB_GETITEMRECT", 0x0198},
|
|
|
|
{"LB_GETITEMDATA", 0x0199},
|
|
|
|
{"LB_SETITEMDATA", 0x019A},
|
|
|
|
{"LB_SELITEMRANGE", 0x019B},
|
|
|
|
{"LB_SETANCHORINDEX", 0x019C},
|
|
|
|
{"LB_GETANCHORINDEX", 0x019D},
|
|
|
|
{"LB_SETCARETINDEX", 0x019E},
|
|
|
|
{"LB_GETCARETINDEX", 0x019F},
|
|
|
|
{"LB_SETITEMHEIGHT", 0x01A0},
|
|
|
|
{"LB_GETITEMHEIGHT", 0x01A1},
|
|
|
|
{"LB_FINDSTRINGEXACT", 0x01A2},
|
|
|
|
{"LB_SETLOCALE", 0x01A5},
|
|
|
|
{"LB_GETLOCALE", 0x01A6},
|
|
|
|
{"LB_SETCOUNT", 0x01A7},
|
|
|
|
{"LB_INITSTORAGE", 0x01A8},
|
|
|
|
{"LB_ITEMFROMPOINT", 0x01A9},
|
|
|
|
{"LB_MSGMAX", 0x01B0},
|
|
|
|
{"WM_MOUSEMOVE", 0x0200},
|
|
|
|
{"WM_LBUTTONDOWN", 0x0201},
|
|
|
|
{"WM_LBUTTONUP", 0x0202},
|
|
|
|
{"WM_LBUTTONDBLCLK", 0x0203},
|
|
|
|
{"WM_RBUTTONDOWN", 0x0204},
|
|
|
|
{"WM_RBUTTONUP", 0x0205},
|
|
|
|
{"WM_RBUTTONDBLCLK", 0x0206},
|
|
|
|
{"WM_MBUTTONDOWN", 0x0207},
|
|
|
|
{"WM_MBUTTONUP", 0x0208},
|
|
|
|
{"WM_MBUTTONDBLCLK", 0x0209},
|
|
|
|
{"WM_MOUSEWHEEL", 0x020A},
|
2006-09-08 06:04:44 +00:00
|
|
|
{"WM_MOUSEHWHEEL", 0x020E},
|
2004-09-03 08:44:23 +00:00
|
|
|
{"WM_PARENTNOTIFY", 0x0210},
|
|
|
|
{"WM_ENTERMENULOOP", 0x0211},
|
|
|
|
{"WM_EXITMENULOOP", 0x0212},
|
|
|
|
{"WM_NEXTMENU", 0x0213},
|
|
|
|
{"WM_SIZING", 0x0214},
|
|
|
|
{"WM_CAPTURECHANGED", 0x0215},
|
|
|
|
{"WM_MOVING", 0x0216},
|
|
|
|
{"WM_POWERBROADCAST", 0x0218},
|
|
|
|
{"WM_DEVICECHANGE", 0x0219},
|
|
|
|
{"WM_MDICREATE", 0x0220},
|
|
|
|
{"WM_MDIDESTROY", 0x0221},
|
|
|
|
{"WM_MDIACTIVATE", 0x0222},
|
|
|
|
{"WM_MDIRESTORE", 0x0223},
|
|
|
|
{"WM_MDINEXT", 0x0224},
|
|
|
|
{"WM_MDIMAXIMIZE", 0x0225},
|
|
|
|
{"WM_MDITILE", 0x0226},
|
|
|
|
{"WM_MDICASCADE", 0x0227},
|
|
|
|
{"WM_MDIICONARRANGE", 0x0228},
|
|
|
|
{"WM_MDIGETACTIVE", 0x0229},
|
|
|
|
{"WM_MDISETMENU", 0x0230},
|
|
|
|
{"WM_ENTERSIZEMOVE", 0x0231},
|
|
|
|
{"WM_EXITSIZEMOVE", 0x0232},
|
|
|
|
{"WM_DROPFILES", 0x0233},
|
|
|
|
{"WM_MDIREFRESHMENU", 0x0234},
|
|
|
|
{"WM_IME_SETCONTEXT", 0x0281},
|
|
|
|
{"WM_IME_NOTIFY", 0x0282},
|
|
|
|
{"WM_IME_CONTROL", 0x0283},
|
|
|
|
{"WM_IME_COMPOSITIONFULL", 0x0284},
|
|
|
|
{"WM_IME_SELECT", 0x0285},
|
|
|
|
{"WM_IME_CHAR", 0x0286},
|
|
|
|
{"WM_IME_REQUEST", 0x0288},
|
|
|
|
{"WM_IME_KEYDOWN", 0x0290},
|
|
|
|
{"WM_IME_KEYUP", 0x0291},
|
2005-12-02 12:08:32 +00:00
|
|
|
{"WM_NCMOUSEHOVER", 0x02A0},
|
2004-09-03 08:44:23 +00:00
|
|
|
{"WM_MOUSEHOVER", 0x02A1},
|
|
|
|
{"WM_MOUSELEAVE", 0x02A3},
|
|
|
|
{"WM_CUT", 0x0300},
|
|
|
|
{"WM_COPY", 0x0301},
|
|
|
|
{"WM_PASTE", 0x0302},
|
|
|
|
{"WM_CLEAR", 0x0303},
|
|
|
|
{"WM_UNDO", 0x0304},
|
|
|
|
{"WM_RENDERFORMAT", 0x0305},
|
|
|
|
{"WM_RENDERALLFORMATS", 0x0306},
|
|
|
|
{"WM_DESTROYCLIPBOARD", 0x0307},
|
|
|
|
{"WM_DRAWCLIPBOARD", 0x0308},
|
|
|
|
{"WM_PAINTCLIPBOARD", 0x0309},
|
|
|
|
{"WM_VSCROLLCLIPBOARD", 0x030A},
|
|
|
|
{"WM_SIZECLIPBOARD", 0x030B},
|
|
|
|
{"WM_ASKCBFORMATNAME", 0x030C},
|
|
|
|
{"WM_CHANGECBCHAIN", 0x030D},
|
|
|
|
{"WM_HSCROLLCLIPBOARD", 0x030E},
|
|
|
|
{"WM_QUERYNEWPALETTE", 0x030F},
|
|
|
|
{"WM_PALETTEISCHANGING", 0x0310},
|
|
|
|
{"WM_PALETTECHANGED", 0x0311},
|
|
|
|
{"WM_HOTKEY", 0x0312},
|
|
|
|
{"WM_PRINT", 0x0317},
|
|
|
|
{"WM_PRINTCLIENT", 0x0318},
|
|
|
|
{"WM_THEMECHANGED", 0x031A},
|
|
|
|
{"WM_HANDHELDFIRST", 0x0358},
|
|
|
|
{"WM_HANDHELDLAST", 0x035F},
|
|
|
|
{"WM_AFXFIRST", 0x0360},
|
|
|
|
{"WM_AFXLAST", 0x037F},
|
|
|
|
{"WM_PENWINFIRST", 0x0380},
|
|
|
|
{"WM_PENWINLAST", 0x038F},
|
|
|
|
{"WM_APP", 0x8000},
|
|
|
|
{NULL, 0x0}
|
|
|
|
};
|
2000-05-11 13:39:17 +00:00
|
|
|
|
2001-05-25 10:53:32 +00:00
|
|
|
|
2000-05-11 13:39:17 +00:00
|
|
|
static long gEventCounter = 0;
|
|
|
|
static long gLastEventMsg = 0;
|
|
|
|
|
|
|
|
void PrintEvent(UINT msg, PRBool aShowAllEvents, PRBool aShowMouseMoves)
|
|
|
|
{
|
|
|
|
int inx = 0;
|
|
|
|
while (gAllEvents[inx].mId != (long)msg && gAllEvents[inx].mStr != NULL) {
|
|
|
|
inx++;
|
|
|
|
}
|
|
|
|
if (aShowAllEvents || (!aShowAllEvents && gLastEventMsg != (long)msg)) {
|
|
|
|
if (aShowMouseMoves || (!aShowMouseMoves && msg != 0x0020 && msg != 0x0200 && msg != 0x0084)) {
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("%6d - 0x%04X %s\n", gEventCounter++, msg, gAllEvents[inx].mStr ? gAllEvents[inx].mStr : "Unknown");
|
2000-05-11 13:39:17 +00:00
|
|
|
gLastEventMsg = msg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2001-12-17 22:51:39 +00:00
|
|
|
#define WM_XP_THEMECHANGED 0x031A
|
2000-05-11 13:39:17 +00:00
|
|
|
|
2002-02-27 02:18:12 +00:00
|
|
|
// Static helper functions for heap dumping
|
|
|
|
static nsresult HeapDump(const char *filename, const char *heading)
|
|
|
|
{
|
2005-02-23 07:07:51 +00:00
|
|
|
#ifdef WINCE
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
#else
|
2002-02-27 02:18:12 +00:00
|
|
|
|
|
|
|
PRFileDesc *prfd = PR_Open(filename, PR_CREATE_FILE | PR_APPEND | PR_WRONLY, 0777);
|
|
|
|
if (!prfd)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
char buf[1024];
|
|
|
|
PRUint32 n;
|
|
|
|
PRUint32 written = 0;
|
|
|
|
HANDLE heapHandle[64];
|
2006-02-17 17:22:34 +00:00
|
|
|
DWORD nheap = GetProcessHeaps(64, heapHandle);
|
2002-02-27 02:18:12 +00:00
|
|
|
if (nheap == 0 || nheap > 64) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
n = PR_snprintf(buf, sizeof buf, "BEGIN HEAPDUMP : %s\n", heading);
|
|
|
|
PR_Write(prfd, buf, n);
|
|
|
|
for (DWORD i = 0; i < nheap; i++) {
|
|
|
|
// Dump each heap
|
|
|
|
PROCESS_HEAP_ENTRY ent = {0};
|
2002-02-27 22:36:08 +00:00
|
|
|
n = PR_snprintf(buf, sizeof buf, "BEGIN heap %d : 0x%p\n", i+1, heapHandle[i]);
|
2002-02-27 02:18:12 +00:00
|
|
|
PR_Write(prfd, buf, n);
|
|
|
|
ent.lpData = NULL;
|
2006-02-17 17:22:34 +00:00
|
|
|
while (HeapWalk(heapHandle[i], &ent)) {
|
2002-02-27 22:36:08 +00:00
|
|
|
if (ent.wFlags & PROCESS_HEAP_REGION)
|
|
|
|
n = PR_snprintf(buf, sizeof buf, "REGION %08p : overhead %d committed %d uncommitted %d firstblock %08p lastblock %08p\n",
|
|
|
|
ent.lpData, ent.cbOverhead,
|
|
|
|
ent.Region.dwCommittedSize, ent.Region.dwUnCommittedSize,
|
|
|
|
ent.Region.lpFirstBlock, ent.Region.lpLastBlock);
|
|
|
|
else
|
|
|
|
n = PR_snprintf(buf, sizeof buf, "%s %08p : %6d overhead %2d\n",
|
|
|
|
(ent.wFlags & PROCESS_HEAP_UNCOMMITTED_RANGE) ? "----" : ((ent.wFlags & PROCESS_HEAP_ENTRY_BUSY) ? "USED" : "FREE"),
|
|
|
|
ent.lpData, ent.cbData, ent.cbOverhead);
|
2002-02-27 02:18:12 +00:00
|
|
|
PR_Write(prfd, buf, n);
|
|
|
|
}
|
2002-02-27 22:36:08 +00:00
|
|
|
n = PR_snprintf(buf, sizeof buf, "END heap %d : 0x%p\n", i+1, heapHandle[i]);
|
|
|
|
PR_Write(prfd, buf, n);
|
2002-02-27 02:18:12 +00:00
|
|
|
}
|
|
|
|
n = PR_snprintf(buf, sizeof buf, "END HEAPDUMP : %s\n", heading);
|
|
|
|
PR_Write(prfd, buf, n);
|
|
|
|
|
|
|
|
PR_Close(prfd);
|
|
|
|
return NS_OK;
|
2005-06-29 18:52:08 +00:00
|
|
|
#endif // WINCE
|
2002-02-27 02:18:12 +00:00
|
|
|
}
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// Recursively dispatch synchronous paints for nsIWidget
|
2002-09-20 01:24:36 +00:00
|
|
|
// descendants with invalidated rectangles.
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
BOOL CALLBACK nsWindow::DispatchStarvedPaints(HWND aWnd, LPARAM aMsg)
|
2002-09-20 01:24:36 +00:00
|
|
|
{
|
2006-04-04 20:57:13 +00:00
|
|
|
LONG proc = ::GetWindowLongW(aWnd, GWL_WNDPROC);
|
2002-09-20 01:24:36 +00:00
|
|
|
if (proc == (LONG)&nsWindow::WindowProc) {
|
2004-09-03 08:44:23 +00:00
|
|
|
// its one of our windows so check to see if it has a
|
2002-09-20 01:24:36 +00:00
|
|
|
// invalidated rect. If it does. Dispatch a synchronous
|
|
|
|
// paint.
|
|
|
|
if (GetUpdateRect(aWnd, NULL, FALSE)) {
|
2004-09-03 08:44:23 +00:00
|
|
|
VERIFY(::UpdateWindow(aWnd));
|
2002-09-20 01:24:36 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
2002-09-20 01:24:36 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// Check for pending paints and dispatch any pending paint
|
|
|
|
// messages for any nsIWidget which is a descendant of the
|
|
|
|
// top-level window that *this* window is embedded within.
|
2006-05-10 17:30:15 +00:00
|
|
|
//
|
2004-09-03 08:44:23 +00:00
|
|
|
// Note: We do not dispatch pending paint messages for non
|
|
|
|
// nsIWidget managed windows.
|
2002-09-20 01:24:36 +00:00
|
|
|
|
2002-09-28 15:04:47 +00:00
|
|
|
void nsWindow::DispatchPendingEvents()
|
2002-09-20 01:24:36 +00:00
|
|
|
{
|
2002-10-01 03:04:22 +00:00
|
|
|
gLastInputEventTime = PR_IntervalToMicroseconds(PR_IntervalNow());
|
|
|
|
|
2006-05-10 17:30:15 +00:00
|
|
|
// We need to ensure that reflow events do not get starved.
|
|
|
|
// At the same time, we don't want to recurse through here
|
|
|
|
// as that would prevent us from dispatching starved paints.
|
|
|
|
static int recursionBlocker = 0;
|
|
|
|
if (recursionBlocker++ == 0) {
|
|
|
|
NS_ProcessPendingEvents(nsnull, PR_MillisecondsToInterval(100));
|
|
|
|
--recursionBlocker;
|
2002-09-28 15:04:47 +00:00
|
|
|
}
|
|
|
|
|
2002-09-20 01:24:36 +00:00
|
|
|
// Quickly check to see if there are any
|
|
|
|
// paint events pending.
|
|
|
|
if (::GetQueueStatus(QS_PAINT)) {
|
|
|
|
// Find the top level window.
|
2004-09-03 08:44:23 +00:00
|
|
|
HWND topWnd = GetTopLevelHWND(mWnd);
|
|
|
|
|
|
|
|
// Dispatch pending paints for all topWnd's descendant windows.
|
2002-10-07 20:07:54 +00:00
|
|
|
// Note: EnumChildWindows enumerates all descendant windows not just
|
|
|
|
// it's children.
|
|
|
|
::EnumChildWindows(topWnd, nsWindow::DispatchStarvedPaints, NULL);
|
2002-09-20 01:24:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-23 17:02:45 +00:00
|
|
|
#ifndef WINCE
|
|
|
|
void nsWindow::PostSleepWakeNotification(const char* aNotification)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1");
|
|
|
|
if (observerService)
|
|
|
|
{
|
|
|
|
observerService->NotifyObservers(nsnull, aNotification, nsnull);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *aRetValue)
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
static UINT vkKeyCached = 0; // caches VK code fon WM_KEYDOWN
|
|
|
|
PRBool result = PR_FALSE; // call the default nsWindow proc
|
|
|
|
static PRBool getWheelInfo = PR_TRUE;
|
|
|
|
*aRetValue = 0;
|
2007-06-17 10:59:19 +00:00
|
|
|
PRBool isMozWindowTakingFocus = PR_TRUE;
|
2004-09-03 08:44:23 +00:00
|
|
|
nsPaletteInfo palInfo;
|
1998-06-01 17:04:16 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// Uncomment this to see all windows messages
|
|
|
|
// first param shows all events
|
|
|
|
// second param indicates whether to show mouse move events
|
|
|
|
//PrintEvent(msg, PR_FALSE, PR_FALSE);
|
2002-06-04 17:47:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
switch (msg) {
|
|
|
|
case WM_COMMAND:
|
|
|
|
{
|
|
|
|
WORD wNotifyCode = HIWORD(wParam); // notification code
|
|
|
|
if ((CBN_SELENDOK == wNotifyCode) || (CBN_SELENDCANCEL == wNotifyCode)) { // Combo box change
|
2005-04-28 23:48:28 +00:00
|
|
|
nsGUIEvent event(PR_TRUE, NS_CONTROL_CHANGE, this);
|
2004-09-03 08:44:23 +00:00
|
|
|
nsPoint point(0,0);
|
|
|
|
InitEvent(event, &point); // this add ref's event.widget
|
|
|
|
result = DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
} else if (wNotifyCode == 0) { // Menu selection
|
2005-04-28 23:48:28 +00:00
|
|
|
nsMenuEvent event(PR_TRUE, NS_MENU_SELECTED, this);
|
2004-09-03 08:44:23 +00:00
|
|
|
event.mCommand = LOWORD(wParam);
|
|
|
|
InitEvent(event);
|
|
|
|
result = DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1998-04-24 23:09:11 +00:00
|
|
|
|
2005-02-23 07:07:51 +00:00
|
|
|
#ifndef WINCE
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_DISPLAYCHANGE:
|
|
|
|
DispatchStandardEvent(NS_DISPLAYCHANGED);
|
|
|
|
break;
|
2005-02-23 07:07:51 +00:00
|
|
|
#endif
|
1998-05-04 19:25:25 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_SYSCOLORCHANGE:
|
|
|
|
// Note: This is sent for child windows as well as top-level windows.
|
|
|
|
// The Win32 toolkit normally only sends these events to top-level windows.
|
|
|
|
// But we cycle through all of the childwindows and send it to them as well
|
|
|
|
// so all presentations get notified properly.
|
|
|
|
// See nsWindow::GlobalMsgWindowProc.
|
|
|
|
DispatchStandardEvent(NS_SYSCOLORCHANGED);
|
|
|
|
break;
|
1998-04-24 23:09:11 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_NOTIFY:
|
|
|
|
// TAB change
|
|
|
|
{
|
|
|
|
LPNMHDR pnmh = (LPNMHDR) lParam;
|
2001-12-17 22:51:39 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
switch (pnmh->code) {
|
|
|
|
case TCN_SELCHANGE:
|
2001-06-11 22:42:27 +00:00
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
DispatchStandardEvent(NS_TABCHANGE);
|
|
|
|
result = PR_TRUE;
|
2001-06-11 22:42:27 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2001-06-11 22:42:27 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_XP_THEMECHANGED:
|
|
|
|
{
|
|
|
|
DispatchStandardEvent(NS_THEMECHANGED);
|
|
|
|
|
|
|
|
// Invalidate the window so that the repaint will
|
|
|
|
// pick up the new theme.
|
|
|
|
Invalidate(PR_FALSE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_FONTCHANGE:
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
PRBool didChange = PR_FALSE;
|
|
|
|
|
|
|
|
// update the global font list
|
|
|
|
nsCOMPtr<nsIFontEnumerator> fontEnum = do_GetService("@mozilla.org/gfx/fontenumerator;1", &rv);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
fontEnum->UpdateFontList(&didChange);
|
|
|
|
//didChange is TRUE only if new font langGroup is added to the list.
|
|
|
|
if (didChange) {
|
2006-09-10 19:15:09 +00:00
|
|
|
// update device context font cache
|
|
|
|
// Dirty but easiest way:
|
2006-10-23 15:29:09 +00:00
|
|
|
// Changing nsIPrefBranch entry which triggers callbacks
|
2006-09-10 19:15:09 +00:00
|
|
|
// and flows into calling mDeviceContext->FlushFontCache()
|
|
|
|
// to update the font cache in all the instance of Browsers
|
|
|
|
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
|
|
|
if (prefs) {
|
|
|
|
nsCOMPtr<nsIPrefBranch> fiPrefs;
|
|
|
|
prefs->GetBranch("font.internaluseonly.", getter_AddRefs(fiPrefs));
|
|
|
|
if (fiPrefs) {
|
|
|
|
PRBool fontInternalChange = PR_FALSE;
|
|
|
|
fiPrefs->GetBoolPref("changed", &fontInternalChange);
|
|
|
|
fiPrefs->SetBoolPref("changed", !fontInternalChange);
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
1998-04-24 23:09:11 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
} //if (NS_SUCCEEDED(rv))
|
|
|
|
}
|
|
|
|
break;
|
1998-04-17 00:16:11 +00:00
|
|
|
|
2006-02-23 17:02:45 +00:00
|
|
|
#ifndef WINCE
|
|
|
|
case WM_POWERBROADCAST:
|
|
|
|
// only hidden window handle this
|
|
|
|
// to prevent duplicate notification
|
|
|
|
if (mWindowType == eWindowType_invisible) {
|
|
|
|
switch (wParam)
|
|
|
|
{
|
|
|
|
case PBT_APMSUSPEND:
|
|
|
|
PostSleepWakeNotification("sleep_notification");
|
|
|
|
break;
|
|
|
|
case PBT_APMRESUMEAUTOMATIC:
|
|
|
|
case PBT_APMRESUMECRITICAL:
|
|
|
|
case PBT_APMRESUMESUSPEND:
|
|
|
|
PostSleepWakeNotification("wake_notification");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_MOVE: // Window moved
|
|
|
|
{
|
|
|
|
PRInt32 x = GET_X_LPARAM(lParam); // horizontal position in screen coordinates
|
|
|
|
PRInt32 y = GET_Y_LPARAM(lParam); // vertical position in screen coordinates
|
|
|
|
result = OnMove(x, y);
|
|
|
|
}
|
|
|
|
break;
|
1999-12-01 22:38:06 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_CLOSE: // close request
|
|
|
|
DispatchStandardEvent(NS_XUL_CLOSE);
|
|
|
|
result = PR_TRUE; // abort window closure
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_DESTROY:
|
|
|
|
// clean up.
|
|
|
|
OnDestroy();
|
|
|
|
result = PR_TRUE;
|
|
|
|
break;
|
2003-04-14 22:56:35 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_PAINT:
|
2006-03-07 21:08:48 +00:00
|
|
|
#ifdef MOZ_CAIRO_GFX
|
|
|
|
*aRetValue = (int) OnPaint();
|
|
|
|
result = PR_TRUE;
|
|
|
|
#else
|
2004-09-03 08:44:23 +00:00
|
|
|
result = OnPaint();
|
2006-03-07 21:08:48 +00:00
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
break;
|
|
|
|
|
2005-02-23 07:07:51 +00:00
|
|
|
#ifndef WINCE
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_PRINTCLIENT:
|
|
|
|
result = OnPaint((HDC) wParam);
|
|
|
|
break;
|
2005-02-23 07:07:51 +00:00
|
|
|
#endif
|
2005-08-22 15:17:53 +00:00
|
|
|
|
2005-07-24 19:36:18 +00:00
|
|
|
#ifdef WINCE
|
2005-10-13 15:07:56 +00:00
|
|
|
// This needs to move into nsIDOMKeyEvent.idl && nsGUIEvent.h
|
2005-07-24 19:36:18 +00:00
|
|
|
case WM_HOTKEY:
|
|
|
|
{
|
2005-10-13 15:07:56 +00:00
|
|
|
// SmartPhones has a one or two menu buttons at the
|
|
|
|
// bottom of the screen. They are dispatched via a
|
|
|
|
// menu resource, rather then a hotkey. To make
|
|
|
|
// this look consistent, we have mapped this menu to
|
|
|
|
// fire hotkey events. See
|
|
|
|
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/win_ce/html/pwc_TheBackButtonandOtherInterestingButtons.asp
|
|
|
|
|
2006-01-28 18:18:45 +00:00
|
|
|
if (VK_TSOFT1 == HIWORD(lParam) && (0 != (MOD_KEYUP & LOWORD(lParam))))
|
2005-10-13 15:07:56 +00:00
|
|
|
{
|
2006-04-27 19:22:33 +00:00
|
|
|
keybd_event(VK_F19, 0, 0, 0);
|
|
|
|
keybd_event(VK_F19, 0, KEYEVENTF_KEYUP, 0);
|
2005-10-13 15:07:56 +00:00
|
|
|
result = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-01-28 18:18:45 +00:00
|
|
|
if (VK_TSOFT2 == HIWORD(lParam) && (0 != (MOD_KEYUP & LOWORD(lParam))))
|
2005-10-13 15:07:56 +00:00
|
|
|
{
|
2006-04-27 19:22:33 +00:00
|
|
|
keybd_event(VK_F20, 0, 0, 0);
|
|
|
|
keybd_event(VK_F20, 0, KEYEVENTF_KEYUP, 0);
|
2005-10-13 15:07:56 +00:00
|
|
|
result = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VK_TBACK == HIWORD(lParam) && (0 != (MOD_KEYUP & LOWORD(lParam))))
|
|
|
|
{
|
|
|
|
keybd_event(VK_BACK, 0, 0, 0);
|
|
|
|
keybd_event(VK_BACK, 0, KEYEVENTF_KEYUP, 0);
|
|
|
|
result = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-07-24 19:36:18 +00:00
|
|
|
switch (wParam)
|
|
|
|
{
|
|
|
|
case VK_APP1:
|
2005-10-13 15:07:56 +00:00
|
|
|
keybd_event(VK_F1, 0, 0, 0);
|
|
|
|
keybd_event(VK_F1, 0, KEYEVENTF_KEYUP, 0);
|
|
|
|
result = 0;
|
2005-07-24 19:36:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_APP2:
|
2005-10-13 15:07:56 +00:00
|
|
|
keybd_event(VK_F2, 0, 0, 0);
|
|
|
|
keybd_event(VK_F2, 0, KEYEVENTF_KEYUP, 0);
|
|
|
|
result = 0;
|
2005-07-24 19:36:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_APP3:
|
2005-10-13 15:07:56 +00:00
|
|
|
keybd_event(VK_F3, 0, 0, 0);
|
|
|
|
keybd_event(VK_F3, 0, KEYEVENTF_KEYUP, 0);
|
|
|
|
result = 0;
|
2005-07-24 19:36:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_APP4:
|
2005-10-13 15:07:56 +00:00
|
|
|
keybd_event(VK_F4, 0, 0, 0);
|
|
|
|
keybd_event(VK_F4, 0, KEYEVENTF_KEYUP, 0);
|
|
|
|
result = 0;
|
2005-07-24 19:36:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_APP5:
|
2005-10-13 15:07:56 +00:00
|
|
|
keybd_event(VK_F5, 0, 0, 0);
|
|
|
|
keybd_event(VK_F5, 0, KEYEVENTF_KEYUP, 0);
|
|
|
|
result = 0;
|
2005-07-24 19:36:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_APP6:
|
2005-10-13 15:07:56 +00:00
|
|
|
keybd_event(VK_F6, 0, 0, 0);
|
|
|
|
keybd_event(VK_F6, 0, KEYEVENTF_KEYUP, 0);
|
|
|
|
result = 0;
|
2005-07-24 19:36:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2006-04-17 17:42:20 +00:00
|
|
|
case WM_SYSCHAR:
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_CHAR:
|
|
|
|
{
|
2005-05-16 11:17:45 +00:00
|
|
|
#ifdef KE_DEBUG
|
|
|
|
printf("%s\tchar=%c\twp=%4x\tlp=%8x\n", (msg == WM_SYSCHAR) ? "WM_SYSCHAR" : "WM_CHAR", wParam, wParam, lParam);
|
|
|
|
#endif
|
2006-11-24 02:10:50 +00:00
|
|
|
result = OnChar(wParam, lParam);
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
break;
|
2001-05-01 13:29:14 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_SYSKEYUP:
|
|
|
|
case WM_KEYUP:
|
2005-04-29 13:33:49 +00:00
|
|
|
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
#ifdef KE_DEBUG
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("%s\t\twp=%x\tlp=%x\n", (WM_KEYUP==msg) ? "WM_KEYUP" : "WM_SYSKEYUP", wParam, lParam);
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
mIsShiftDown = IS_VK_DOWN(NS_VK_SHIFT);
|
|
|
|
mIsControlDown = IS_VK_DOWN(NS_VK_CONTROL);
|
|
|
|
mIsAltDown = IS_VK_DOWN(NS_VK_ALT);
|
|
|
|
|
|
|
|
// Note: the original code passed (HIWORD(lParam)) to OnKeyUp as
|
|
|
|
// scan code. However, this breaks Alt+Num pad input.
|
2006-04-04 20:57:13 +00:00
|
|
|
// http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/toascii.asp
|
2004-09-03 08:44:23 +00:00
|
|
|
// states the following:
|
|
|
|
// Typically, ToAscii performs the translation based on the
|
|
|
|
// virtual-key code. In some cases, however, bit 15 of the
|
|
|
|
// uScanCode parameter may be used to distinguish between a key
|
|
|
|
// press and a key release. The scan code is used for
|
|
|
|
// translating ALT+number key combinations.
|
|
|
|
|
|
|
|
// ignore [shift+]alt+space so the OS can handle it
|
|
|
|
if (mIsAltDown && !mIsControlDown && IS_VK_DOWN(NS_VK_SPACE)) {
|
|
|
|
result = PR_FALSE;
|
|
|
|
DispatchPendingEvents();
|
|
|
|
break;
|
|
|
|
}
|
2002-02-02 05:26:36 +00:00
|
|
|
|
2004-12-03 22:32:50 +00:00
|
|
|
if (!sIMEIsComposing && (msg != WM_KEYUP || wParam != VK_MENU)) {
|
|
|
|
// Ignore VK_MENU if it's not a system key release, so that the menu bar does not trigger
|
|
|
|
// This helps avoid triggering the menu bar for ALT key accelerators used in
|
|
|
|
// assistive technologies such as Window-Eyes and ZoomText, and when using Alt+Tab
|
|
|
|
// to switch back to Mozilla in Windows 95 and Windows 98
|
2004-09-03 08:44:23 +00:00
|
|
|
result = OnKeyUp(wParam, (HIWORD(lParam)), lParam);
|
2004-12-03 22:32:50 +00:00
|
|
|
}
|
|
|
|
else {
|
2004-09-03 08:44:23 +00:00
|
|
|
result = PR_FALSE;
|
2004-12-03 22:32:50 +00:00
|
|
|
}
|
2002-09-28 15:04:47 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
DispatchPendingEvents();
|
|
|
|
break;
|
1999-04-06 20:23:55 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// Let the fall through if it isn't a key pad
|
|
|
|
case WM_SYSKEYDOWN:
|
|
|
|
case WM_KEYDOWN:
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
#ifdef KE_DEBUG
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("%s\t\twp=%4x\tlp=%8x\n", (WM_KEYDOWN==msg) ? "WM_KEYDOWN" : "WM_SYSKEYDOWN", wParam, lParam);
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
#endif
|
2002-02-16 01:44:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
mIsShiftDown = IS_VK_DOWN(NS_VK_SHIFT);
|
|
|
|
mIsControlDown = IS_VK_DOWN(NS_VK_CONTROL);
|
|
|
|
mIsAltDown = IS_VK_DOWN(NS_VK_ALT);
|
|
|
|
|
|
|
|
// Note: the original code passed (HIWORD(lParam)) to OnKeyDown as
|
|
|
|
// scan code. However, this breaks Alt+Num pad input.
|
2006-04-04 20:57:13 +00:00
|
|
|
// http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/toascii.asp
|
2004-09-03 08:44:23 +00:00
|
|
|
// states the following:
|
|
|
|
// Typically, ToAscii performs the translation based on the
|
|
|
|
// virtual-key code. In some cases, however, bit 15 of the
|
|
|
|
// uScanCode parameter may be used to distinguish between a key
|
|
|
|
// press and a key release. The scan code is used for
|
|
|
|
// translating ALT+number key combinations.
|
|
|
|
|
|
|
|
// ignore [shift+]alt+space so the OS can handle it
|
|
|
|
if (mIsAltDown && !mIsControlDown && IS_VK_DOWN(NS_VK_SPACE)) {
|
|
|
|
result = PR_FALSE;
|
|
|
|
DispatchPendingEvents();
|
|
|
|
break;
|
|
|
|
}
|
2002-02-02 05:26:36 +00:00
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
if (mIsAltDown && sIMEIsStatusChanged) {
|
|
|
|
sIMEIsStatusChanged = FALSE;
|
2004-09-03 08:44:23 +00:00
|
|
|
result = PR_FALSE;
|
|
|
|
}
|
2004-09-08 19:30:22 +00:00
|
|
|
else if (!sIMEIsComposing) {
|
2004-09-03 08:44:23 +00:00
|
|
|
result = OnKeyDown(wParam, (HIWORD(lParam)), lParam);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
result = PR_FALSE;
|
2005-02-23 07:07:51 +00:00
|
|
|
#ifndef WINCE
|
2004-09-03 08:44:23 +00:00
|
|
|
if (wParam == VK_MENU || (wParam == VK_F10 && !mIsShiftDown)) {
|
|
|
|
// We need to let Windows handle this keypress,
|
|
|
|
// by returning PR_FALSE, if there's a native menu
|
|
|
|
// bar somewhere in our containing window hierarchy.
|
|
|
|
// Otherwise we handle the keypress and don't pass
|
|
|
|
// it on to Windows, by returning PR_TRUE.
|
|
|
|
PRBool hasNativeMenu = PR_FALSE;
|
|
|
|
HWND hWnd = mWnd;
|
|
|
|
while (hWnd) {
|
|
|
|
if (::GetMenu(hWnd)) {
|
|
|
|
hasNativeMenu = PR_TRUE;
|
1998-04-13 20:24:54 +00:00
|
|
|
break;
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
hWnd = ::GetParent(hWnd);
|
|
|
|
}
|
|
|
|
result = !hasNativeMenu;
|
|
|
|
}
|
2005-02-23 07:07:51 +00:00
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
DispatchPendingEvents();
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// say we've dealt with erase background if widget does
|
|
|
|
// not need auto-erasing
|
|
|
|
case WM_ERASEBKGND:
|
|
|
|
if (! AutoErase()) {
|
|
|
|
*aRetValue = 1;
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_GETDLGCODE:
|
|
|
|
*aRetValue = DLGC_WANTALLKEYS;
|
|
|
|
result = PR_TRUE;
|
|
|
|
break;
|
2001-09-27 11:10:17 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_MOUSEMOVE:
|
2005-12-02 12:08:32 +00:00
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
// Suppress dispatch of pending events
|
|
|
|
// when mouse moves are generated by widget
|
|
|
|
// creation instead of user input.
|
2005-12-29 10:18:31 +00:00
|
|
|
LPARAM lParamScreen = lParamToScreen(lParam);
|
2004-09-03 08:44:23 +00:00
|
|
|
POINT mp;
|
2005-12-29 10:18:31 +00:00
|
|
|
mp.x = GET_X_LPARAM(lParamScreen);
|
|
|
|
mp.y = GET_Y_LPARAM(lParamScreen);
|
2004-09-03 08:44:23 +00:00
|
|
|
PRBool userMovedMouse = PR_FALSE;
|
|
|
|
if ((gLastMouseMovePoint.x != mp.x) || (gLastMouseMovePoint.y != mp.y)) {
|
|
|
|
userMovedMouse = PR_TRUE;
|
|
|
|
}
|
2002-09-20 01:24:36 +00:00
|
|
|
|
2005-12-02 12:08:32 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_MOVE, wParam, lParam);
|
2004-09-03 08:44:23 +00:00
|
|
|
if (userMovedMouse) {
|
|
|
|
DispatchPendingEvents();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
//SetFocus(); // this is bad
|
|
|
|
//RelayMouseEvent(msg,wParam, lParam);
|
|
|
|
{
|
2005-08-11 00:37:53 +00:00
|
|
|
#ifdef WINCE
|
2005-11-02 19:20:31 +00:00
|
|
|
if (!gRollupListener && !gRollupWidget)
|
2005-08-11 00:37:53 +00:00
|
|
|
{
|
2005-11-02 19:20:31 +00:00
|
|
|
SHRGINFO shrg;
|
|
|
|
shrg.cbSize = sizeof(shrg);
|
|
|
|
shrg.hwndClient = mWnd;
|
|
|
|
shrg.ptDown.x = LOWORD(lParam);
|
|
|
|
shrg.ptDown.y = HIWORD(lParam);
|
|
|
|
shrg.dwFlags = SHRG_RETURNCMD;
|
|
|
|
if (SHRecognizeGesture(&shrg) == GN_CONTEXTMENU)
|
|
|
|
{
|
2006-11-16 21:35:39 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_BUTTON_DOWN, wParam, lParam,
|
|
|
|
PR_FALSE, nsMouseEvent::eRightButton);
|
|
|
|
result = DispatchMouseEvent(NS_MOUSE_BUTTON_UP, wParam, lParam,
|
|
|
|
PR_FALSE, nsMouseEvent::eRightButton);
|
2005-11-02 19:20:31 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-08-11 00:37:53 +00:00
|
|
|
}
|
2006-04-18 18:31:26 +00:00
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
// check whether IME window do mouse operation
|
2006-11-16 21:35:39 +00:00
|
|
|
if (IMEMouseHandling(IMEMOUSE_LDOWN, lParam))
|
2004-09-03 08:44:23 +00:00
|
|
|
break;
|
2006-04-18 18:31:26 +00:00
|
|
|
|
2006-11-16 21:35:39 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_BUTTON_DOWN, wParam, lParam,
|
|
|
|
PR_FALSE, nsMouseEvent::eLeftButton);
|
2004-09-03 08:44:23 +00:00
|
|
|
DispatchPendingEvents();
|
|
|
|
}
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_LBUTTONUP:
|
|
|
|
//RelayMouseEvent(msg,wParam, lParam);
|
2006-11-16 21:35:39 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_BUTTON_UP, wParam, lParam,
|
|
|
|
PR_FALSE, nsMouseEvent::eLeftButton);
|
2004-09-03 08:44:23 +00:00
|
|
|
DispatchPendingEvents();
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2005-12-02 12:08:32 +00:00
|
|
|
#ifndef WINCE
|
|
|
|
case WM_MOUSELEAVE:
|
|
|
|
{
|
2006-07-08 12:32:40 +00:00
|
|
|
// We use MINLONG | MINSHORT as the mouse position to make sure
|
2005-12-02 12:08:32 +00:00
|
|
|
// EventStateManager doesn't convert this EXIT message to
|
|
|
|
// a MOVE message (besides, WM_MOUSELEAVE doesn't have the position
|
|
|
|
// in lParam).
|
2006-11-19 21:13:25 +00:00
|
|
|
// We also need to check mouse button states and put them in for
|
|
|
|
// wParam.
|
|
|
|
WPARAM mouseState = (GetKeyState(VK_LBUTTON) ? MK_LBUTTON : 0)
|
|
|
|
| (GetKeyState(VK_MBUTTON) ? MK_MBUTTON : 0)
|
|
|
|
| (GetKeyState(VK_RBUTTON) ? MK_RBUTTON : 0);
|
|
|
|
DispatchMouseEvent(NS_MOUSE_EXIT, mouseState, MINLONG | MINSHORT);
|
2005-12-02 12:08:32 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_CONTEXTMENU:
|
|
|
|
{
|
|
|
|
// if the context menu is brought up from the keyboard, |lParam|
|
2006-11-23 04:52:53 +00:00
|
|
|
// will be maxlong.
|
2005-12-02 12:08:32 +00:00
|
|
|
LPARAM pos;
|
2006-11-16 21:35:39 +00:00
|
|
|
PRBool contextMenukey = PR_FALSE;
|
2005-12-02 12:08:32 +00:00
|
|
|
if (lParam == 0xFFFFFFFF)
|
|
|
|
{
|
2006-11-16 21:35:39 +00:00
|
|
|
contextMenukey = PR_TRUE;
|
2005-12-02 12:08:32 +00:00
|
|
|
pos = lParamToClient(GetMessagePos());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pos = lParamToClient(lParam);
|
|
|
|
}
|
2006-11-23 04:52:53 +00:00
|
|
|
result = DispatchMouseEvent(NS_CONTEXTMENU, wParam, pos, contextMenukey,
|
|
|
|
nsMouseEvent::eRightButton);
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_LBUTTONDBLCLK:
|
2006-11-16 21:35:39 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_DOUBLECLICK, wParam, lParam, PR_FALSE,
|
|
|
|
nsMouseEvent::eLeftButton);
|
2004-09-03 08:44:23 +00:00
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
{
|
|
|
|
// check whether IME window do mouse operation
|
2006-11-16 21:35:39 +00:00
|
|
|
if (IMEMouseHandling(IMEMOUSE_MDOWN, lParam))
|
2004-09-03 08:44:23 +00:00
|
|
|
break;
|
2006-11-16 21:35:39 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_BUTTON_DOWN, wParam, lParam, PR_FALSE,
|
|
|
|
nsMouseEvent::eMiddleButton);
|
2004-09-03 08:44:23 +00:00
|
|
|
DispatchPendingEvents();
|
|
|
|
}
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_MBUTTONUP:
|
2006-11-16 21:35:39 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_BUTTON_UP, wParam, lParam, PR_FALSE,
|
|
|
|
nsMouseEvent::eMiddleButton);
|
2004-09-03 08:44:23 +00:00
|
|
|
DispatchPendingEvents();
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_MBUTTONDBLCLK:
|
2006-11-16 21:35:39 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_BUTTON_DOWN, wParam, lParam, PR_FALSE,
|
|
|
|
nsMouseEvent::eMiddleButton);
|
2004-09-03 08:44:23 +00:00
|
|
|
break;
|
2002-12-06 03:41:43 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
{
|
|
|
|
// check whether IME window do mouse operation
|
2006-11-16 21:35:39 +00:00
|
|
|
if (IMEMouseHandling(IMEMOUSE_RDOWN, lParam))
|
2004-09-03 08:44:23 +00:00
|
|
|
break;
|
2006-11-16 21:35:39 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_BUTTON_DOWN, wParam, lParam, PR_FALSE,
|
|
|
|
nsMouseEvent::eRightButton);
|
2004-09-03 08:44:23 +00:00
|
|
|
DispatchPendingEvents();
|
|
|
|
}
|
|
|
|
break;
|
2002-12-06 03:41:43 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_RBUTTONUP:
|
2006-11-16 21:35:39 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_BUTTON_UP, wParam, lParam, PR_FALSE,
|
|
|
|
nsMouseEvent::eRightButton);
|
2004-09-03 08:44:23 +00:00
|
|
|
DispatchPendingEvents();
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_RBUTTONDBLCLK:
|
2006-11-16 21:35:39 +00:00
|
|
|
result = DispatchMouseEvent(NS_MOUSE_DOUBLECLICK, wParam, lParam, PR_FALSE,
|
|
|
|
nsMouseEvent::eRightButton);
|
2004-09-03 08:44:23 +00:00
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_APPCOMMAND:
|
|
|
|
{
|
|
|
|
PRUint32 appCommand = GET_APPCOMMAND_LPARAM(lParam);
|
2000-04-01 22:16:43 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
switch (appCommand)
|
|
|
|
{
|
|
|
|
case APPCOMMAND_BROWSER_BACKWARD:
|
|
|
|
case APPCOMMAND_BROWSER_FORWARD:
|
|
|
|
case APPCOMMAND_BROWSER_REFRESH:
|
|
|
|
case APPCOMMAND_BROWSER_STOP:
|
2006-12-01 11:09:53 +00:00
|
|
|
case APPCOMMAND_BROWSER_SEARCH:
|
|
|
|
case APPCOMMAND_BROWSER_FAVORITES:
|
|
|
|
case APPCOMMAND_BROWSER_HOME:
|
|
|
|
DispatchCommandEvent(appCommand);
|
2004-09-03 08:44:23 +00:00
|
|
|
// tell the driver that we handled the event
|
|
|
|
*aRetValue = 1;
|
|
|
|
result = PR_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// default = PR_FALSE - tell the driver that the event was not handled
|
|
|
|
}
|
|
|
|
break;
|
2000-04-01 22:16:43 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_HSCROLL:
|
|
|
|
case WM_VSCROLL:
|
|
|
|
// check for the incoming nsWindow handle to be null in which case
|
|
|
|
// we assume the message is coming from a horizontal scrollbar inside
|
|
|
|
// a listbox and we don't bother processing it (well, we don't have to)
|
|
|
|
if (lParam) {
|
|
|
|
nsWindow* scrollbar = GetNSWindowPtr((HWND)lParam);
|
2000-04-01 22:16:43 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (scrollbar) {
|
|
|
|
result = scrollbar->OnScroll(LOWORD(wParam), (short)HIWORD(wParam));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2000-04-01 22:16:43 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_CTLCOLORLISTBOX:
|
|
|
|
case WM_CTLCOLOREDIT:
|
|
|
|
case WM_CTLCOLORBTN:
|
|
|
|
//case WM_CTLCOLORSCROLLBAR: //XXX causes the scrollbar to be drawn incorrectly
|
|
|
|
case WM_CTLCOLORSTATIC:
|
|
|
|
if (lParam) {
|
|
|
|
nsWindow* control = GetNSWindowPtr((HWND)lParam);
|
|
|
|
if (control) {
|
|
|
|
control->SetUpForPaint((HDC)wParam);
|
|
|
|
*aRetValue = (LPARAM)control->OnControlColor();
|
2000-04-01 22:16:43 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
2000-04-01 22:16:43 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
result = PR_TRUE;
|
|
|
|
break;
|
2000-08-24 04:53:31 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_ACTIVATE:
|
|
|
|
if (mEventCallback) {
|
|
|
|
PRInt32 fActive = LOWORD(wParam);
|
1999-11-13 05:16:33 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (WA_INACTIVE == fActive) {
|
2007-06-17 10:59:19 +00:00
|
|
|
gJustGotDeactivate = PR_TRUE;
|
2004-12-09 19:01:35 +00:00
|
|
|
if (mIsTopWidgetWindow)
|
|
|
|
mLastKeyboardLayout = gKeyboardLayout;
|
2004-09-03 08:44:23 +00:00
|
|
|
} else {
|
2007-06-17 10:59:19 +00:00
|
|
|
gJustGotActivate = PR_TRUE;
|
2005-04-28 23:48:28 +00:00
|
|
|
nsMouseEvent event(PR_TRUE, NS_MOUSE_ACTIVATE, this,
|
|
|
|
nsMouseEvent::eReal);
|
2004-09-03 08:44:23 +00:00
|
|
|
InitEvent(event);
|
|
|
|
|
|
|
|
event.acceptActivation = PR_TRUE;
|
2007-06-17 10:59:19 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
PRBool result = DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
|
|
|
|
if (event.acceptActivation)
|
|
|
|
*aRetValue = MA_ACTIVATE;
|
|
|
|
else
|
|
|
|
*aRetValue = MA_NOACTIVATE;
|
2004-12-09 19:01:35 +00:00
|
|
|
|
|
|
|
if (gSwitchKeyboardLayout && mLastKeyboardLayout)
|
|
|
|
ActivateKeyboardLayout(mLastKeyboardLayout, 0);
|
2000-04-01 22:16:43 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-02-23 07:07:51 +00:00
|
|
|
#ifndef WINCE
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_WINDOWPOSCHANGING:
|
|
|
|
{
|
|
|
|
LPWINDOWPOS info = (LPWINDOWPOS) lParam;
|
|
|
|
// enforce local z-order rules
|
|
|
|
if (!(info->flags & SWP_NOZORDER))
|
|
|
|
ConstrainZLevel(&info->hwndInsertAfter);
|
|
|
|
// prevent rude external programs from making hidden window visible
|
|
|
|
if (mWindowType == eWindowType_invisible)
|
|
|
|
info->flags &= ~SWP_SHOWWINDOW;
|
|
|
|
}
|
|
|
|
break;
|
2005-02-23 07:07:51 +00:00
|
|
|
#endif
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_SETFOCUS:
|
2007-02-20 19:45:17 +00:00
|
|
|
{
|
|
|
|
nsWindow* topWindow = GetNSWindowPtr(::GetAncestor(mWnd, GA_ROOT));
|
|
|
|
|
2007-02-27 17:50:16 +00:00
|
|
|
result = DispatchFocus(NS_GOTFOCUS, PR_TRUE);
|
|
|
|
|
2007-02-20 19:45:17 +00:00
|
|
|
if ((HWND)wParam == NULL ||
|
|
|
|
(topWindow && topWindow->mWnd != ::GetAncestor((HWND)wParam, GA_ROOT))) {
|
|
|
|
result = DispatchFocus(NS_ACTIVATE, PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-25 08:34:42 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2004-09-03 08:44:23 +00:00
|
|
|
if (nsWindow::gIsAccessibilityOn) {
|
2005-07-15 02:35:19 +00:00
|
|
|
// Create it for the first time so that it can start firing events
|
2006-04-18 19:08:34 +00:00
|
|
|
nsCOMPtr<nsIAccessible> rootAccessible = GetRootAccessible();
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
2001-09-25 08:34:42 +00:00
|
|
|
#endif
|
2005-11-02 19:20:31 +00:00
|
|
|
|
|
|
|
#ifdef WINCE
|
|
|
|
// On Windows CE, we have a window that overlaps
|
|
|
|
// the ISP button. In this case, we should always
|
|
|
|
// try to hide it when we are activated
|
|
|
|
if (mWindowType == eWindowType_dialog || mWindowType == eWindowType_toplevel) {
|
|
|
|
|
|
|
|
// This should work on all platforms, but it doesn't...
|
|
|
|
SHFullScreen(mWnd, SHFS_HIDESIPBUTTON);
|
|
|
|
|
2006-06-16 22:13:36 +00:00
|
|
|
HWND hWndSIP = FindWindow( _T( "MS_SIPBUTTON" ), NULL );
|
2005-11-02 19:20:31 +00:00
|
|
|
if (hWndSIP)
|
|
|
|
{
|
|
|
|
ShowWindow( hWndSIP, SW_HIDE );
|
|
|
|
SetWindowPos(hWndSIP, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
|
|
|
|
}
|
|
|
|
}
|
2006-05-30 20:57:07 +00:00
|
|
|
{
|
|
|
|
// Get current input context
|
|
|
|
HIMC hC = ImmGetContext(mWnd);
|
|
|
|
// Open the IME
|
|
|
|
ImmSetOpenStatus(hC, TRUE);
|
|
|
|
// Set "multi-press" input mode
|
|
|
|
ImmEscapeW(NULL, hC, IME_ESC_SET_MODE, (LPVOID)IM_SPELL);
|
|
|
|
}
|
2005-11-02 19:20:31 +00:00
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_KILLFOCUS:
|
2006-05-30 20:57:07 +00:00
|
|
|
#ifdef WINCE
|
|
|
|
{
|
|
|
|
// Get current input context
|
|
|
|
HIMC hC = ImmGetContext(mWnd);
|
|
|
|
// Close the IME
|
|
|
|
ImmSetOpenStatus(hC, FALSE);
|
|
|
|
}
|
|
|
|
#endif
|
2007-06-17 10:59:19 +00:00
|
|
|
WCHAR className[kMaxClassNameLength];
|
|
|
|
::GetClassNameW((HWND)wParam, className, kMaxClassNameLength);
|
|
|
|
if (wcscmp(className, kWClassNameUI) &&
|
|
|
|
wcscmp(className, kWClassNameContent) &&
|
|
|
|
wcscmp(className, kWClassNameContentFrame) &&
|
|
|
|
wcscmp(className, kWClassNameDialog) &&
|
|
|
|
wcscmp(className, kWClassNameGeneral)) {
|
|
|
|
isMozWindowTakingFocus = PR_FALSE;
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
2007-06-17 10:59:19 +00:00
|
|
|
if (gJustGotDeactivate) {
|
|
|
|
gJustGotDeactivate = PR_FALSE;
|
|
|
|
result = DispatchFocus(NS_DEACTIVATE, isMozWindowTakingFocus);
|
|
|
|
}
|
|
|
|
result = DispatchFocus(NS_LOSTFOCUS, isMozWindowTakingFocus);
|
2004-09-03 08:44:23 +00:00
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_WINDOWPOSCHANGED:
|
|
|
|
{
|
|
|
|
WINDOWPOS *wp = (LPWINDOWPOS)lParam;
|
|
|
|
|
|
|
|
// We only care about a resize, so filter out things like z-order
|
|
|
|
// changes. Note: there's a WM_MOVE handler above which is why we're
|
|
|
|
// not handling them here...
|
|
|
|
if (0 == (wp->flags & SWP_NOSIZE)) {
|
|
|
|
// XXX Why are we using the client size area? If the size notification
|
|
|
|
// is for the client area then the origin should be (0,0) and not
|
|
|
|
// the window origin in screen coordinates...
|
|
|
|
RECT r;
|
|
|
|
::GetWindowRect(mWnd, &r);
|
|
|
|
PRInt32 newWidth, newHeight;
|
|
|
|
newWidth = PRInt32(r.right - r.left);
|
|
|
|
newHeight = PRInt32(r.bottom - r.top);
|
|
|
|
nsRect rect(wp->x, wp->y, newWidth, newHeight);
|
|
|
|
|
1998-06-19 02:46:25 +00:00
|
|
|
|
2005-12-19 03:00:41 +00:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
if (mIsTranslucent)
|
|
|
|
ResizeTranslucentWindow(newWidth, newHeight);
|
|
|
|
#endif
|
|
|
|
|
2006-06-16 02:27:37 +00:00
|
|
|
if (newWidth > mLastSize.width)
|
2004-09-03 08:44:23 +00:00
|
|
|
{
|
2006-06-16 02:27:37 +00:00
|
|
|
RECT drect;
|
2005-12-19 03:00:41 +00:00
|
|
|
|
2006-06-16 02:27:37 +00:00
|
|
|
//getting wider
|
|
|
|
drect.left = wp->x + mLastSize.width;
|
|
|
|
drect.top = wp->y;
|
|
|
|
drect.right = drect.left + (newWidth - mLastSize.width);
|
|
|
|
drect.bottom = drect.top + newHeight;
|
2005-12-19 03:00:41 +00:00
|
|
|
|
2006-06-16 02:27:37 +00:00
|
|
|
::RedrawWindow(mWnd, &drect, NULL,
|
|
|
|
RDW_INVALIDATE | RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_ERASENOW | RDW_ALLCHILDREN);
|
|
|
|
}
|
|
|
|
if (newHeight > mLastSize.height)
|
|
|
|
{
|
|
|
|
RECT drect;
|
1998-06-19 02:46:25 +00:00
|
|
|
|
2006-06-16 02:27:37 +00:00
|
|
|
//getting taller
|
|
|
|
drect.left = wp->x;
|
|
|
|
drect.top = wp->y + mLastSize.height;
|
|
|
|
drect.right = drect.left + newWidth;
|
|
|
|
drect.bottom = drect.top + (newHeight - mLastSize.height);
|
1998-06-19 02:46:25 +00:00
|
|
|
|
2006-06-16 02:27:37 +00:00
|
|
|
::RedrawWindow(mWnd, &drect, NULL,
|
|
|
|
RDW_INVALIDATE | RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_ERASENOW | RDW_ALLCHILDREN);
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
2004-07-27 19:14:44 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
mBounds.width = newWidth;
|
|
|
|
mBounds.height = newHeight;
|
|
|
|
mLastSize.width = newWidth;
|
|
|
|
mLastSize.height = newHeight;
|
|
|
|
///nsRect rect(wp->x, wp->y, wp->cx, wp->cy);
|
|
|
|
|
|
|
|
// If we're being minimized, don't send the resize event to Gecko because
|
|
|
|
// it will cause the scrollbar in the content area to go away and we'll
|
|
|
|
// forget the scroll position of the page.
|
|
|
|
if ( !newWidth && !newHeight ) {
|
|
|
|
result = PR_FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2000-12-19 03:01:31 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// recalculate the width and height
|
|
|
|
// this time based on the client area
|
|
|
|
if (::GetClientRect(mWnd, &r)) {
|
|
|
|
rect.width = PRInt32(r.right - r.left);
|
|
|
|
rect.height = PRInt32(r.bottom - r.top);
|
|
|
|
}
|
|
|
|
result = OnResize(rect);
|
|
|
|
}
|
2002-06-20 04:55:13 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
/* handle size mode changes
|
|
|
|
(the framechanged message seems a handy place to hook in,
|
|
|
|
because it happens early enough (WM_SIZE is too late) and
|
|
|
|
because in testing it seems an accurate harbinger of
|
|
|
|
an impending min/max/restore change (WM_NCCALCSIZE would
|
|
|
|
also work, but it's also sent when merely resizing.)) */
|
|
|
|
if (wp->flags & SWP_FRAMECHANGED && ::IsWindowVisible(mWnd)) {
|
|
|
|
WINDOWPLACEMENT pl;
|
|
|
|
pl.length = sizeof(pl);
|
|
|
|
::GetWindowPlacement(mWnd, &pl);
|
|
|
|
|
2005-04-28 23:48:28 +00:00
|
|
|
nsSizeModeEvent event(PR_TRUE, NS_SIZEMODE, this);
|
2004-09-03 08:44:23 +00:00
|
|
|
if (pl.showCmd == SW_SHOWMAXIMIZED)
|
|
|
|
event.mSizeMode = nsSizeMode_Maximized;
|
|
|
|
else if (pl.showCmd == SW_SHOWMINIMIZED)
|
|
|
|
event.mSizeMode = nsSizeMode_Minimized;
|
|
|
|
else
|
|
|
|
event.mSizeMode = nsSizeMode_Normal;
|
|
|
|
InitEvent(event);
|
|
|
|
|
|
|
|
result = DispatchWindowEvent(&event);
|
2007-06-17 10:59:19 +00:00
|
|
|
|
|
|
|
if (pl.showCmd == SW_SHOWMINIMIZED) {
|
|
|
|
// Deactivate
|
|
|
|
WCHAR className[kMaxClassNameLength];
|
|
|
|
::GetClassNameW((HWND)wParam, className, kMaxClassNameLength);
|
|
|
|
if (wcscmp(className, kWClassNameUI) &&
|
|
|
|
wcscmp(className, kWClassNameContent) &&
|
|
|
|
wcscmp(className, kWClassNameContentFrame) &&
|
|
|
|
wcscmp(className, kWClassNameDialog) &&
|
|
|
|
wcscmp(className, kWClassNameGeneral)) {
|
|
|
|
isMozWindowTakingFocus = PR_FALSE;
|
|
|
|
}
|
|
|
|
gJustGotDeactivate = PR_FALSE;
|
|
|
|
result = DispatchFocus(NS_DEACTIVATE, isMozWindowTakingFocus);
|
|
|
|
} else if (pl.showCmd == SW_SHOWNORMAL){
|
|
|
|
// Make sure we're active
|
|
|
|
result = DispatchFocus(NS_GOTFOCUS, PR_TRUE);
|
|
|
|
result = DispatchFocus(NS_ACTIVATE, PR_TRUE);
|
|
|
|
}
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_SETTINGCHANGE:
|
2005-08-16 19:15:06 +00:00
|
|
|
#ifdef WINCE
|
|
|
|
if (wParam == SPI_SETWORKAREA)
|
|
|
|
{
|
|
|
|
RECT workArea;
|
|
|
|
::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0);
|
|
|
|
|
|
|
|
SetWindowPos(mWnd,
|
|
|
|
nsnull,
|
|
|
|
workArea.left,
|
|
|
|
workArea.top,
|
|
|
|
workArea.right,
|
|
|
|
workArea.bottom,
|
|
|
|
SWP_NOACTIVATE | SWP_NOOWNERZORDER);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
getWheelInfo = PR_TRUE;
|
2004-09-03 08:44:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_PALETTECHANGED:
|
|
|
|
if ((HWND)wParam == mWnd) {
|
|
|
|
// We caused the WM_PALETTECHANGED message so avoid realizing
|
|
|
|
// another foreground palette
|
|
|
|
result = PR_TRUE;
|
1999-11-29 21:14:43 +00:00
|
|
|
break;
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
// fall thru...
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_QUERYNEWPALETTE: // this window is about to become active
|
|
|
|
mContext->GetPaletteInfo(palInfo);
|
|
|
|
if (palInfo.isPaletteDevice && palInfo.palette) {
|
|
|
|
HDC hDC = ::GetDC(mWnd);
|
|
|
|
HPALETTE hOldPal = ::SelectPalette(hDC, (HPALETTE)palInfo.palette, TRUE);
|
1998-08-19 00:57:02 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// Realize the drawing palette
|
|
|
|
int i = ::RealizePalette(hDC);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2001-06-20 05:48:45 +00:00
|
|
|
#ifdef DEBUG
|
2004-09-03 08:44:23 +00:00
|
|
|
//printf("number of colors that changed=%d\n",i);
|
2001-06-20 05:48:45 +00:00
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
// we should always invalidate.. because the lookup may have changed
|
|
|
|
::InvalidateRect(mWnd, (LPRECT)NULL, TRUE);
|
2000-02-11 14:35:01 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
::ReleaseDC(mWnd, hDC);
|
|
|
|
*aRetValue = TRUE;
|
|
|
|
}
|
|
|
|
result = PR_TRUE;
|
|
|
|
break;
|
|
|
|
|
2005-02-23 07:07:51 +00:00
|
|
|
#ifndef WINCE
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_INPUTLANGCHANGEREQUEST:
|
|
|
|
*aRetValue = TRUE;
|
|
|
|
result = PR_FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_INPUTLANGCHANGE:
|
|
|
|
result = OnInputLangChange((HKL)lParam, aRetValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_IME_STARTCOMPOSITION:
|
|
|
|
result = OnIMEStartComposition();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_IME_COMPOSITION:
|
|
|
|
result = OnIMEComposition(lParam);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_IME_ENDCOMPOSITION:
|
|
|
|
result = OnIMEEndComposition();
|
|
|
|
break;
|
1999-03-09 23:48:58 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_IME_CHAR:
|
|
|
|
// We receive double byte char code. No need to worry about the <Shift>
|
|
|
|
mIsShiftDown = PR_FALSE;
|
|
|
|
result = OnIMEChar((BYTE)(wParam >> 8), (BYTE)(wParam & 0x00FF), lParam);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_IME_NOTIFY:
|
|
|
|
result = OnIMENotify(wParam, lParam, aRetValue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// This is a Window 98/2000 only message
|
|
|
|
case WM_IME_REQUEST:
|
2006-04-04 20:57:13 +00:00
|
|
|
result = OnIMERequest(wParam, lParam, aRetValue);
|
2005-10-13 15:07:56 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_IME_SELECT:
|
|
|
|
result = OnIMESelect(wParam, (WORD)(lParam & 0x0FFFF));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_IME_SETCONTEXT:
|
|
|
|
result = OnIMESetContext(wParam, lParam);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_DROPFILES:
|
|
|
|
{
|
2001-06-20 05:48:45 +00:00
|
|
|
#if 0
|
2004-09-03 08:44:23 +00:00
|
|
|
HDROP hDropInfo = (HDROP) wParam;
|
|
|
|
UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);
|
1999-03-09 23:48:58 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
for (UINT iFile = 0; iFile < nFiles; iFile++) {
|
|
|
|
TCHAR szFileName[_MAX_PATH];
|
|
|
|
::DragQueryFile(hDropInfo, iFile, szFileName, _MAX_PATH);
|
2001-06-20 05:48:45 +00:00
|
|
|
#ifdef DEBUG
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("szFileName [%s]\n", szFileName);
|
2005-06-29 18:52:08 +00:00
|
|
|
#endif // DEBUG
|
2004-09-03 08:44:23 +00:00
|
|
|
nsAutoString fileStr(szFileName);
|
|
|
|
nsEventStatus status;
|
|
|
|
nsDragDropEvent event(NS_DRAGDROP_EVENT, this);
|
|
|
|
InitEvent(event);
|
|
|
|
event.mType = nsDragDropEventStatus_eDrop;
|
|
|
|
event.mIsFileURL = PR_FALSE;
|
|
|
|
event.mURL = fileStr.get();
|
|
|
|
DispatchEvent(&event, status);
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
}
|
2005-06-29 18:52:08 +00:00
|
|
|
#endif // 0
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
break;
|
2005-06-29 18:52:08 +00:00
|
|
|
#endif // WINCE
|
1999-03-23 21:26:20 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_DESTROYCLIPBOARD:
|
|
|
|
{
|
|
|
|
nsIClipboard* clipboard;
|
2004-11-07 23:59:35 +00:00
|
|
|
nsresult rv = CallGetService(kCClipboardCID, &clipboard);
|
2004-09-03 08:44:23 +00:00
|
|
|
clipboard->EmptyClipboard(nsIClipboard::kGlobalClipboard);
|
2004-11-07 23:59:35 +00:00
|
|
|
NS_RELEASE(clipboard);
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
break;
|
1999-03-23 21:26:20 +00:00
|
|
|
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_GETOBJECT:
|
|
|
|
{
|
2007-06-14 17:12:50 +00:00
|
|
|
*aRetValue = 0;
|
2005-10-20 02:35:46 +00:00
|
|
|
if (lParam == OBJID_CLIENT) { // oleacc.dll will be loaded dynamically
|
2006-04-18 19:08:34 +00:00
|
|
|
nsCOMPtr<nsIAccessible> rootAccessible = GetRootAccessible(); // Held by a11y cache
|
2005-10-20 02:35:46 +00:00
|
|
|
if (rootAccessible) {
|
2007-06-14 17:12:50 +00:00
|
|
|
IAccessible *msaaAccessible = NULL;
|
2005-07-15 02:35:19 +00:00
|
|
|
rootAccessible->GetNativeInterface((void**)&msaaAccessible); // does an addref
|
2007-06-14 17:12:50 +00:00
|
|
|
if (msaaAccessible) {
|
|
|
|
*aRetValue = LresultFromObject(IID_IAccessible, wParam, msaaAccessible); // does an addref
|
|
|
|
msaaAccessible->Release(); // release extra addref
|
|
|
|
result = PR_TRUE; // We handled the WM_GETOBJECT message
|
2002-06-25 22:54:23 +00:00
|
|
|
}
|
|
|
|
}
|
2005-10-20 02:35:46 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
#endif
|
2004-04-01 22:51:46 +00:00
|
|
|
|
2005-02-23 07:07:51 +00:00
|
|
|
#ifndef WINCE
|
2004-09-03 08:44:23 +00:00
|
|
|
case WM_SYSCOMMAND:
|
|
|
|
// prevent Windows from trimming the working set. bug 76831
|
|
|
|
if (!gTrimOnMinimize && wParam == SC_MINIMIZE) {
|
|
|
|
::ShowWindow(mWnd, SW_SHOWMINIMIZED);
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2005-02-23 07:07:51 +00:00
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2006-04-17 17:42:20 +00:00
|
|
|
|
|
|
|
#ifdef WINCE
|
|
|
|
case WM_HIBERNATE:
|
|
|
|
nsMemory::HeapMinimize(PR_TRUE);
|
|
|
|
break;
|
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
// Handle both flavors of mouse wheel events.
|
2005-02-23 07:07:51 +00:00
|
|
|
#ifndef WINCE
|
2006-09-08 06:04:44 +00:00
|
|
|
if (msg == WM_MOUSEWHEEL || msg == WM_MOUSEHWHEEL) {
|
|
|
|
static int iDeltaPerLine, iDeltaPerChar;
|
|
|
|
static ULONG ulScrollLines, ulScrollChars = 1;
|
|
|
|
static int currentVDelta, currentHDelta;
|
|
|
|
static HWND currentWindow = 0;
|
|
|
|
|
|
|
|
PRBool isVertical = msg == WM_MOUSEWHEEL;
|
2004-09-03 08:44:23 +00:00
|
|
|
|
|
|
|
// Get mouse wheel metrics (but only once).
|
|
|
|
if (getWheelInfo) {
|
|
|
|
getWheelInfo = PR_FALSE;
|
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
SystemParametersInfo (SPI_GETWHEELSCROLLLINES, 0, &ulScrollLines, 0);
|
2002-04-29 14:50:58 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// ulScrollLines usually equals 3 or 0 (for no scrolling)
|
|
|
|
// WHEEL_DELTA equals 120, so iDeltaPerLine will be 40.
|
|
|
|
|
|
|
|
// However, if ulScrollLines > WHEEL_DELTA, we assume that
|
|
|
|
// the mouse driver wants a page scroll. The docs state that
|
|
|
|
// ulScrollLines should explicitly equal WHEEL_PAGESCROLL, but
|
|
|
|
// since some mouse drivers use an arbitrary large number instead,
|
|
|
|
// we have to handle that as well.
|
|
|
|
|
|
|
|
iDeltaPerLine = 0;
|
|
|
|
if (ulScrollLines) {
|
|
|
|
if (ulScrollLines <= WHEEL_DELTA) {
|
|
|
|
iDeltaPerLine = WHEEL_DELTA / ulScrollLines;
|
|
|
|
} else {
|
|
|
|
ulScrollLines = WHEEL_PAGESCROLL;
|
|
|
|
}
|
2002-04-29 14:50:58 +00:00
|
|
|
}
|
2006-09-08 06:04:44 +00:00
|
|
|
|
|
|
|
if (!SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0,
|
|
|
|
&ulScrollChars, 0)) {
|
|
|
|
// Note that we may always fail to get the value before Win Vista.
|
|
|
|
ulScrollChars = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
iDeltaPerChar = 0;
|
|
|
|
if (ulScrollChars) {
|
|
|
|
if (ulScrollChars <= WHEEL_DELTA) {
|
|
|
|
iDeltaPerChar = WHEEL_DELTA / ulScrollChars;
|
|
|
|
} else {
|
|
|
|
ulScrollChars = WHEEL_PAGESCROLL;
|
|
|
|
}
|
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
|
2006-09-08 06:04:44 +00:00
|
|
|
if ((isVertical && ulScrollLines != WHEEL_PAGESCROLL && !iDeltaPerLine) ||
|
|
|
|
(!isVertical && ulScrollChars != WHEEL_PAGESCROLL && !iDeltaPerChar))
|
2004-09-03 08:44:23 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
// The mousewheel event will be dispatched to the toplevel
|
|
|
|
// window. We need to give it to the child window
|
|
|
|
|
|
|
|
POINT point;
|
|
|
|
point.x = GET_X_LPARAM(lParam);
|
|
|
|
point.y = GET_Y_LPARAM(lParam);
|
|
|
|
HWND destWnd = ::WindowFromPoint(point);
|
|
|
|
|
|
|
|
// Since we receive mousewheel events for as long as
|
|
|
|
// we are focused, it's entirely possible that there
|
|
|
|
// is another app's window or no window under the
|
|
|
|
// pointer.
|
|
|
|
|
|
|
|
if (!destWnd) {
|
|
|
|
// No window is under the pointer
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We don't care about windows belonging to other processes.
|
|
|
|
DWORD processId = 0;
|
|
|
|
GetWindowThreadProcessId(destWnd, &processId);
|
|
|
|
if (processId != GetCurrentProcessId())
|
|
|
|
{
|
|
|
|
// Somebody elses window
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
LONG proc = ::GetWindowLongW(destWnd, GWL_WNDPROC);
|
2004-09-03 08:44:23 +00:00
|
|
|
if (proc != (LONG)&nsWindow::WindowProc) {
|
|
|
|
// Some other app, or a plugin window.
|
|
|
|
// Windows directs WM_MOUSEWHEEL to the focused window.
|
|
|
|
// However, Mozilla does not like plugins having focus, so a
|
|
|
|
// Mozilla window (ie, the plugin's parent (us!) has focus.)
|
|
|
|
// Therefore, plugins etc _should_ get first grab at the
|
|
|
|
// message, but this focus vaguary means the plugin misses
|
|
|
|
// out. If the window is a child of ours, forward it on.
|
|
|
|
// Determine if a child by walking the parent list until
|
|
|
|
// we find a parent matching our wndproc.
|
|
|
|
HWND parentWnd = ::GetParent(destWnd);
|
|
|
|
while (parentWnd) {
|
2006-05-02 06:17:55 +00:00
|
|
|
LONG parentWndProc = ::GetClassLongW(parentWnd, GCL_WNDPROC);
|
2004-09-03 08:44:23 +00:00
|
|
|
if (parentWndProc == (LONG)&nsWindow::DefaultWindowProc || parentWndProc == (LONG)&nsWindow::WindowProc) {
|
|
|
|
// We have a child window - quite possibly a plugin window.
|
|
|
|
// However, not all plugins are created equal - some will handle this message themselves,
|
|
|
|
// some will forward directly back to us, while others will call DefWndProc, which
|
|
|
|
// itself still forwards back to us.
|
|
|
|
// So if we have sent it once, we need to handle it ourself.
|
|
|
|
if (mIsInMouseWheelProcessing) {
|
|
|
|
destWnd = parentWnd;
|
|
|
|
} else {
|
|
|
|
// First time we have seen this message.
|
|
|
|
// Call the child - either it will consume it, or
|
|
|
|
// it will wind it's way back to us, triggering the destWnd case above.
|
|
|
|
// either way, when the call returns, we are all done with the message,
|
|
|
|
mIsInMouseWheelProcessing = PR_TRUE;
|
2006-04-04 20:57:13 +00:00
|
|
|
if (0 == ::SendMessageW(destWnd, msg, wParam, lParam)) {
|
2004-09-03 08:44:23 +00:00
|
|
|
result = PR_TRUE; // consumed - don't call DefWndProc
|
2001-09-29 00:05:58 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
destWnd = nsnull;
|
|
|
|
mIsInMouseWheelProcessing = PR_FALSE;
|
2001-09-29 00:05:58 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
break; // stop parent search
|
2000-03-18 00:57:23 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
parentWnd = ::GetParent(parentWnd);
|
|
|
|
} // while parentWnd
|
|
|
|
}
|
|
|
|
if (destWnd == nsnull)
|
|
|
|
break; // done with this message.
|
|
|
|
if (destWnd != mWnd) {
|
|
|
|
nsWindow* destWindow = GetNSWindowPtr(destWnd);
|
|
|
|
if (destWindow) {
|
|
|
|
return destWindow->ProcessMessage(msg, wParam, lParam, aRetValue);
|
2000-11-02 05:15:34 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
else
|
|
|
|
printf("WARNING: couldn't get child window for MW event\n");
|
|
|
|
#endif
|
2000-08-04 21:43:29 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2006-09-08 06:04:44 +00:00
|
|
|
// We should cancel the surplus delta if the current window is not
|
|
|
|
// same as previous.
|
|
|
|
if (currentWindow != mWnd) {
|
|
|
|
currentVDelta = 0;
|
|
|
|
currentHDelta = 0;
|
|
|
|
currentWindow = mWnd;
|
|
|
|
}
|
|
|
|
|
2005-04-28 23:48:28 +00:00
|
|
|
nsMouseScrollEvent scrollEvent(PR_TRUE, NS_MOUSE_SCROLL, this);
|
2006-09-08 06:04:44 +00:00
|
|
|
scrollEvent.delta = 0;
|
|
|
|
if (isVertical) {
|
|
|
|
scrollEvent.scrollFlags = nsMouseScrollEvent::kIsVertical;
|
|
|
|
if (ulScrollLines == WHEEL_PAGESCROLL) {
|
|
|
|
scrollEvent.scrollFlags |= nsMouseScrollEvent::kIsFullPage;
|
|
|
|
scrollEvent.delta = (((short) HIWORD (wParam)) > 0) ? -1 : 1;
|
|
|
|
} else {
|
|
|
|
currentVDelta -= (short) HIWORD (wParam);
|
|
|
|
if (PR_ABS(currentVDelta) >= iDeltaPerLine) {
|
|
|
|
scrollEvent.delta = currentVDelta / iDeltaPerLine;
|
|
|
|
currentVDelta %= iDeltaPerLine;
|
|
|
|
}
|
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
} else {
|
2006-09-08 06:04:44 +00:00
|
|
|
scrollEvent.scrollFlags = nsMouseScrollEvent::kIsHorizontal;
|
|
|
|
if (ulScrollChars == WHEEL_PAGESCROLL) {
|
|
|
|
scrollEvent.scrollFlags |= nsMouseScrollEvent::kIsFullPage;
|
|
|
|
scrollEvent.delta = (((short) HIWORD (wParam)) > 0) ? 1 : -1;
|
|
|
|
} else {
|
|
|
|
currentHDelta += (short) HIWORD (wParam);
|
|
|
|
if (PR_ABS(currentHDelta) >= iDeltaPerChar) {
|
|
|
|
scrollEvent.delta = currentHDelta / iDeltaPerChar;
|
|
|
|
currentHDelta %= iDeltaPerChar;
|
|
|
|
}
|
|
|
|
}
|
2002-02-27 02:18:12 +00:00
|
|
|
}
|
2000-08-04 21:43:29 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
scrollEvent.isShift = IS_VK_DOWN(NS_VK_SHIFT);
|
|
|
|
scrollEvent.isControl = IS_VK_DOWN(NS_VK_CONTROL);
|
|
|
|
scrollEvent.isMeta = PR_FALSE;
|
|
|
|
scrollEvent.isAlt = IS_VK_DOWN(NS_VK_ALT);
|
|
|
|
InitEvent(scrollEvent);
|
|
|
|
if (nsnull != mEventCallback) {
|
|
|
|
result = DispatchWindowEvent(&scrollEvent);
|
|
|
|
}
|
|
|
|
NS_RELEASE(scrollEvent.widget);
|
2006-09-08 06:04:44 +00:00
|
|
|
// Note that we should return zero if we process WM_MOUSEWHEEL.
|
|
|
|
// But if we process WM_MOUSEHWHEEL, we should return non-zero.
|
|
|
|
if (result)
|
|
|
|
*aRetValue = isVertical ? 0 : TRUE;
|
|
|
|
} // msg == WM_MOUSEWHEEL || msg == WM_MOUSEHWHEEL
|
2004-09-03 08:44:23 +00:00
|
|
|
|
|
|
|
else if (msg == nsWindow::uWM_HEAP_DUMP) {
|
|
|
|
// XXX for now we use c:\heapdump.txt until we figure out how to
|
|
|
|
// XXX pass in message parameters.
|
|
|
|
HeapDump("c:\\heapdump.txt", "whatever");
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
2005-02-23 07:07:51 +00:00
|
|
|
#endif // WINCE
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-07-12 22:28:19 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*aRetValue = result;
|
|
|
|
if (mWnd) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//Events which caused mWnd destruction and aren't consumed
|
|
|
|
//will crash during the Windows default processing.
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// return the window class name and initialize the class if needed
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2002-01-05 23:50:52 +00:00
|
|
|
|
|
|
|
#define CS_XP_DROPSHADOW 0x00020000
|
|
|
|
|
2002-07-03 00:55:47 +00:00
|
|
|
LPCWSTR nsWindow::WindowClassW()
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
if (!nsWindow::sIsRegistered) {
|
|
|
|
WNDCLASSW wc;
|
|
|
|
|
|
|
|
// wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
|
2006-04-18 18:31:26 +00:00
|
|
|
wc.style = CS_DBLCLKS;
|
2004-09-03 08:44:23 +00:00
|
|
|
wc.lpfnWndProc = nsWindow::DefaultWindowProc;
|
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
wc.cbWndExtra = 0;
|
|
|
|
wc.hInstance = nsToolkit::mDllInstance;
|
2005-04-13 12:46:10 +00:00
|
|
|
// XXX : we don't need LoadIconW for now (see bug 171349, comment 181)
|
|
|
|
wc.hIcon = ::LoadIcon(::GetModuleHandle(NULL), IDI_APPLICATION);
|
2004-09-03 08:44:23 +00:00
|
|
|
wc.hCursor = NULL;
|
|
|
|
wc.hbrBackground = mBrush;
|
|
|
|
wc.lpszMenuName = NULL;
|
|
|
|
wc.lpszClassName = kWClassNameHidden;
|
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
BOOL succeeded = ::RegisterClassW(&wc) != 0;
|
2004-09-03 08:44:23 +00:00
|
|
|
nsWindow::sIsRegistered = succeeded;
|
|
|
|
|
2005-02-18 14:24:43 +00:00
|
|
|
wc.lpszClassName = kWClassNameContentFrame;
|
2006-04-04 20:57:13 +00:00
|
|
|
if (!::RegisterClassW(&wc)) {
|
2005-02-18 14:24:43 +00:00
|
|
|
nsWindow::sIsRegistered = FALSE;
|
|
|
|
}
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
wc.lpszClassName = kWClassNameContent;
|
2006-04-04 20:57:13 +00:00
|
|
|
if (!::RegisterClassW(&wc)) {
|
2004-09-03 08:44:23 +00:00
|
|
|
nsWindow::sIsRegistered = FALSE;
|
2004-05-04 12:39:42 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2005-03-02 08:03:13 +00:00
|
|
|
wc.lpszClassName = kWClassNameUI;
|
2006-04-04 20:57:13 +00:00
|
|
|
if (!::RegisterClassW(&wc)) {
|
2004-09-03 08:44:23 +00:00
|
|
|
nsWindow::sIsRegistered = FALSE;
|
2004-05-04 12:39:42 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2005-03-02 08:03:13 +00:00
|
|
|
wc.lpszClassName = kWClassNameGeneral;
|
2006-04-04 20:57:13 +00:00
|
|
|
ATOM generalClassAtom = ::RegisterClassW(&wc);
|
2005-03-02 08:03:13 +00:00
|
|
|
if (!generalClassAtom) {
|
2004-09-03 08:44:23 +00:00
|
|
|
nsWindow::sIsRegistered = FALSE;
|
2004-05-04 12:39:42 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2006-11-15 12:05:56 +00:00
|
|
|
wc.lpszClassName = kWClassNameDialog;
|
|
|
|
wc.hIcon = 0;
|
|
|
|
if (!::RegisterClassW(&wc)) {
|
|
|
|
nsWindow::sIsRegistered = FALSE;
|
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mWindowType == eWindowType_invisible) {
|
|
|
|
return kWClassNameHidden;
|
|
|
|
}
|
2006-11-15 12:05:56 +00:00
|
|
|
if (mWindowType == eWindowType_dialog) {
|
|
|
|
return kWClassNameDialog;
|
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
if (mContentType == eContentTypeContent) {
|
|
|
|
return kWClassNameContent;
|
|
|
|
}
|
2005-02-18 14:24:43 +00:00
|
|
|
if (mContentType == eContentTypeContentFrame) {
|
|
|
|
return kWClassNameContentFrame;
|
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
if (mContentType == eContentTypeUI) {
|
|
|
|
return kWClassNameUI;
|
|
|
|
}
|
|
|
|
return kWClassNameGeneral;
|
2002-07-03 00:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LPCWSTR nsWindow::WindowPopupClassW()
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
const LPCWSTR className = L"MozillaDropShadowWindowClass";
|
|
|
|
|
|
|
|
if (!nsWindow::sIsPopupClassRegistered) {
|
|
|
|
WNDCLASSW wc;
|
2006-04-17 17:42:20 +00:00
|
|
|
|
|
|
|
wc.style = CS_DBLCLKS | CS_XP_DROPSHADOW;
|
2004-09-03 08:44:23 +00:00
|
|
|
wc.lpfnWndProc = nsWindow::DefaultWindowProc;
|
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
wc.cbWndExtra = 0;
|
|
|
|
wc.hInstance = nsToolkit::mDllInstance;
|
2005-04-13 12:46:10 +00:00
|
|
|
// XXX : we don't need LoadIconW for now (see bug 171349, comment 181)
|
|
|
|
wc.hIcon = ::LoadIcon(::GetModuleHandle(NULL), IDI_APPLICATION);
|
2004-09-03 08:44:23 +00:00
|
|
|
wc.hCursor = NULL;
|
|
|
|
wc.hbrBackground = mBrush;
|
|
|
|
wc.lpszMenuName = NULL;
|
|
|
|
wc.lpszClassName = className;
|
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
nsWindow::sIsPopupClassRegistered = ::RegisterClassW(&wc);
|
2002-07-03 00:55:47 +00:00
|
|
|
if (!nsWindow::sIsPopupClassRegistered) {
|
2004-09-03 08:44:23 +00:00
|
|
|
// For older versions of Win32 (i.e., not XP), the registration will
|
|
|
|
// fail, so we have to re-register without the CS_XP_DROPSHADOW flag.
|
|
|
|
wc.style = CS_DBLCLKS;
|
2006-04-04 20:57:13 +00:00
|
|
|
nsWindow::sIsPopupClassRegistered = ::RegisterClassW(&wc);
|
2002-07-03 00:55:47 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
2002-07-03 00:55:47 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
return className;
|
2002-07-03 00:55:47 +00:00
|
|
|
}
|
|
|
|
|
2005-02-23 07:07:51 +00:00
|
|
|
LPCSTR nsWindow::WindowClass()
|
2002-07-29 21:44:53 +00:00
|
|
|
{
|
2003-04-28 10:24:52 +00:00
|
|
|
// Call into the wide version to make sure things get
|
|
|
|
// registered properly.
|
2004-05-04 12:39:42 +00:00
|
|
|
LPCWSTR classNameW = WindowClassW();
|
2003-04-28 10:24:52 +00:00
|
|
|
|
|
|
|
// XXX: The class name used here must be kept in sync with
|
|
|
|
// the classname used in WindowClassW();
|
2004-05-04 12:39:42 +00:00
|
|
|
|
|
|
|
if (classNameW == kWClassNameHidden) {
|
|
|
|
return kClassNameHidden;
|
|
|
|
}
|
2006-11-15 12:05:56 +00:00
|
|
|
if (classNameW == kWClassNameDialog) {
|
|
|
|
return kClassNameDialog;
|
|
|
|
}
|
2004-05-04 12:39:42 +00:00
|
|
|
if (classNameW == kWClassNameUI) {
|
|
|
|
return kClassNameUI;
|
|
|
|
}
|
|
|
|
if (classNameW == kWClassNameContent) {
|
|
|
|
return kClassNameContent;
|
|
|
|
}
|
2005-02-18 14:24:43 +00:00
|
|
|
if (classNameW == kWClassNameContentFrame) {
|
|
|
|
return kClassNameContentFrame;
|
|
|
|
}
|
2004-05-04 12:39:42 +00:00
|
|
|
return kClassNameGeneral;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2005-02-23 07:07:51 +00:00
|
|
|
LPCSTR nsWindow::WindowPopupClass()
|
2002-01-05 23:50:52 +00:00
|
|
|
{
|
2003-04-28 10:24:52 +00:00
|
|
|
// Call into the wide version to make sure things get
|
|
|
|
// registered properly.
|
|
|
|
WindowPopupClassW();
|
|
|
|
|
|
|
|
// XXX: The class name used here must be kept in sync with
|
|
|
|
// the classname used in WindowPopupClassW();
|
|
|
|
return "MozillaDropShadowWindowClass";
|
2002-01-05 23:50:52 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// return nsWindow styles
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
DWORD nsWindow::WindowStyle()
|
|
|
|
{
|
2005-06-08 16:48:44 +00:00
|
|
|
DWORD style;
|
|
|
|
|
2005-02-23 07:07:51 +00:00
|
|
|
#ifdef WINCE
|
2005-07-18 16:04:45 +00:00
|
|
|
switch (mWindowType) {
|
|
|
|
case eWindowType_child:
|
2005-08-22 15:17:53 +00:00
|
|
|
style = WS_CHILD;
|
2005-07-18 16:04:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eWindowType_dialog:
|
2005-08-16 19:15:06 +00:00
|
|
|
case eWindowType_popup:
|
2005-08-22 15:17:53 +00:00
|
|
|
style = WS_BORDER | WS_POPUP;
|
|
|
|
break;
|
2005-07-18 16:04:45 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
NS_ASSERTION(0, "unknown border style");
|
|
|
|
// fall through
|
|
|
|
|
|
|
|
case eWindowType_toplevel:
|
|
|
|
case eWindowType_invisible:
|
|
|
|
style = WS_BORDER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-02-23 07:07:51 +00:00
|
|
|
#else
|
2004-09-03 08:44:23 +00:00
|
|
|
switch (mWindowType) {
|
2000-03-21 03:42:00 +00:00
|
|
|
case eWindowType_child:
|
|
|
|
style = WS_OVERLAPPED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eWindowType_dialog:
|
|
|
|
if (mBorderStyle == eBorderStyle_default) {
|
|
|
|
style = WS_OVERLAPPED | WS_BORDER | WS_DLGFRAME | WS_SYSMENU |
|
|
|
|
DS_3DLOOK | DS_MODALFRAME;
|
|
|
|
} else {
|
|
|
|
style = WS_OVERLAPPED | WS_BORDER | WS_DLGFRAME | WS_SYSMENU |
|
|
|
|
DS_3DLOOK | DS_MODALFRAME |
|
|
|
|
WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eWindowType_popup:
|
|
|
|
style = WS_OVERLAPPED | WS_POPUP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
NS_ASSERTION(0, "unknown border style");
|
|
|
|
// fall through
|
|
|
|
|
|
|
|
case eWindowType_toplevel:
|
2003-07-25 14:54:39 +00:00
|
|
|
case eWindowType_invisible:
|
2000-03-21 03:42:00 +00:00
|
|
|
style = WS_OVERLAPPED | WS_BORDER | WS_DLGFRAME | WS_SYSMENU |
|
|
|
|
WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mBorderStyle != eBorderStyle_default && mBorderStyle != eBorderStyle_all) {
|
|
|
|
if (mBorderStyle == eBorderStyle_none || !(mBorderStyle & eBorderStyle_border))
|
|
|
|
style &= ~WS_BORDER;
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2000-03-21 03:42:00 +00:00
|
|
|
if (mBorderStyle == eBorderStyle_none || !(mBorderStyle & eBorderStyle_title)) {
|
|
|
|
style &= ~WS_DLGFRAME;
|
|
|
|
style |= WS_POPUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mBorderStyle == eBorderStyle_none || !(mBorderStyle & eBorderStyle_close))
|
|
|
|
style &= ~0;
|
|
|
|
// XXX The close box can only be removed by changing the window class,
|
|
|
|
// as far as I know --- roc+moz@cs.cmu.edu
|
|
|
|
|
|
|
|
if (mBorderStyle == eBorderStyle_none ||
|
|
|
|
!(mBorderStyle & (eBorderStyle_menu | eBorderStyle_close)))
|
|
|
|
style &= ~WS_SYSMENU;
|
|
|
|
// Looks like getting rid of the system menu also does away with the
|
|
|
|
// close box. So, we only get rid of the system menu if you want neither it
|
|
|
|
// nor the close box. How does the Windows "Dialog" window class get just
|
|
|
|
// closebox and no sysmenu? Who knows.
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2000-03-21 03:42:00 +00:00
|
|
|
if (mBorderStyle == eBorderStyle_none || !(mBorderStyle & eBorderStyle_resizeh))
|
|
|
|
style &= ~WS_THICKFRAME;
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2000-03-21 03:42:00 +00:00
|
|
|
if (mBorderStyle == eBorderStyle_none || !(mBorderStyle & eBorderStyle_minimize))
|
|
|
|
style &= ~WS_MINIMIZEBOX;
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2000-03-21 03:42:00 +00:00
|
|
|
if (mBorderStyle == eBorderStyle_none || !(mBorderStyle & eBorderStyle_maximize))
|
|
|
|
style &= ~WS_MAXIMIZEBOX;
|
|
|
|
}
|
2005-06-29 18:52:08 +00:00
|
|
|
#endif // WINCE
|
2005-06-08 16:48:44 +00:00
|
|
|
return style;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// return nsWindow extended styles
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
DWORD nsWindow::WindowExStyle()
|
|
|
|
{
|
2005-08-09 07:21:27 +00:00
|
|
|
switch (mWindowType)
|
|
|
|
{
|
|
|
|
case eWindowType_child:
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case eWindowType_dialog:
|
2006-11-15 12:05:56 +00:00
|
|
|
return WS_EX_WINDOWEDGE | WS_EX_DLGMODALFRAME;
|
2005-08-09 07:21:27 +00:00
|
|
|
|
|
|
|
case eWindowType_popup:
|
2005-08-09 16:00:08 +00:00
|
|
|
return WS_EX_TOPMOST | WS_EX_TOOLWINDOW;
|
2005-08-09 07:21:27 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
NS_ASSERTION(0, "unknown border style");
|
|
|
|
// fall through
|
|
|
|
|
|
|
|
case eWindowType_toplevel:
|
|
|
|
case eWindowType_invisible:
|
2005-08-09 16:00:08 +00:00
|
|
|
return WS_EX_WINDOWEDGE;
|
2005-08-09 07:21:27 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Subclass (or remove the subclass from) this component's nsWindow
|
|
|
|
//
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void nsWindow::SubclassWindow(BOOL bState)
|
|
|
|
{
|
1998-09-15 03:45:06 +00:00
|
|
|
if (NULL != mWnd) {
|
1998-04-13 20:24:54 +00:00
|
|
|
NS_PRECONDITION(::IsWindow(mWnd), "Invalid window handle");
|
2004-09-03 08:44:23 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
if (bState) {
|
2004-09-03 08:44:23 +00:00
|
|
|
// change the nsWindow proc
|
|
|
|
if (mUnicodeWidget)
|
2006-04-04 20:57:13 +00:00
|
|
|
mPrevWndProc = (WNDPROC)::SetWindowLongW(mWnd, GWL_WNDPROC,
|
2004-09-03 08:44:23 +00:00
|
|
|
(LONG)nsWindow::WindowProc);
|
|
|
|
else
|
2006-04-04 20:57:13 +00:00
|
|
|
mPrevWndProc = (WNDPROC)::SetWindowLongA(mWnd, GWL_WNDPROC,
|
2004-09-03 08:44:23 +00:00
|
|
|
(LONG)nsWindow::WindowProc);
|
|
|
|
NS_ASSERTION(mPrevWndProc, "Null standard window procedure");
|
|
|
|
// connect the this pointer to the nsWindow handle
|
|
|
|
SetNSWindowPtr(mWnd, this);
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
else {
|
2004-09-03 08:44:23 +00:00
|
|
|
if (mUnicodeWidget)
|
2006-04-04 20:57:13 +00:00
|
|
|
::SetWindowLongW(mWnd, GWL_WNDPROC, (LONG)mPrevWndProc);
|
2004-09-03 08:44:23 +00:00
|
|
|
else
|
2006-04-04 20:57:13 +00:00
|
|
|
::SetWindowLongA(mWnd, GWL_WNDPROC, (LONG)mPrevWndProc);
|
2004-09-03 08:44:23 +00:00
|
|
|
SetNSWindowPtr(mWnd, NULL);
|
|
|
|
mPrevWndProc = NULL;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-09-15 03:45:06 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// WM_DESTROY has been called
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsWindow::OnDestroy()
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
mOnDestroyCalled = PR_TRUE;
|
1998-09-15 03:45:06 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
SubclassWindow(FALSE);
|
|
|
|
mWnd = NULL;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// free GDI objects
|
|
|
|
if (mBrush) {
|
|
|
|
VERIFY(::DeleteObject(mBrush));
|
|
|
|
mBrush = NULL;
|
|
|
|
}
|
2001-08-09 20:22:39 +00:00
|
|
|
|
|
|
|
#if 0
|
2004-09-03 08:44:23 +00:00
|
|
|
if (mPalette) {
|
|
|
|
VERIFY(::DeleteObject(mPalette));
|
|
|
|
mPalette = NULL;
|
|
|
|
}
|
2001-08-09 20:22:39 +00:00
|
|
|
#endif
|
1998-08-09 01:37:30 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// if we were in the middle of deferred window positioning then
|
|
|
|
// free the memory for the multiple-window position structure
|
|
|
|
if (mDeferredPositioner) {
|
|
|
|
VERIFY(::EndDeferWindowPos(mDeferredPositioner));
|
|
|
|
mDeferredPositioner = NULL;
|
|
|
|
}
|
1998-08-09 01:37:30 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// release references to children, device context, toolkit, and app shell
|
|
|
|
nsBaseWidget::OnDestroy();
|
|
|
|
|
|
|
|
// dispatch the event
|
|
|
|
if (!mIsDestroying) {
|
|
|
|
// dispatching of the event may cause the reference count to drop to 0
|
|
|
|
// and result in this object being destroyed. To avoid that, add a reference
|
|
|
|
// and then release it after dispatching the event
|
|
|
|
AddRef();
|
|
|
|
DispatchStandardEvent(NS_DESTROY);
|
|
|
|
Release();
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-05-29 22:44:13 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Move
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool nsWindow::OnMove(PRInt32 aX, PRInt32 aY)
|
2004-09-03 08:44:23 +00:00
|
|
|
{
|
2003-11-14 21:58:08 +00:00
|
|
|
mBounds.x = aX;
|
|
|
|
mBounds.y = aY;
|
|
|
|
|
2005-04-28 23:48:28 +00:00
|
|
|
nsGUIEvent event(PR_TRUE, NS_MOVE, this);
|
2004-01-12 08:25:18 +00:00
|
|
|
InitEvent(event);
|
2005-08-23 03:57:07 +00:00
|
|
|
event.refPoint.x = aX;
|
|
|
|
event.refPoint.y = aY;
|
1998-10-08 00:04:21 +00:00
|
|
|
|
|
|
|
PRBool result = DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
return result;
|
1998-05-29 22:44:13 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Paint
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2003-04-14 22:56:35 +00:00
|
|
|
PRBool nsWindow::OnPaint(HDC aDC)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
nsRect bounds;
|
|
|
|
PRBool result = PR_TRUE;
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
nsEventStatus eventStatus = nsEventStatus_eIgnore;
|
1998-12-15 05:44:21 +00:00
|
|
|
|
2005-12-19 03:00:41 +00:00
|
|
|
#ifdef MOZ_XUL
|
2006-04-04 20:57:13 +00:00
|
|
|
if (!aDC && mIsTranslucent)
|
2005-12-29 22:30:22 +00:00
|
|
|
{
|
|
|
|
// For layered translucent windows all drawing should go to memory DC and no
|
2006-06-16 02:27:37 +00:00
|
|
|
// WM_PAINT messages are normally generated. To support asynchronous painting
|
|
|
|
// we force generation of WM_PAINT messages by invalidating window areas with
|
|
|
|
// RedrawWindow, InvalidateRect or InvalidateRgn function calls.
|
|
|
|
// BeginPaint/EndPaint must be called to make Windows think that invalid area
|
|
|
|
// is painted. Otherwise it will continue sending the same message endlessly.
|
2005-12-29 22:30:22 +00:00
|
|
|
::BeginPaint(mWnd, &ps);
|
|
|
|
::EndPaint(mWnd, &ps);
|
2006-06-16 02:27:37 +00:00
|
|
|
|
|
|
|
aDC = mMemoryDC;
|
2005-12-29 22:30:22 +00:00
|
|
|
}
|
2005-12-19 03:00:41 +00:00
|
|
|
#endif
|
|
|
|
|
2005-04-21 20:53:00 +00:00
|
|
|
mPainting = PR_TRUE;
|
|
|
|
|
1999-09-09 03:47:26 +00:00
|
|
|
#ifdef NS_DEBUG
|
2004-09-03 08:44:23 +00:00
|
|
|
HRGN debugPaintFlashRegion = NULL;
|
|
|
|
HDC debugPaintFlashDC = NULL;
|
1998-12-15 05:44:21 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (debug_WantPaintFlashing())
|
|
|
|
{
|
|
|
|
debugPaintFlashRegion = ::CreateRectRgn(0, 0, 0, 0);
|
|
|
|
::GetUpdateRgn(mWnd, debugPaintFlashRegion, TRUE);
|
|
|
|
debugPaintFlashDC = ::GetDC(mWnd);
|
|
|
|
}
|
1999-09-09 03:47:26 +00:00
|
|
|
#endif // NS_DEBUG
|
1998-12-15 05:44:21 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
HDC hDC = aDC ? aDC : (::BeginPaint(mWnd, &ps));
|
2006-01-31 01:04:41 +00:00
|
|
|
mPaintDC = hDC;
|
2004-09-03 08:44:23 +00:00
|
|
|
RECT paintRect;
|
2004-12-09 17:56:46 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_XUL
|
|
|
|
if (aDC || mIsTranslucent) {
|
|
|
|
#else
|
2004-09-03 08:44:23 +00:00
|
|
|
if (aDC) {
|
2004-12-09 17:56:46 +00:00
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
::GetClientRect(mWnd, &paintRect);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
paintRect = ps.rcPaint;
|
|
|
|
}
|
1999-09-09 03:47:26 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (!IsRectEmpty(&paintRect))
|
|
|
|
{
|
|
|
|
// call the event callback
|
|
|
|
if (mEventCallback)
|
|
|
|
{
|
2005-04-28 23:48:28 +00:00
|
|
|
nsPaintEvent event(PR_TRUE, NS_PAINT, this);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
InitEvent(event);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
nsRect rect(paintRect.left,
|
|
|
|
paintRect.top,
|
|
|
|
paintRect.right - paintRect.left,
|
|
|
|
paintRect.bottom - paintRect.top);
|
|
|
|
event.region = nsnull;
|
|
|
|
event.rect = ▭
|
|
|
|
// Should probably pass in a real region here, using GetRandomRgn
|
|
|
|
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/clipping_4q0e.asp
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-09-09 03:47:26 +00:00
|
|
|
#ifdef NS_DEBUG
|
2004-09-03 08:44:23 +00:00
|
|
|
debug_DumpPaintEvent(stdout,
|
|
|
|
this,
|
|
|
|
&event,
|
|
|
|
nsCAutoString("noname"),
|
|
|
|
(PRInt32) mWnd);
|
1999-09-09 03:47:26 +00:00
|
|
|
#endif // NS_DEBUG
|
1998-12-15 05:44:21 +00:00
|
|
|
|
2005-10-06 04:02:10 +00:00
|
|
|
#ifdef MOZ_CAIRO_GFX
|
2007-04-02 18:53:43 +00:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
nsRefPtr<gfxASurface> targetSurface;
|
|
|
|
if (mIsTranslucent) {
|
|
|
|
targetSurface = mTranslucentSurface;
|
|
|
|
} else {
|
|
|
|
targetSurface = new gfxWindowsSurface(hDC);
|
|
|
|
}
|
|
|
|
#else
|
2006-02-15 23:35:53 +00:00
|
|
|
nsRefPtr<gfxASurface> targetSurface = new gfxWindowsSurface(hDC);
|
2007-04-02 18:53:43 +00:00
|
|
|
#endif
|
|
|
|
|
2006-02-15 23:35:53 +00:00
|
|
|
nsRefPtr<gfxContext> thebesContext = new gfxContext(targetSurface);
|
|
|
|
|
|
|
|
#ifdef MOZ_XUL
|
2006-04-04 20:57:13 +00:00
|
|
|
if (mIsTranslucent) {
|
2006-02-15 23:35:53 +00:00
|
|
|
// If we're rendering with translucency, we're going to be
|
|
|
|
// rendering the whole window; make sure we clear it first
|
|
|
|
thebesContext->SetOperator(gfxContext::OPERATOR_CLEAR);
|
|
|
|
thebesContext->Paint();
|
|
|
|
thebesContext->SetOperator(gfxContext::OPERATOR_OVER);
|
|
|
|
} else {
|
|
|
|
// If we're not doing translucency, then double buffer
|
2006-08-09 20:25:07 +00:00
|
|
|
thebesContext->PushGroup(gfxASurface::CONTENT_COLOR);
|
2006-02-15 23:35:53 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsCOMPtr<nsIRenderingContext> rc;
|
|
|
|
nsresult rv = mContext->CreateRenderingContextInstance (*getter_AddRefs(rc));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("CreateRenderingContextInstance failed");
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = rc->Init(mContext, thebesContext);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("RC::Init failed");
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2006-01-31 01:04:41 +00:00
|
|
|
event.renderingContext = rc;
|
|
|
|
result = DispatchWindowEvent(&event, eventStatus);
|
|
|
|
event.renderingContext = nsnull;
|
|
|
|
|
2006-02-15 23:35:53 +00:00
|
|
|
#ifdef MOZ_XUL
|
2006-04-04 20:57:13 +00:00
|
|
|
if (mIsTranslucent) {
|
2006-01-31 01:04:41 +00:00
|
|
|
// Data from offscreen drawing surface was copied to memory bitmap of transparent
|
|
|
|
// bitmap. Now it can be read from memory bitmap to apply alpha channel and after
|
|
|
|
// that displayed on the screen.
|
|
|
|
UpdateTranslucentWindow();
|
2006-02-22 22:56:01 +00:00
|
|
|
} else if (result) {
|
|
|
|
// Only update if DispatchWindowEvent returned TRUE; otherwise, nothing handled
|
|
|
|
// this, and we'll just end up painting with black.
|
2006-02-15 23:35:53 +00:00
|
|
|
thebesContext->PopGroupToSource();
|
|
|
|
thebesContext->SetOperator(gfxContext::OPERATOR_SOURCE);
|
|
|
|
thebesContext->Paint();
|
2006-01-31 01:04:41 +00:00
|
|
|
}
|
2006-02-15 23:35:53 +00:00
|
|
|
#endif
|
2006-01-31 01:04:41 +00:00
|
|
|
|
2006-02-15 23:35:53 +00:00
|
|
|
#else
|
|
|
|
/* Non-cairo GFX */
|
2006-01-31 01:04:41 +00:00
|
|
|
if (NS_SUCCEEDED(CallCreateInstance(kRenderingContextCID, &event.renderingContext)))
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
nsIRenderingContextWin *winrc;
|
2004-11-01 18:50:36 +00:00
|
|
|
if (NS_SUCCEEDED(CallQueryInterface(event.renderingContext, &winrc)))
|
2004-09-03 08:44:23 +00:00
|
|
|
{
|
|
|
|
nsIDrawingSurface* surf;
|
1998-12-15 05:44:21 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
//i know all of this seems a little backwards. i'll fix it, i swear. MMP
|
1998-12-15 05:44:21 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (NS_OK == winrc->CreateDrawingSurface(hDC, surf))
|
|
|
|
{
|
|
|
|
event.renderingContext->Init(mContext, surf);
|
|
|
|
result = DispatchWindowEvent(&event, eventStatus);
|
|
|
|
event.renderingContext->DestroyDrawingSurface(surf);
|
2004-07-27 19:14:44 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_XUL
|
2006-04-04 20:57:13 +00:00
|
|
|
if (mIsTranslucent)
|
2004-07-27 19:14:44 +00:00
|
|
|
{
|
|
|
|
// Data from offscreen drawing surface was copied to memory bitmap of transparent
|
|
|
|
// bitmap. Now it can be read from memory bitmap to apply alpha channel and after
|
|
|
|
// that displayed on the screen.
|
|
|
|
UpdateTranslucentWindow();
|
|
|
|
}
|
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
1998-12-15 05:44:21 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_RELEASE(winrc);
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_RELEASE(event.renderingContext);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
result = PR_FALSE;
|
2006-01-31 01:04:41 +00:00
|
|
|
#endif
|
1998-10-08 00:04:21 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_RELEASE(event.widget);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (!aDC) {
|
|
|
|
::EndPaint(mWnd, &ps);
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2006-01-31 01:04:41 +00:00
|
|
|
mPaintDC = nsnull;
|
|
|
|
|
1999-09-09 03:47:26 +00:00
|
|
|
#ifdef NS_DEBUG
|
2004-09-03 08:44:23 +00:00
|
|
|
if (debug_WantPaintFlashing())
|
|
|
|
{
|
|
|
|
// Only flash paint events which have not ignored the paint message.
|
|
|
|
// Those that ignore the paint message aren't painting anything so there
|
|
|
|
// is only the overhead of the dispatching the paint event.
|
|
|
|
if (nsEventStatus_eIgnore != eventStatus) {
|
|
|
|
::InvertRgn(debugPaintFlashDC, debugPaintFlashRegion);
|
|
|
|
PR_Sleep(PR_MillisecondsToInterval(30));
|
|
|
|
::InvertRgn(debugPaintFlashDC, debugPaintFlashRegion);
|
|
|
|
PR_Sleep(PR_MillisecondsToInterval(30));
|
1999-09-09 03:47:26 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
::ReleaseDC(mWnd, debugPaintFlashDC);
|
|
|
|
::DeleteObject(debugPaintFlashRegion);
|
|
|
|
}
|
1999-09-09 03:47:26 +00:00
|
|
|
#endif // NS_DEBUG
|
|
|
|
|
2005-04-21 20:53:00 +00:00
|
|
|
mPainting = PR_FALSE;
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
return result;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Send a resize message to the listener
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool nsWindow::OnResize(nsRect &aWindowRect)
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
// call the event callback
|
1998-10-07 22:11:37 +00:00
|
|
|
if (mEventCallback) {
|
2005-04-28 23:48:28 +00:00
|
|
|
nsSizeEvent event(PR_TRUE, NS_SIZE, this);
|
2004-01-12 08:25:18 +00:00
|
|
|
InitEvent(event);
|
1998-10-07 22:11:37 +00:00
|
|
|
event.windowSize = &aWindowRect;
|
1998-11-04 21:43:47 +00:00
|
|
|
RECT r;
|
|
|
|
if (::GetWindowRect(mWnd, &r)) {
|
|
|
|
event.mWinWidth = PRInt32(r.right - r.left);
|
|
|
|
event.mWinHeight = PRInt32(r.bottom - r.top);
|
|
|
|
} else {
|
|
|
|
event.mWinWidth = 0;
|
|
|
|
event.mWinHeight = 0;
|
|
|
|
}
|
1998-10-08 00:04:21 +00:00
|
|
|
PRBool result = DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
return result;
|
1998-10-07 22:11:37 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-10-07 22:11:37 +00:00
|
|
|
return PR_FALSE;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Deal with all sort of mouse event
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2006-11-16 21:35:39 +00:00
|
|
|
PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType, WPARAM wParam,
|
|
|
|
LPARAM lParam, PRBool aIsContextMenuKey,
|
|
|
|
PRInt16 aButton)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
|
|
|
|
if (nsnull == mEventCallback && nsnull == mMouseListener) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2005-12-02 12:08:32 +00:00
|
|
|
nsPoint eventPoint;
|
|
|
|
eventPoint.x = GET_X_LPARAM(lParam);
|
|
|
|
eventPoint.y = GET_Y_LPARAM(lParam);
|
|
|
|
|
2006-11-16 21:35:39 +00:00
|
|
|
nsMouseEvent event(PR_TRUE, aEventType, this, nsMouseEvent::eReal,
|
|
|
|
aIsContextMenuKey
|
|
|
|
? nsMouseEvent::eContextMenuKey
|
|
|
|
: nsMouseEvent::eNormal);
|
|
|
|
if (aEventType == NS_CONTEXTMENU && aIsContextMenuKey) {
|
2003-05-15 00:12:03 +00:00
|
|
|
nsPoint zero(0, 0);
|
2004-01-12 08:25:18 +00:00
|
|
|
InitEvent(event, &zero);
|
2003-05-15 00:12:03 +00:00
|
|
|
} else {
|
2005-12-02 12:08:32 +00:00
|
|
|
InitEvent(event, &eventPoint);
|
2003-05-15 00:12:03 +00:00
|
|
|
}
|
|
|
|
|
1999-02-03 22:36:34 +00:00
|
|
|
event.isShift = IS_VK_DOWN(NS_VK_SHIFT);
|
|
|
|
event.isControl = IS_VK_DOWN(NS_VK_CONTROL);
|
landing keyEvent_19991004_BRANCH
bugs # see the log of the check in into branch
author/reviewer:
mozilla/layout/base/src/nsRangeList.cpp brade/mjudge
mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp brade/ftang
mozilla/layout/events/src/nsDOMEvent.cpp brade/joki
mozilla/layout/events/src/nsEventStateManager.cpp brade/joki
mozilla/widget/public/nsGUIEvent.h akkana/ftang
mozilla/widget/src/windows/nsWindow.cpp ftang/mjudge
mozilla/widget/src/windows/nsWindow.h ftang/mjudge
mozilla/widget/src/mac/nsTextAreaWidget.cpp brade/ftang
mozilla/widget/src/mac/nsMacEventHandler.cpp brade/simon
mozilla/widget/src/xpwidgets/nsKeyBindMgr.cpp brade/ftang
mozilla/widget/src/gtk/nsGtkEventHandler.cpp akkana/?
mozilla/widget/src/gtk/nsWidget.cpp erik/ftang
mozilla/layout/xul/base/src/nsTreeCellFrame.cpp brade/ftang
mozilla/editor/base/nsEditorEventListeners.cpp brade/akkana
mozilla/editor/base/nsHTMLEditor.cpp brade/akkana
mozilla/rdf/content/src/nsXULKeyListener.cpp ftang/saari
fix the master bug- 15693
fix at least, but not limited to, the following bugs
10158,11956,6053,9333,10901,14348,6449,11845,13016,14410,15657,15307,15842,13856
1999-10-14 18:27:01 +00:00
|
|
|
event.isMeta = PR_FALSE;
|
1999-02-03 22:36:34 +00:00
|
|
|
event.isAlt = IS_VK_DOWN(NS_VK_ALT);
|
2006-11-16 21:35:39 +00:00
|
|
|
event.button = aButton;
|
1998-05-08 14:54:09 +00:00
|
|
|
|
2005-12-29 10:18:31 +00:00
|
|
|
nsRect mpWidget;
|
|
|
|
nsRect mpScreen;
|
|
|
|
mpWidget.x = eventPoint.x;
|
|
|
|
mpWidget.y = eventPoint.y;
|
|
|
|
WidgetToScreen(mpWidget, mpScreen);
|
2000-04-28 20:27:18 +00:00
|
|
|
|
2005-11-25 19:48:04 +00:00
|
|
|
// Suppress mouse moves caused by widget creation
|
2005-12-29 10:18:31 +00:00
|
|
|
if (aEventType == NS_MOUSE_MOVE)
|
2001-12-06 02:55:06 +00:00
|
|
|
{
|
2005-12-29 10:18:31 +00:00
|
|
|
if ((gLastMouseMovePoint.x == mpScreen.x) && (gLastMouseMovePoint.y == mpScreen.y))
|
|
|
|
{
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
gLastMouseMovePoint.x = mpScreen.x;
|
|
|
|
gLastMouseMovePoint.y = mpScreen.y;
|
2001-12-06 02:55:06 +00:00
|
|
|
}
|
|
|
|
|
2006-01-07 18:38:35 +00:00
|
|
|
PRBool insideMovementThreshold = (abs(gLastMousePoint.x - eventPoint.x) < (short)::GetSystemMetrics(SM_CXDOUBLECLK)) &&
|
|
|
|
(abs(gLastMousePoint.y - eventPoint.y) < (short)::GetSystemMetrics(SM_CYDOUBLECLK));
|
2005-12-29 10:18:31 +00:00
|
|
|
|
2004-07-09 21:39:16 +00:00
|
|
|
BYTE eventButton;
|
2006-11-16 21:35:39 +00:00
|
|
|
switch (aButton) {
|
|
|
|
case nsMouseEvent::eLeftButton:
|
2004-07-09 21:39:16 +00:00
|
|
|
eventButton = VK_LBUTTON;
|
|
|
|
break;
|
2006-11-16 21:35:39 +00:00
|
|
|
case nsMouseEvent::eMiddleButton:
|
2004-07-09 21:39:16 +00:00
|
|
|
eventButton = VK_MBUTTON;
|
|
|
|
break;
|
2006-11-16 21:35:39 +00:00
|
|
|
case nsMouseEvent::eRightButton:
|
2004-07-09 21:39:16 +00:00
|
|
|
eventButton = VK_RBUTTON;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
eventButton = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-12-29 10:18:31 +00:00
|
|
|
// Doubleclicks are used to set the click count, then changed to mousedowns
|
|
|
|
// We're going to time double-clicks from mouse *up* to next mouse *down*
|
|
|
|
LONG curMsgTime = ::GetMessageTime();
|
|
|
|
|
2006-11-16 21:35:39 +00:00
|
|
|
if (aEventType == NS_MOUSE_DOUBLECLICK) {
|
|
|
|
event.message = NS_MOUSE_BUTTON_DOWN;
|
|
|
|
event.button = aButton;
|
2001-02-23 00:40:19 +00:00
|
|
|
gLastClickCount = 2;
|
|
|
|
}
|
2006-11-16 21:35:39 +00:00
|
|
|
else if (aEventType == NS_MOUSE_BUTTON_UP) {
|
2000-04-28 20:27:18 +00:00
|
|
|
// remember when this happened for the next mouse down
|
2005-12-02 12:08:32 +00:00
|
|
|
gLastMousePoint.x = eventPoint.x;
|
|
|
|
gLastMousePoint.y = eventPoint.y;
|
2004-07-09 21:39:16 +00:00
|
|
|
gLastMouseButton = eventButton;
|
2001-02-23 00:40:19 +00:00
|
|
|
}
|
2006-11-16 21:35:39 +00:00
|
|
|
else if (aEventType == NS_MOUSE_BUTTON_DOWN) {
|
2000-04-28 20:27:18 +00:00
|
|
|
// now look to see if we want to convert this to a double- or triple-click
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2000-12-12 12:22:49 +00:00
|
|
|
#ifdef NS_DEBUG_XX
|
2000-12-13 11:53:10 +00:00
|
|
|
printf("Msg: %d Last: %d Dif: %d Max %d\n", curMsgTime, gLastMouseDownTime, curMsgTime-gLastMouseDownTime, ::GetDoubleClickTime());
|
2000-12-12 12:22:49 +00:00
|
|
|
printf("Mouse %d %d\n", abs(gLastMousePoint.x - mp.x), abs(gLastMousePoint.y - mp.y));
|
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
if (((curMsgTime - gLastMouseDownTime) < (LONG)::GetDoubleClickTime()) && insideMovementThreshold &&
|
|
|
|
eventButton == gLastMouseButton) {
|
2000-04-28 20:27:18 +00:00
|
|
|
gLastClickCount ++;
|
|
|
|
} else {
|
|
|
|
// reset the click count, to count *this* click
|
|
|
|
gLastClickCount = 1;
|
|
|
|
}
|
2000-12-13 11:53:10 +00:00
|
|
|
// Set last Click time on MouseDown only
|
|
|
|
gLastMouseDownTime = curMsgTime;
|
2001-02-23 00:40:19 +00:00
|
|
|
}
|
|
|
|
else if (aEventType == NS_MOUSE_MOVE && !insideMovementThreshold) {
|
2000-12-12 12:22:49 +00:00
|
|
|
gLastClickCount = 0;
|
2000-04-28 20:27:18 +00:00
|
|
|
}
|
2000-12-12 12:22:49 +00:00
|
|
|
event.clickCount = gLastClickCount;
|
2000-04-28 20:27:18 +00:00
|
|
|
|
2000-12-12 12:22:49 +00:00
|
|
|
#ifdef NS_DEBUG_XX
|
|
|
|
printf("Msg Time: %d Click Count: %d\n", curMsgTime, event.clickCount);
|
|
|
|
#endif
|
2000-04-28 20:27:18 +00:00
|
|
|
|
1999-06-25 21:17:52 +00:00
|
|
|
nsPluginEvent pluginEvent;
|
|
|
|
|
2005-12-02 12:08:32 +00:00
|
|
|
switch (aEventType)
|
1999-06-25 21:17:52 +00:00
|
|
|
{
|
2006-11-16 21:35:39 +00:00
|
|
|
case NS_MOUSE_BUTTON_DOWN:
|
|
|
|
switch (aButton) {
|
|
|
|
case nsMouseEvent::eLeftButton:
|
|
|
|
pluginEvent.event = WM_LBUTTONDOWN;
|
|
|
|
break;
|
|
|
|
case nsMouseEvent::eMiddleButton:
|
|
|
|
pluginEvent.event = WM_MBUTTONDOWN;
|
|
|
|
break;
|
|
|
|
case nsMouseEvent::eRightButton:
|
|
|
|
pluginEvent.event = WM_RBUTTONDOWN;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1999-06-25 21:17:52 +00:00
|
|
|
break;
|
2006-11-16 21:35:39 +00:00
|
|
|
case NS_MOUSE_BUTTON_UP:
|
|
|
|
switch (aButton) {
|
|
|
|
case nsMouseEvent::eLeftButton:
|
|
|
|
pluginEvent.event = WM_LBUTTONUP;
|
|
|
|
break;
|
|
|
|
case nsMouseEvent::eMiddleButton:
|
|
|
|
pluginEvent.event = WM_MBUTTONUP;
|
|
|
|
break;
|
|
|
|
case nsMouseEvent::eRightButton:
|
|
|
|
pluginEvent.event = WM_RBUTTONUP;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1999-06-25 21:17:52 +00:00
|
|
|
break;
|
2006-11-16 21:35:39 +00:00
|
|
|
case NS_MOUSE_DOUBLECLICK:
|
|
|
|
switch (aButton) {
|
|
|
|
case nsMouseEvent::eLeftButton:
|
|
|
|
pluginEvent.event = WM_LBUTTONDBLCLK;
|
|
|
|
break;
|
|
|
|
case nsMouseEvent::eMiddleButton:
|
|
|
|
pluginEvent.event = WM_MBUTTONDBLCLK;
|
|
|
|
break;
|
|
|
|
case nsMouseEvent::eRightButton:
|
|
|
|
pluginEvent.event = WM_RBUTTONDBLCLK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1999-06-25 21:17:52 +00:00
|
|
|
break;
|
|
|
|
case NS_MOUSE_MOVE:
|
|
|
|
pluginEvent.event = WM_MOUSEMOVE;
|
|
|
|
break;
|
|
|
|
default:
|
2005-12-02 12:08:32 +00:00
|
|
|
pluginEvent.event = WM_NULL;
|
1999-06-25 21:17:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-02-05 06:13:44 +00:00
|
|
|
pluginEvent.wParam = wParam; // plugins NEED raw OS event flags!
|
2005-12-02 12:08:32 +00:00
|
|
|
pluginEvent.lParam = lParam;
|
1999-06-25 21:17:52 +00:00
|
|
|
|
|
|
|
event.nativeMsg = (void *)&pluginEvent;
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// call the event callback
|
1998-04-13 20:24:54 +00:00
|
|
|
if (nsnull != mEventCallback) {
|
2006-02-22 21:08:40 +00:00
|
|
|
if (nsToolkit::gMouseTrailer)
|
|
|
|
nsToolkit::gMouseTrailer->Disable();
|
1998-04-13 20:24:54 +00:00
|
|
|
if (aEventType == NS_MOUSE_MOVE) {
|
2006-02-22 21:08:40 +00:00
|
|
|
if (nsToolkit::gMouseTrailer && !mIsInMouseCapture) {
|
|
|
|
nsToolkit::gMouseTrailer->SetMouseTrailerWindow(mWnd);
|
1999-08-05 14:56:21 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
nsRect rect;
|
|
|
|
GetBounds(rect);
|
|
|
|
rect.x = 0;
|
|
|
|
rect.y = 0;
|
|
|
|
|
2005-08-23 03:57:07 +00:00
|
|
|
if (rect.Contains(event.refPoint)) {
|
1998-05-29 22:44:13 +00:00
|
|
|
if (gCurrentWindow == NULL || gCurrentWindow != this) {
|
|
|
|
if ((nsnull != gCurrentWindow) && (!gCurrentWindow->mIsDestroying)) {
|
2005-12-02 12:08:32 +00:00
|
|
|
LPARAM pos = gCurrentWindow->lParamToClient(lParamToScreen(lParam));
|
|
|
|
gCurrentWindow->DispatchMouseEvent(NS_MOUSE_EXIT, wParam, pos);
|
1998-05-29 22:44:13 +00:00
|
|
|
}
|
|
|
|
gCurrentWindow = this;
|
|
|
|
if (!mIsDestroying) {
|
2005-12-02 12:08:32 +00:00
|
|
|
LPARAM pos = gCurrentWindow->lParamToClient(lParamToScreen(lParam));
|
|
|
|
gCurrentWindow->DispatchMouseEvent(NS_MOUSE_ENTER, wParam, pos);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
} else if (aEventType == NS_MOUSE_EXIT) {
|
1998-05-29 22:44:13 +00:00
|
|
|
if (gCurrentWindow == this) {
|
|
|
|
gCurrentWindow = nsnull;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
}
|
2002-04-02 21:08:29 +00:00
|
|
|
|
2006-01-09 17:23:20 +00:00
|
|
|
result = DispatchWindowEvent(&event);
|
|
|
|
|
2006-02-22 21:08:40 +00:00
|
|
|
if (nsToolkit::gMouseTrailer)
|
|
|
|
nsToolkit::gMouseTrailer->Enable();
|
2006-01-22 12:00:55 +00:00
|
|
|
|
2002-04-02 21:08:29 +00:00
|
|
|
// Release the widget with NS_IF_RELEASE() just in case
|
|
|
|
// the context menu key code in nsEventListenerManager::HandleEvent()
|
|
|
|
// released it already.
|
|
|
|
NS_IF_RELEASE(event.widget);
|
1998-04-13 20:24:54 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsnull != mMouseListener) {
|
|
|
|
switch (aEventType) {
|
2004-09-03 08:44:23 +00:00
|
|
|
case NS_MOUSE_MOVE:
|
|
|
|
{
|
1998-04-13 20:24:54 +00:00
|
|
|
result = ConvertStatus(mMouseListener->MouseMoved(event));
|
|
|
|
nsRect rect;
|
|
|
|
GetBounds(rect);
|
2005-08-23 03:57:07 +00:00
|
|
|
if (rect.Contains(event.refPoint)) {
|
1998-05-29 22:44:13 +00:00
|
|
|
if (gCurrentWindow == NULL || gCurrentWindow != this) {
|
|
|
|
gCurrentWindow = this;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2006-11-16 21:35:39 +00:00
|
|
|
case NS_MOUSE_BUTTON_DOWN:
|
1998-04-13 20:24:54 +00:00
|
|
|
result = ConvertStatus(mMouseListener->MousePressed(event));
|
|
|
|
break;
|
|
|
|
|
2006-11-16 21:35:39 +00:00
|
|
|
case NS_MOUSE_BUTTON_UP:
|
1998-04-13 20:24:54 +00:00
|
|
|
result = ConvertStatus(mMouseListener->MouseReleased(event));
|
|
|
|
result = ConvertStatus(mMouseListener->MouseClicked(event));
|
|
|
|
break;
|
|
|
|
} // switch
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
2005-04-29 13:33:49 +00:00
|
|
|
|
1998-10-08 00:04:21 +00:00
|
|
|
NS_RELEASE(event.widget);
|
1998-04-13 20:24:54 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-04-01 01:38:35 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
2001-08-03 08:15:20 +00:00
|
|
|
// Deal with accessibile event
|
2001-04-01 01:38:35 +00:00
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-04-01 01:38:35 +00:00
|
|
|
PRBool nsWindow::DispatchAccessibleEvent(PRUint32 aEventType, nsIAccessible** aAcc, nsPoint* aPoint)
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
|
|
|
|
if (nsnull == mEventCallback) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aAcc = nsnull;
|
|
|
|
|
2005-04-28 23:48:28 +00:00
|
|
|
nsAccessibleEvent event(PR_TRUE, aEventType, this);
|
2004-01-12 08:25:18 +00:00
|
|
|
InitEvent(event, aPoint);
|
2001-04-01 01:38:35 +00:00
|
|
|
|
|
|
|
event.isShift = IS_VK_DOWN(NS_VK_SHIFT);
|
|
|
|
event.isControl = IS_VK_DOWN(NS_VK_CONTROL);
|
|
|
|
event.isMeta = PR_FALSE;
|
|
|
|
event.isAlt = IS_VK_DOWN(NS_VK_ALT);
|
|
|
|
event.accessible = nsnull;
|
|
|
|
|
|
|
|
result = DispatchWindowEvent(&event);
|
|
|
|
|
|
|
|
// if the event returned an accesssible get it.
|
|
|
|
if (event.accessible)
|
|
|
|
*aAcc = event.accessible;
|
|
|
|
|
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2001-08-17 03:13:07 +00:00
|
|
|
#endif
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Deal with focus messages
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2001-05-18 12:07:42 +00:00
|
|
|
PRBool nsWindow::DispatchFocus(PRUint32 aEventType, PRBool isMozWindowTakingFocus)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
// call the event callback
|
1999-07-27 20:50:05 +00:00
|
|
|
if (mEventCallback) {
|
2005-04-28 23:48:28 +00:00
|
|
|
nsFocusEvent event(PR_TRUE, aEventType, this);
|
2004-01-12 08:25:18 +00:00
|
|
|
InitEvent(event);
|
1999-07-27 20:50:05 +00:00
|
|
|
|
|
|
|
//focus and blur event should go to their base widget loc, not current mouse pos
|
2005-08-23 03:57:07 +00:00
|
|
|
event.refPoint.x = 0;
|
|
|
|
event.refPoint.y = 0;
|
1999-07-27 20:50:05 +00:00
|
|
|
|
2001-05-18 12:07:42 +00:00
|
|
|
event.isMozWindowTakingFocus = isMozWindowTakingFocus;
|
|
|
|
|
1999-07-27 20:50:05 +00:00
|
|
|
nsPluginEvent pluginEvent;
|
|
|
|
|
|
|
|
switch (aEventType)//~~~
|
|
|
|
{
|
|
|
|
case NS_GOTFOCUS:
|
|
|
|
pluginEvent.event = WM_SETFOCUS;
|
|
|
|
break;
|
|
|
|
case NS_LOSTFOCUS:
|
|
|
|
pluginEvent.event = WM_KILLFOCUS;
|
2000-08-24 04:53:31 +00:00
|
|
|
break;
|
|
|
|
case NS_PLUGIN_ACTIVATE:
|
|
|
|
pluginEvent.event = WM_KILLFOCUS;
|
1999-07-27 20:50:05 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-07-27 20:50:05 +00:00
|
|
|
event.nativeMsg = (void *)&pluginEvent;
|
|
|
|
|
|
|
|
PRBool result = DispatchWindowEvent(&event);
|
2005-10-13 15:07:56 +00:00
|
|
|
|
1999-07-27 20:50:05 +00:00
|
|
|
NS_RELEASE(event.widget);
|
2005-07-24 19:36:18 +00:00
|
|
|
|
1999-07-27 20:50:05 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Deal with scrollbar messages (actually implemented only in nsScrollbar)
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
PRBool nsWindow::OnScroll(UINT scrollCode, int cPos)
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
return PR_FALSE;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
2004-09-03 08:44:23 +00:00
|
|
|
// Return the brush used to paint the background of this control
|
1998-04-13 20:24:54 +00:00
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
HBRUSH nsWindow::OnControlColor()
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
return mBrush;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-07-21 18:04:18 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Deal with all sort of mouse event
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2006-11-16 21:35:39 +00:00
|
|
|
PRBool ChildWindow::DispatchMouseEvent(PRUint32 aEventType, WPARAM wParam, LPARAM lParam,
|
|
|
|
PRBool aIsContextMenuKey, PRInt16 aButton)
|
1998-07-21 18:04:18 +00:00
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
|
|
|
|
if (nsnull == mEventCallback && nsnull == mMouseListener) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (aEventType) {
|
2006-11-16 21:35:39 +00:00
|
|
|
case NS_MOUSE_BUTTON_DOWN:
|
2004-09-03 08:44:23 +00:00
|
|
|
CaptureMouse(PR_TRUE);
|
1998-07-21 18:04:18 +00:00
|
|
|
break;
|
|
|
|
|
2006-11-19 21:13:25 +00:00
|
|
|
// NS_MOUSE_MOVE and NS_MOUSE_EXIT are here because we need to make sure capture flag
|
|
|
|
// isn't left on after a drag where we wouldn't see a button up message (see bug 324131).
|
2006-11-16 21:35:39 +00:00
|
|
|
case NS_MOUSE_BUTTON_UP:
|
2006-11-19 21:13:25 +00:00
|
|
|
case NS_MOUSE_MOVE:
|
|
|
|
case NS_MOUSE_EXIT:
|
|
|
|
if (!(wParam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) && mIsInMouseCapture)
|
2006-11-13 12:20:20 +00:00
|
|
|
CaptureMouse(PR_FALSE);
|
1998-07-21 18:04:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
} // switch
|
|
|
|
|
2006-11-16 21:35:39 +00:00
|
|
|
return nsWindow::DispatchMouseEvent(aEventType, wParam, lParam,
|
|
|
|
aIsContextMenuKey, aButton);
|
1998-07-21 18:04:18 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2000-03-21 03:42:00 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// return the style for a child nsWindow
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
DWORD ChildWindow::WindowStyle()
|
1999-07-27 04:27:17 +00:00
|
|
|
{
|
2000-03-21 03:42:00 +00:00
|
|
|
return WS_CHILD | WS_CLIPCHILDREN | nsWindow::WindowStyle();
|
1999-07-27 04:27:17 +00:00
|
|
|
}
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_METHOD nsWindow::SetTitle(const nsAString& aTitle)
|
2000-01-31 22:53:35 +00:00
|
|
|
{
|
2004-04-18 23:18:23 +00:00
|
|
|
const nsString& strTitle = PromiseFlatString(aTitle);
|
2006-04-04 20:57:13 +00:00
|
|
|
::SendMessageW(mWnd, WM_SETTEXT, (WPARAM)0, (LPARAM)(LPCWSTR)strTitle.get());
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
1998-04-17 23:45:07 +00:00
|
|
|
|
2004-09-07 18:59:27 +00:00
|
|
|
NS_METHOD nsWindow::SetIcon(const nsAString& aIconSpec)
|
2001-04-14 00:57:30 +00:00
|
|
|
{
|
2004-09-07 18:59:27 +00:00
|
|
|
// Assume the given string is a local identifier for an icon file.
|
|
|
|
|
|
|
|
nsCOMPtr<nsILocalFile> iconFile;
|
|
|
|
ResolveIconName(aIconSpec, NS_LITERAL_STRING(".ico"),
|
|
|
|
getter_AddRefs(iconFile));
|
|
|
|
if (!iconFile)
|
|
|
|
return NS_OK; // not an error if icon is not found
|
|
|
|
|
2002-05-07 23:07:19 +00:00
|
|
|
nsAutoString iconPath;
|
2004-09-07 18:59:27 +00:00
|
|
|
iconFile->GetPath(iconPath);
|
|
|
|
|
|
|
|
// XXX this should use MZLU (see bug 239279)
|
2004-09-03 08:44:23 +00:00
|
|
|
|
|
|
|
::SetLastError(0);
|
2005-02-23 07:07:51 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
HICON bigIcon = (HICON)::LoadImageW(NULL,
|
|
|
|
(LPCWSTR)iconPath.get(),
|
|
|
|
IMAGE_ICON,
|
|
|
|
::GetSystemMetrics(SM_CXICON),
|
|
|
|
::GetSystemMetrics(SM_CYICON),
|
|
|
|
LR_LOADFROMFILE );
|
|
|
|
HICON smallIcon = (HICON)::LoadImageW(NULL,
|
|
|
|
(LPCWSTR)iconPath.get(),
|
|
|
|
IMAGE_ICON,
|
|
|
|
::GetSystemMetrics(SM_CXSMICON),
|
|
|
|
::GetSystemMetrics(SM_CYSMICON),
|
|
|
|
LR_LOADFROMFILE );
|
2001-06-20 01:47:29 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (bigIcon) {
|
2006-04-04 20:57:13 +00:00
|
|
|
HICON icon = (HICON) ::SendMessageW(mWnd, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)bigIcon);
|
2003-10-30 01:35:14 +00:00
|
|
|
if (icon)
|
|
|
|
::DestroyIcon(icon);
|
2001-04-14 00:57:30 +00:00
|
|
|
}
|
2004-09-07 18:59:27 +00:00
|
|
|
#ifdef DEBUG_SetIcon
|
2001-04-14 00:57:30 +00:00
|
|
|
else {
|
2004-09-07 18:59:27 +00:00
|
|
|
NS_LossyConvertUTF16toASCII cPath(iconPath);
|
|
|
|
printf( "\nIcon load error; icon=%s, rc=0x%08X\n\n", cPath.get(), ::GetLastError() );
|
2001-04-14 00:57:30 +00:00
|
|
|
}
|
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
if (smallIcon) {
|
2006-04-04 20:57:13 +00:00
|
|
|
HICON icon = (HICON) ::SendMessageW(mWnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)smallIcon);
|
2003-10-30 01:35:14 +00:00
|
|
|
if (icon)
|
|
|
|
::DestroyIcon(icon);
|
2001-04-14 00:57:30 +00:00
|
|
|
}
|
2004-09-07 18:59:27 +00:00
|
|
|
#ifdef DEBUG_SetIcon
|
2001-04-14 00:57:30 +00:00
|
|
|
else {
|
2004-09-07 18:59:27 +00:00
|
|
|
NS_LossyConvertUTF16toASCII cPath(iconPath);
|
|
|
|
printf( "\nSmall icon load error; icon=%s, rc=0x%08X\n\n", cPath.get(), ::GetLastError() );
|
2001-04-14 00:57:30 +00:00
|
|
|
}
|
|
|
|
#endif
|
2004-09-07 18:59:27 +00:00
|
|
|
|
2001-04-14 00:57:30 +00:00
|
|
|
return NS_OK;
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
2001-04-14 00:57:30 +00:00
|
|
|
|
1998-04-17 23:45:07 +00:00
|
|
|
|
1998-04-28 19:24:52 +00:00
|
|
|
PRBool nsWindow::AutoErase()
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
return PR_FALSE;
|
1998-04-28 19:24:52 +00:00
|
|
|
}
|
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsWindow::GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight)
|
|
|
|
{
|
|
|
|
aWidth = mPreferredWidth;
|
|
|
|
aHeight = mPreferredHeight;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsWindow::SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight)
|
|
|
|
{
|
|
|
|
mPreferredWidth = aWidth;
|
|
|
|
mPreferredHeight = aHeight;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-03-22 23:09:01 +00:00
|
|
|
#define ZH_CN_INTELLEGENT_ABC_IME ((HKL)0xe0040804L)
|
2002-05-23 22:03:49 +00:00
|
|
|
#define ZH_CN_MS_PINYIN_IME_3_0 ((HKL)0xe00e0804L)
|
|
|
|
#define ZH_CN_NEIMA_IME ((HKL)0xe0050804L)
|
2004-09-03 08:44:23 +00:00
|
|
|
#define PINYIN_IME_ON_XP(kl) ((nsToolkit::mIsWinXP) && \
|
|
|
|
(ZH_CN_MS_PINYIN_IME_3_0 == (kl)))
|
2002-09-25 02:23:01 +00:00
|
|
|
PRBool gPinYinIMECaretCreated = PR_FALSE;
|
2002-03-22 23:09:01 +00:00
|
|
|
|
1999-03-19 23:36:20 +00:00
|
|
|
void
|
1999-10-27 23:05:24 +00:00
|
|
|
nsWindow::HandleTextEvent(HIMC hIMEContext,PRBool aCheckAttr)
|
1999-03-19 23:36:20 +00:00
|
|
|
{
|
2004-09-08 19:30:22 +00:00
|
|
|
NS_ASSERTION(sIMECompUnicode, "sIMECompUnicode is null");
|
|
|
|
NS_ASSERTION(sIMEIsComposing, "conflict state");
|
1999-11-16 23:45:44 +00:00
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
if (!sIMECompUnicode)
|
2004-09-03 08:44:23 +00:00
|
|
|
return;
|
|
|
|
|
2005-04-28 23:48:28 +00:00
|
|
|
nsTextEvent event(PR_TRUE, NS_TEXT_TEXT, this);
|
2004-09-03 08:44:23 +00:00
|
|
|
nsPoint point(0, 0);
|
1998-04-17 23:45:07 +00:00
|
|
|
|
2004-01-12 08:25:18 +00:00
|
|
|
InitEvent(event, &point);
|
2004-09-03 08:44:23 +00:00
|
|
|
|
|
|
|
if (aCheckAttr) {
|
2004-09-08 19:30:22 +00:00
|
|
|
GetTextRangeList(&(event.rangeCount),&(event.rangeArray));
|
1999-10-27 00:14:46 +00:00
|
|
|
} else {
|
2004-09-03 08:44:23 +00:00
|
|
|
event.rangeCount = 0;
|
|
|
|
event.rangeArray = nsnull;
|
1999-10-27 00:14:46 +00:00
|
|
|
}
|
1999-06-29 20:31:22 +00:00
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
event.theText = sIMECompUnicode->get();
|
2004-09-03 08:44:23 +00:00
|
|
|
event.isShift = mIsShiftDown;
|
1999-03-19 23:36:20 +00:00
|
|
|
event.isControl = mIsControlDown;
|
2004-09-03 08:44:23 +00:00
|
|
|
event.isMeta = PR_FALSE;
|
1999-06-29 20:31:22 +00:00
|
|
|
event.isAlt = mIsAltDown;
|
1999-03-19 23:36:20 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
DispatchWindowEvent(&event);
|
1999-03-19 23:36:20 +00:00
|
|
|
NS_RELEASE(event.widget);
|
1998-04-17 23:45:07 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (event.rangeArray)
|
|
|
|
delete [] event.rangeArray;
|
1999-10-25 22:17:09 +00:00
|
|
|
|
1999-08-06 07:42:35 +00:00
|
|
|
//
|
|
|
|
// Post process event
|
|
|
|
//
|
2004-09-03 08:44:23 +00:00
|
|
|
if (event.theReply.mCursorPosition.width || event.theReply.mCursorPosition.height)
|
2002-02-18 23:46:51 +00:00
|
|
|
{
|
2005-11-18 05:29:52 +00:00
|
|
|
nsRect cursorPosition;
|
|
|
|
ResolveIMECaretPos(this, event.theReply.mCursorPosition, cursorPosition);
|
2005-02-01 19:24:59 +00:00
|
|
|
CANDIDATEFORM candForm;
|
2002-02-18 23:46:51 +00:00
|
|
|
candForm.dwIndex = 0;
|
|
|
|
candForm.dwStyle = CFS_EXCLUDE;
|
2005-11-18 05:29:52 +00:00
|
|
|
candForm.ptCurrentPos.x = cursorPosition.x;
|
|
|
|
candForm.ptCurrentPos.y = cursorPosition.y;
|
2002-02-18 23:46:51 +00:00
|
|
|
candForm.rcArea.right = candForm.rcArea.left = candForm.ptCurrentPos.x;
|
|
|
|
candForm.rcArea.top = candForm.ptCurrentPos.y;
|
2004-09-03 08:44:23 +00:00
|
|
|
candForm.rcArea.bottom = candForm.ptCurrentPos.y +
|
2005-11-18 05:29:52 +00:00
|
|
|
cursorPosition.height;
|
2004-09-03 08:44:23 +00:00
|
|
|
|
|
|
|
if (gPinYinIMECaretCreated)
|
2002-09-25 02:23:01 +00:00
|
|
|
{
|
|
|
|
SetCaretPos(candForm.ptCurrentPos.x, candForm.ptCurrentPos.y);
|
|
|
|
}
|
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
::ImmSetCandidateWindow(hIMEContext, &candForm);
|
2005-02-01 19:24:59 +00:00
|
|
|
|
2002-03-22 23:09:01 +00:00
|
|
|
// somehow the "Intellegent ABC IME" in Simplified Chinese
|
|
|
|
// window listen to the caret position to decide where to put the
|
|
|
|
// candidate window
|
2004-09-03 08:44:23 +00:00
|
|
|
if (gKeyboardLayout == ZH_CN_INTELLEGENT_ABC_IME)
|
2002-03-22 23:09:01 +00:00
|
|
|
{
|
|
|
|
CreateCaret(mWnd, nsnull, 1, 1);
|
2004-09-03 08:44:23 +00:00
|
|
|
SetCaretPos(candForm.ptCurrentPos.x, candForm.ptCurrentPos.y);
|
2002-03-22 23:09:01 +00:00
|
|
|
DestroyCaret();
|
|
|
|
}
|
2002-10-01 02:47:41 +00:00
|
|
|
|
|
|
|
// Record previous composing char position
|
2004-09-03 08:44:23 +00:00
|
|
|
// The cursor is always on the right char before it, but not necessarily on the
|
2002-10-01 02:47:41 +00:00
|
|
|
// left of next char, as what happens in wrapping.
|
2004-09-08 19:30:22 +00:00
|
|
|
if (sIMECursorPosition && sIMECompCharPos &&
|
|
|
|
sIMECursorPosition < IME_MAX_CHAR_POS) {
|
2005-11-18 05:29:52 +00:00
|
|
|
sIMECompCharPos[sIMECursorPosition-1].right = cursorPosition.x;
|
|
|
|
sIMECompCharPos[sIMECursorPosition-1].top = cursorPosition.y;
|
|
|
|
sIMECompCharPos[sIMECursorPosition-1].bottom = cursorPosition.YMost();
|
|
|
|
if (sIMECompCharPos[sIMECursorPosition-1].top != cursorPosition.y) {
|
2002-10-01 02:47:41 +00:00
|
|
|
// wrapping, invalidate left position
|
2004-09-08 19:30:22 +00:00
|
|
|
sIMECompCharPos[sIMECursorPosition-1].left = -1;
|
2002-10-01 02:47:41 +00:00
|
|
|
}
|
2005-11-18 05:29:52 +00:00
|
|
|
sIMECompCharPos[sIMECursorPosition].left = cursorPosition.x;
|
|
|
|
sIMECompCharPos[sIMECursorPosition].top = cursorPosition.y;
|
|
|
|
sIMECompCharPos[sIMECursorPosition].bottom = cursorPosition.YMost();
|
2002-10-01 02:47:41 +00:00
|
|
|
}
|
2005-11-18 05:29:52 +00:00
|
|
|
sIMECaretHeight = cursorPosition.height;
|
2002-02-18 23:46:51 +00:00
|
|
|
} else {
|
2004-09-03 08:44:23 +00:00
|
|
|
// for some reason we don't know yet, theReply may contain invalid result
|
2002-02-18 23:46:51 +00:00
|
|
|
// need more debugging in nsCaret to find out the reason
|
|
|
|
// the best we can do now is to ignore the invalid result
|
|
|
|
}
|
1999-03-19 23:36:20 +00:00
|
|
|
}
|
1999-05-03 22:57:48 +00:00
|
|
|
|
2002-05-23 22:03:49 +00:00
|
|
|
BOOL
|
1999-08-31 01:20:32 +00:00
|
|
|
nsWindow::HandleStartComposition(HIMC hIMEContext)
|
1999-05-03 22:57:48 +00:00
|
|
|
{
|
2005-03-07 12:25:26 +00:00
|
|
|
// ATOK send the messages following order at starting composition.
|
|
|
|
// 1. WM_IME_COMPOSITION
|
|
|
|
// 2. WM_IME_STARTCOMPOSITION
|
|
|
|
// We call this function at both step #1 and #2.
|
|
|
|
// However, the composition start event should occur only once.
|
|
|
|
if (sIMEIsComposing)
|
|
|
|
return PR_TRUE;
|
|
|
|
|
2005-06-09 14:50:35 +00:00
|
|
|
if (sIMEReconvertUnicode) {
|
|
|
|
nsMemory::Free(sIMEReconvertUnicode);
|
|
|
|
sIMEReconvertUnicode = NULL;
|
|
|
|
}
|
|
|
|
|
2005-04-28 23:48:28 +00:00
|
|
|
nsCompositionEvent event(PR_TRUE, NS_COMPOSITION_START, this);
|
2004-09-03 08:44:23 +00:00
|
|
|
nsPoint point(0, 0);
|
|
|
|
CANDIDATEFORM candForm;
|
1999-05-03 22:57:48 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
InitEvent(event, &point);
|
|
|
|
DispatchWindowEvent(&event);
|
1999-08-31 01:20:32 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
//
|
|
|
|
// Post process event
|
|
|
|
//
|
|
|
|
if (event.theReply.mCursorPosition.width || event.theReply.mCursorPosition.height)
|
2002-02-18 23:46:51 +00:00
|
|
|
{
|
2005-11-18 05:29:52 +00:00
|
|
|
nsRect cursorPosition;
|
|
|
|
ResolveIMECaretPos(this, event.theReply.mCursorPosition, cursorPosition);
|
2002-02-18 23:46:51 +00:00
|
|
|
candForm.dwIndex = 0;
|
|
|
|
candForm.dwStyle = CFS_CANDIDATEPOS;
|
2005-11-18 05:29:52 +00:00
|
|
|
candForm.ptCurrentPos.x = cursorPosition.x + IME_X_OFFSET;
|
|
|
|
candForm.ptCurrentPos.y = cursorPosition.y + IME_Y_OFFSET +
|
|
|
|
cursorPosition.height;
|
2002-02-18 23:46:51 +00:00
|
|
|
candForm.rcArea.right = 0;
|
|
|
|
candForm.rcArea.left = 0;
|
|
|
|
candForm.rcArea.top = 0;
|
|
|
|
candForm.rcArea.bottom = 0;
|
1999-11-30 22:09:28 +00:00
|
|
|
#ifdef DEBUG_IME2
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("Candidate window position: x=%d, y=%d\n", candForm.ptCurrentPos.x, candForm.ptCurrentPos.y);
|
1999-08-31 01:20:32 +00:00
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
|
|
|
|
if (!gPinYinIMECaretCreated && PINYIN_IME_ON_XP(gKeyboardLayout))
|
2002-09-25 02:23:01 +00:00
|
|
|
{
|
|
|
|
gPinYinIMECaretCreated = CreateCaret(mWnd, nsnull, 1, 1);
|
|
|
|
SetCaretPos(candForm.ptCurrentPos.x, candForm.ptCurrentPos.y);
|
|
|
|
}
|
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
::ImmSetCandidateWindow(hIMEContext, &candForm);
|
2002-10-01 02:47:41 +00:00
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
sIMECompCharPos = (RECT*)PR_MALLOC(IME_MAX_CHAR_POS*sizeof(RECT));
|
|
|
|
if (sIMECompCharPos) {
|
|
|
|
memset(sIMECompCharPos, -1, sizeof(RECT)*IME_MAX_CHAR_POS);
|
2005-11-18 05:29:52 +00:00
|
|
|
sIMECompCharPos[0].left = cursorPosition.x;
|
|
|
|
sIMECompCharPos[0].top = cursorPosition.y;
|
|
|
|
sIMECompCharPos[0].bottom = cursorPosition.YMost();
|
2002-10-01 02:47:41 +00:00
|
|
|
}
|
2005-11-18 05:29:52 +00:00
|
|
|
sIMECaretHeight = cursorPosition.height;
|
2002-02-18 23:46:51 +00:00
|
|
|
} else {
|
2004-09-03 08:44:23 +00:00
|
|
|
// for some reason we don't know yet, theReply may contain invalid result
|
2002-02-18 23:46:51 +00:00
|
|
|
// need more debugging in nsCaret to find out the reason
|
|
|
|
// the best we can do now is to ignore the invalid result
|
|
|
|
}
|
2002-10-01 02:47:41 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_RELEASE(event.widget);
|
1999-11-16 23:45:44 +00:00
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
if (!sIMECompUnicode)
|
|
|
|
sIMECompUnicode = new nsAutoString();
|
|
|
|
sIMEIsComposing = PR_TRUE;
|
1999-11-10 23:43:46 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
return PR_TRUE;
|
1999-05-03 22:57:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsWindow::HandleEndComposition(void)
|
|
|
|
{
|
2005-06-25 04:43:04 +00:00
|
|
|
if (!sIMEIsComposing)
|
|
|
|
return;
|
|
|
|
|
2005-04-28 23:48:28 +00:00
|
|
|
nsCompositionEvent event(PR_TRUE, NS_COMPOSITION_END, this);
|
2004-09-03 08:44:23 +00:00
|
|
|
nsPoint point(0, 0);
|
1999-05-03 22:57:48 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (gPinYinIMECaretCreated)
|
|
|
|
{
|
|
|
|
DestroyCaret();
|
|
|
|
gPinYinIMECaretCreated = PR_FALSE;
|
|
|
|
}
|
2002-09-25 02:23:01 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
InitEvent(event,&point);
|
|
|
|
DispatchWindowEvent(&event);
|
|
|
|
NS_RELEASE(event.widget);
|
2004-09-08 19:30:22 +00:00
|
|
|
PR_FREEIF(sIMECompCharPos);
|
|
|
|
sIMECompCharPos = nsnull;
|
2005-02-01 19:24:59 +00:00
|
|
|
sIMECaretHeight = 0;
|
2004-09-08 19:30:22 +00:00
|
|
|
sIMEIsComposing = PR_FALSE;
|
1999-05-03 22:57:48 +00:00
|
|
|
}
|
1999-06-29 20:31:22 +00:00
|
|
|
|
1999-11-30 22:09:28 +00:00
|
|
|
static PRUint32 PlatformToNSAttr(PRUint8 aAttr)
|
1999-10-25 22:17:09 +00:00
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
switch (aAttr)
|
|
|
|
{
|
1999-11-30 22:09:28 +00:00
|
|
|
case ATTR_INPUT_ERROR:
|
|
|
|
// case ATTR_FIXEDCONVERTED:
|
1999-10-25 22:17:09 +00:00
|
|
|
case ATTR_INPUT:
|
2004-09-03 08:44:23 +00:00
|
|
|
return NS_TEXTRANGE_RAWINPUT;
|
1999-10-25 22:17:09 +00:00
|
|
|
case ATTR_CONVERTED:
|
2004-09-03 08:44:23 +00:00
|
|
|
return NS_TEXTRANGE_CONVERTEDTEXT;
|
1999-10-25 22:17:09 +00:00
|
|
|
case ATTR_TARGET_NOTCONVERTED:
|
2004-09-03 08:44:23 +00:00
|
|
|
return NS_TEXTRANGE_SELECTEDRAWTEXT;
|
1999-10-25 22:17:09 +00:00
|
|
|
case ATTR_TARGET_CONVERTED:
|
2004-09-03 08:44:23 +00:00
|
|
|
return NS_TEXTRANGE_SELECTEDCONVERTEDTEXT;
|
1999-10-25 22:17:09 +00:00
|
|
|
default:
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_ASSERTION(PR_FALSE, "unknown attribute");
|
|
|
|
return NS_TEXTRANGE_CARETPOSITION;
|
|
|
|
}
|
1999-10-25 22:17:09 +00:00
|
|
|
}
|
1999-06-29 20:31:22 +00:00
|
|
|
//
|
2004-09-03 08:44:23 +00:00
|
|
|
// This function converts the composition string (CGS_COMPSTR) into Unicode while mapping the
|
1999-06-29 20:31:22 +00:00
|
|
|
// attribute (GCS_ATTR) string t
|
2004-09-03 08:44:23 +00:00
|
|
|
void
|
2004-09-08 19:30:22 +00:00
|
|
|
nsWindow::GetTextRangeList(PRUint32* textRangeListLengthResult,nsTextRangeArray* textRangeListResult)
|
1999-06-29 20:31:22 +00:00
|
|
|
{
|
2004-09-08 19:30:22 +00:00
|
|
|
NS_ASSERTION(sIMECompUnicode, "sIMECompUnicode is null");
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
if (!sIMECompUnicode)
|
2004-09-03 08:44:23 +00:00
|
|
|
return;
|
2000-04-13 22:23:04 +00:00
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
long maxlen = sIMECompUnicode->Length();
|
|
|
|
long cursor = sIMECursorPosition;
|
1999-11-30 22:09:28 +00:00
|
|
|
NS_ASSERTION(cursor <= maxlen, "wrong cursor positoin");
|
2004-09-03 08:44:23 +00:00
|
|
|
if (cursor > maxlen)
|
1999-11-30 22:09:28 +00:00
|
|
|
cursor = maxlen;
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
//
|
|
|
|
// figure out the ranges from the compclause string
|
|
|
|
//
|
2004-09-08 19:30:22 +00:00
|
|
|
if (sIMECompClauseArrayLength == 0) {
|
2004-09-03 08:44:23 +00:00
|
|
|
*textRangeListLengthResult = 2;
|
|
|
|
*textRangeListResult = new nsTextRange[2];
|
2004-09-08 19:30:22 +00:00
|
|
|
(*textRangeListResult)[0].mStartOffset = 0;
|
|
|
|
(*textRangeListResult)[0].mEndOffset = sIMECompUnicode->Length();
|
2004-09-03 08:44:23 +00:00
|
|
|
(*textRangeListResult)[0].mRangeType = NS_TEXTRANGE_RAWINPUT;
|
2004-09-08 19:30:22 +00:00
|
|
|
(*textRangeListResult)[1].mStartOffset = cursor;
|
|
|
|
(*textRangeListResult)[1].mEndOffset = cursor;
|
2004-09-03 08:44:23 +00:00
|
|
|
(*textRangeListResult)[1].mRangeType = NS_TEXTRANGE_CARETPOSITION;
|
|
|
|
} else {
|
2004-09-08 19:30:22 +00:00
|
|
|
*textRangeListLengthResult = sIMECompClauseArrayLength;
|
2004-09-03 08:44:23 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// allocate the offset array
|
|
|
|
//
|
|
|
|
*textRangeListResult = new nsTextRange[*textRangeListLengthResult];
|
|
|
|
|
|
|
|
//
|
|
|
|
// figure out the cursor position
|
|
|
|
//
|
2004-09-08 19:30:22 +00:00
|
|
|
(*textRangeListResult)[0].mStartOffset = cursor;
|
|
|
|
(*textRangeListResult)[0].mEndOffset = cursor;
|
2004-09-03 08:44:23 +00:00
|
|
|
(*textRangeListResult)[0].mRangeType = NS_TEXTRANGE_CARETPOSITION;
|
|
|
|
|
|
|
|
//
|
2004-09-08 19:30:22 +00:00
|
|
|
// iterate over the attributes and convert them into unicode
|
|
|
|
//
|
|
|
|
int lastOffset = 0;
|
|
|
|
for(int i = 1; i < sIMECompClauseArrayLength; i++) {
|
|
|
|
long current = sIMECompClauseArray[i];
|
2004-09-03 08:44:23 +00:00
|
|
|
NS_ASSERTION(current <= maxlen, "wrong offset");
|
2004-09-08 19:30:22 +00:00
|
|
|
if(current > maxlen)
|
2004-09-03 08:44:23 +00:00
|
|
|
current = maxlen;
|
1999-11-30 22:09:28 +00:00
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
(*textRangeListResult)[i].mRangeType =
|
|
|
|
PlatformToNSAttr(sIMEAttributeArray[lastOffset]);
|
|
|
|
(*textRangeListResult)[i].mStartOffset = lastOffset;
|
|
|
|
(*textRangeListResult)[i].mEndOffset = current;
|
1999-06-29 20:31:22 +00:00
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
lastOffset = current;
|
2004-09-03 08:44:23 +00:00
|
|
|
} // for
|
|
|
|
} // if else
|
1999-06-29 20:31:22 +00:00
|
|
|
}
|
1999-11-11 22:28:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
2004-09-03 08:44:23 +00:00
|
|
|
BOOL nsWindow::OnInputLangChange(HKL aHKL, LRESULT *oRetValue)
|
1999-11-11 22:28:52 +00:00
|
|
|
{
|
1999-12-01 22:10:13 +00:00
|
|
|
#ifdef KE_DEBUG
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("OnInputLanguageChange\n");
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (gKeyboardLayout != aHKL)
|
2001-09-29 00:15:21 +00:00
|
|
|
{
|
|
|
|
gKeyboardLayout = aHKL;
|
2006-03-16 21:02:22 +00:00
|
|
|
|
|
|
|
gKbdLayout.LoadLayout();
|
2001-09-29 00:15:21 +00:00
|
|
|
}
|
1999-11-11 22:28:52 +00:00
|
|
|
|
2001-09-29 00:15:21 +00:00
|
|
|
ResetInputState();
|
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
if (sIMEIsComposing) {
|
2001-09-29 00:15:21 +00:00
|
|
|
HandleEndComposition();
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE; // always pass to child window
|
1999-11-11 22:28:52 +00:00
|
|
|
}
|
|
|
|
//==========================================================================
|
|
|
|
BOOL nsWindow::OnIMEChar(BYTE aByte1, BYTE aByte2, LPARAM aKeyState)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_IME
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("OnIMEChar\n");
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
2002-05-23 22:03:49 +00:00
|
|
|
wchar_t uniChar;
|
|
|
|
int err = 0;
|
1999-11-11 22:28:52 +00:00
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
uniChar = MAKEWORD(aByte2, aByte1);
|
2002-05-23 22:03:49 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_IME
|
|
|
|
if (!err) {
|
|
|
|
DWORD lastError = ::GetLastError();
|
|
|
|
switch (lastError)
|
|
|
|
{
|
|
|
|
case ERROR_INSUFFICIENT_BUFFER:
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("ERROR_INSUFFICIENT_BUFFER\n");
|
2002-05-23 22:03:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ERROR_INVALID_FLAGS:
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("ERROR_INVALID_FLAGS\n");
|
2002-05-23 22:03:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ERROR_INVALID_PARAMETER:
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("ERROR_INVALID_PARAMETER\n");
|
2002-05-23 22:03:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ERROR_NO_UNICODE_TRANSLATION:
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("ERROR_NO_UNICODE_TRANSLATION\n");
|
2002-05-23 22:03:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-04-18 11:03:51 +00:00
|
|
|
// We need to return TRUE here so that Windows doesn't
|
2002-05-23 22:03:49 +00:00
|
|
|
// send two WM_CHAR msgs
|
|
|
|
DispatchKeyEvent(NS_KEY_PRESS, uniChar, 0, 0);
|
|
|
|
return PR_TRUE;
|
1999-11-11 22:28:52 +00:00
|
|
|
}
|
2004-09-08 19:30:22 +00:00
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
// This function is used when aIndex is GCS_COMPSTR, GCS_COMPREADSTR,
|
|
|
|
// GCS_RESULTSTR, and GCS_RESULTREADSTR.
|
2006-04-04 20:57:13 +00:00
|
|
|
// Otherwise use ::ImmGetCompositionStringW.
|
|
|
|
void nsWindow::GetCompositionString(HIMC aHIMC, DWORD aIndex, nsString* aStrUnicode)
|
2004-09-08 19:30:22 +00:00
|
|
|
{
|
|
|
|
long lRtn;
|
2006-04-04 20:57:13 +00:00
|
|
|
lRtn = ::ImmGetCompositionStringW(aHIMC, aIndex, NULL, 0);
|
2006-06-22 19:07:30 +00:00
|
|
|
if (!EnsureStringLength(*aStrUnicode, (lRtn / sizeof(WCHAR)) + 1))
|
|
|
|
return; // out of memory
|
2004-09-08 19:30:22 +00:00
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
long buflen = lRtn + sizeof(WCHAR);
|
|
|
|
lRtn = ::ImmGetCompositionStringW(aHIMC, aIndex, (LPVOID)aStrUnicode->BeginWriting(), buflen);
|
|
|
|
lRtn = lRtn / sizeof(WCHAR);
|
|
|
|
aStrUnicode->SetLength(lRtn);
|
2004-09-08 19:30:22 +00:00
|
|
|
}
|
|
|
|
|
1999-11-11 22:28:52 +00:00
|
|
|
//==========================================================================
|
2004-09-03 08:44:23 +00:00
|
|
|
BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
|
1999-11-11 22:28:52 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG_IME
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("OnIMEComposition\n");
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
2001-01-18 03:16:04 +00:00
|
|
|
// for bug #60050
|
|
|
|
// MS-IME 95/97/98/2000 may send WM_IME_COMPOSITION with non-conversion
|
|
|
|
// mode before it send WM_IME_STARTCOMPOSITION.
|
2004-09-08 19:30:22 +00:00
|
|
|
if (!sIMECompUnicode)
|
|
|
|
sIMECompUnicode = new nsAutoString();
|
2001-01-18 03:16:04 +00:00
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
NS_ASSERTION(sIMECompUnicode, "sIMECompUnicode is null");
|
|
|
|
if (!sIMECompUnicode)
|
2004-09-03 08:44:23 +00:00
|
|
|
return PR_TRUE;
|
1999-11-11 22:28:52 +00:00
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
HIMC hIMEContext = ::ImmGetContext(mWnd);
|
2004-09-08 19:30:22 +00:00
|
|
|
if (hIMEContext==NULL)
|
2004-09-03 08:44:23 +00:00
|
|
|
return PR_TRUE;
|
1999-11-11 22:28:52 +00:00
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
// will change this if an IME message we handle
|
|
|
|
BOOL result = PR_FALSE;
|
|
|
|
|
2005-06-25 04:43:04 +00:00
|
|
|
PRBool startCompositionMessageHasBeenSent = sIMEIsComposing;
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
//
|
|
|
|
// This catches a fixed result
|
|
|
|
//
|
|
|
|
if (aGCS & GCS_RESULTSTR) {
|
1999-11-11 22:28:52 +00:00
|
|
|
#ifdef DEBUG_IME
|
2005-03-02 08:03:13 +00:00
|
|
|
printf("Handling GCS_RESULTSTR\n");
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
2004-09-08 19:30:22 +00:00
|
|
|
if (!sIMEIsComposing)
|
2004-09-03 08:44:23 +00:00
|
|
|
HandleStartComposition(hIMEContext);
|
1999-11-11 22:28:52 +00:00
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
GetCompositionString(hIMEContext, GCS_RESULTSTR, sIMECompUnicode);
|
1999-11-11 22:28:52 +00:00
|
|
|
#ifdef DEBUG_IME
|
2005-03-02 08:03:13 +00:00
|
|
|
printf("GCS_RESULTSTR compStrLen = %d\n", sIMECompUnicode->Length());
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
result = PR_TRUE;
|
|
|
|
HandleTextEvent(hIMEContext, PR_FALSE);
|
|
|
|
HandleEndComposition();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// This provides us with a composition string
|
|
|
|
//
|
|
|
|
if (aGCS & (GCS_COMPSTR | GCS_COMPATTR | GCS_COMPCLAUSE | GCS_CURSORPOS))
|
|
|
|
{
|
1999-11-11 22:28:52 +00:00
|
|
|
#ifdef DEBUG_IME
|
2005-03-02 08:03:13 +00:00
|
|
|
printf("Handling GCS_COMPSTR\n");
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
1999-11-30 22:09:28 +00:00
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
if (!sIMEIsComposing)
|
2004-09-03 08:44:23 +00:00
|
|
|
HandleStartComposition(hIMEContext);
|
1999-11-11 22:28:52 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
//--------------------------------------------------------
|
2004-09-08 19:30:22 +00:00
|
|
|
// 1. Get GCS_COMPSTR
|
2004-09-03 08:44:23 +00:00
|
|
|
//--------------------------------------------------------
|
2006-04-04 20:57:13 +00:00
|
|
|
GetCompositionString(hIMEContext, GCS_COMPSTR, sIMECompUnicode);
|
2000-04-13 22:23:04 +00:00
|
|
|
|
2005-06-25 04:43:04 +00:00
|
|
|
// See https://bugzilla.mozilla.org/show_bug.cgi?id=296339
|
|
|
|
if (sIMECompUnicode->IsEmpty() &&
|
|
|
|
!startCompositionMessageHasBeenSent) {
|
|
|
|
// In this case, maybe, the sender is MSPinYin. That sends *only*
|
|
|
|
// WM_IME_COMPOSITION with GCS_COMP* and GCS_RESULT* when
|
|
|
|
// user inputted the Chinese full stop. So, that doesn't send
|
|
|
|
// WM_IME_STARTCOMPOSITION and WM_IME_ENDCOMPOSITION.
|
|
|
|
// If WM_IME_STARTCOMPOSITION was not sent and the composition
|
|
|
|
// string is null (it indicates the composition transaction ended),
|
|
|
|
// WM_IME_ENDCOMPOSITION may not be sent. If so, we cannot run
|
|
|
|
// HandleEndComposition() in other place.
|
|
|
|
#ifdef DEBUG_IME
|
|
|
|
printf("Aborting GCS_COMPSTR\n");
|
|
|
|
#endif
|
|
|
|
HandleEndComposition();
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
#ifdef DEBUG_IME
|
2005-03-02 08:03:13 +00:00
|
|
|
printf("GCS_COMPSTR compStrLen = %d\n", sIMECompUnicode->Length());
|
2004-09-08 19:30:22 +00:00
|
|
|
#endif
|
1999-11-30 22:09:28 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
//--------------------------------------------------------
|
|
|
|
// 2. Get GCS_COMPCLAUSE
|
|
|
|
//--------------------------------------------------------
|
2004-09-08 19:30:22 +00:00
|
|
|
long compClauseLen, compClauseLen2;
|
2006-04-04 20:57:13 +00:00
|
|
|
compClauseLen = ::ImmGetCompositionStringW(hIMEContext, GCS_COMPCLAUSE, NULL, 0);
|
2005-03-02 08:03:13 +00:00
|
|
|
#ifdef DEBUG_IME
|
|
|
|
printf("GCS_COMPCLAUSE compClauseLen = %d\n", compClauseLen);
|
|
|
|
#endif
|
2004-09-08 19:30:22 +00:00
|
|
|
compClauseLen = compClauseLen / sizeof(PRUint32);
|
|
|
|
|
|
|
|
if (compClauseLen > sIMECompClauseArraySize) {
|
|
|
|
if (sIMECompClauseArray)
|
|
|
|
delete [] sIMECompClauseArray;
|
|
|
|
// Allocate some extra space to avoid reallocations.
|
|
|
|
sIMECompClauseArray = new PRUint32[compClauseLen + 32];
|
|
|
|
sIMECompClauseArraySize = compClauseLen + 32;
|
|
|
|
}
|
2000-04-13 22:23:04 +00:00
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
compClauseLen2 = ::ImmGetCompositionStringW(hIMEContext, GCS_COMPCLAUSE, sIMECompClauseArray,
|
|
|
|
sIMECompClauseArraySize * sizeof(PRUint32));
|
2000-04-13 22:23:04 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
compClauseLen2 = compClauseLen2 / sizeof(PRUint32);
|
|
|
|
NS_ASSERTION(compClauseLen2 == compClauseLen, "strange result");
|
|
|
|
if (compClauseLen > compClauseLen2)
|
|
|
|
compClauseLen = compClauseLen2;
|
2004-09-08 19:30:22 +00:00
|
|
|
sIMECompClauseArrayLength = compClauseLen;
|
2004-09-03 08:44:23 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------------
|
2004-09-08 19:30:22 +00:00
|
|
|
// 3. Get GCS_COMPATTR
|
2004-09-03 08:44:23 +00:00
|
|
|
//--------------------------------------------------------
|
2004-09-08 19:30:22 +00:00
|
|
|
// This provides us with the attribute string necessary
|
|
|
|
// for doing hiliting
|
|
|
|
long attrStrLen;
|
2006-04-04 20:57:13 +00:00
|
|
|
attrStrLen = ::ImmGetCompositionStringW(hIMEContext, GCS_COMPATTR, NULL, 0);
|
2005-03-02 08:03:13 +00:00
|
|
|
#ifdef DEBUG_IME
|
|
|
|
printf("GCS_COMPATTR attrStrLen = %d\n", attrStrLen);
|
|
|
|
#endif
|
2004-09-08 19:30:22 +00:00
|
|
|
if (attrStrLen > sIMEAttributeArraySize) {
|
|
|
|
if (sIMEAttributeArray)
|
|
|
|
delete [] sIMEAttributeArray;
|
|
|
|
// Allocate some extra space to avoid reallocations.
|
|
|
|
sIMEAttributeArray = new PRUint8[attrStrLen + 64];
|
|
|
|
sIMEAttributeArraySize = attrStrLen + 64;
|
|
|
|
}
|
2006-04-04 20:57:13 +00:00
|
|
|
attrStrLen = ::ImmGetCompositionStringW(hIMEContext, GCS_COMPATTR, sIMEAttributeArray, sIMEAttributeArraySize);
|
2004-09-08 19:30:22 +00:00
|
|
|
|
|
|
|
sIMEAttributeArrayLength = attrStrLen;
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
//--------------------------------------------------------
|
2004-09-08 19:30:22 +00:00
|
|
|
// 4. Get GCS_CURSOPOS
|
2004-09-03 08:44:23 +00:00
|
|
|
//--------------------------------------------------------
|
2006-04-04 20:57:13 +00:00
|
|
|
sIMECursorPosition = ::ImmGetCompositionStringW(hIMEContext, GCS_CURSORPOS, NULL, 0);
|
2004-09-08 19:30:22 +00:00
|
|
|
|
2005-06-25 04:43:04 +00:00
|
|
|
NS_ASSERTION(sIMECursorPosition <= sIMECompUnicode->Length(), "illegal pos");
|
|
|
|
|
|
|
|
#ifdef DEBUG_IME
|
|
|
|
printf("sIMECursorPosition(Unicode): %d\n", sIMECursorPosition);
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
//--------------------------------------------------------
|
2004-09-08 19:30:22 +00:00
|
|
|
// 5. Send the text event
|
2004-09-03 08:44:23 +00:00
|
|
|
//--------------------------------------------------------
|
|
|
|
HandleTextEvent(hIMEContext);
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
2004-09-08 19:30:22 +00:00
|
|
|
if (!result) {
|
1999-11-11 22:28:52 +00:00
|
|
|
#ifdef DEBUG_IME
|
2004-09-08 19:30:22 +00:00
|
|
|
fprintf(stderr,"Haandle 0 length TextEvent. \n");
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
2004-09-08 19:30:22 +00:00
|
|
|
if (!sIMEIsComposing)
|
2004-09-03 08:44:23 +00:00
|
|
|
HandleStartComposition(hIMEContext);
|
1999-11-11 22:28:52 +00:00
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
sIMECompUnicode->Truncate();
|
2004-09-03 08:44:23 +00:00
|
|
|
HandleTextEvent(hIMEContext, PR_FALSE);
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
2000-01-07 00:34:34 +00:00
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
::ImmReleaseContext(mWnd, hIMEContext);
|
2004-09-03 08:44:23 +00:00
|
|
|
return result;
|
1999-11-11 22:28:52 +00:00
|
|
|
}
|
|
|
|
//==========================================================================
|
2004-09-03 08:44:23 +00:00
|
|
|
BOOL nsWindow::OnIMECompositionFull()
|
1999-11-11 22:28:52 +00:00
|
|
|
{
|
1999-11-30 22:09:28 +00:00
|
|
|
#ifdef DEBUG_IME2
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("OnIMECompositionFull\n");
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// not implement yet
|
|
|
|
return PR_FALSE;
|
1999-11-11 22:28:52 +00:00
|
|
|
}
|
|
|
|
//==========================================================================
|
2004-09-03 08:44:23 +00:00
|
|
|
BOOL nsWindow::OnIMEEndComposition()
|
1999-11-11 22:28:52 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG_IME
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("OnIMEEndComposition\n");
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
2004-09-08 19:30:22 +00:00
|
|
|
if (sIMEIsComposing) {
|
2004-09-03 08:44:23 +00:00
|
|
|
HIMC hIMEContext;
|
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
if (sIMEProperty & (IME_PROP_SPECIAL_UI | IME_PROP_AT_CARET))
|
2004-09-03 08:44:23 +00:00
|
|
|
return PR_FALSE;
|
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
hIMEContext = ::ImmGetContext(mWnd);
|
2004-09-08 19:30:22 +00:00
|
|
|
if (hIMEContext==NULL)
|
2004-09-03 08:44:23 +00:00
|
|
|
return PR_TRUE;
|
|
|
|
|
|
|
|
// IME on Korean NT somehow send WM_IME_ENDCOMPOSITION
|
|
|
|
// first when we hit space in composition mode
|
|
|
|
// we need to clear out the current composition string
|
|
|
|
// in that case.
|
2004-09-08 19:30:22 +00:00
|
|
|
sIMECompUnicode->Truncate(0);
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
HandleTextEvent(hIMEContext, PR_FALSE);
|
1999-11-11 22:28:52 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
HandleEndComposition();
|
2006-04-04 20:57:13 +00:00
|
|
|
::ImmReleaseContext(mWnd, hIMEContext);
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
|
|
|
return PR_TRUE;
|
1999-11-11 22:28:52 +00:00
|
|
|
}
|
|
|
|
//==========================================================================
|
2004-09-03 08:44:23 +00:00
|
|
|
BOOL nsWindow::OnIMENotify(WPARAM aIMN, LPARAM aData, LRESULT *oResult)
|
1999-11-11 22:28:52 +00:00
|
|
|
{
|
1999-11-30 22:09:28 +00:00
|
|
|
#ifdef DEBUG_IME2
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("OnIMENotify ");
|
|
|
|
switch (aIMN) {
|
|
|
|
case IMN_CHANGECANDIDATE:
|
|
|
|
printf("IMN_CHANGECANDIDATE %x\n", aData);
|
|
|
|
break;
|
|
|
|
case IMN_CLOSECANDIDATE:
|
|
|
|
printf("IMN_CLOSECANDIDATE %x\n", aData);
|
|
|
|
break;
|
|
|
|
case IMN_CLOSESTATUSWINDOW:
|
|
|
|
printf("IMN_CLOSESTATUSWINDOW\n");
|
|
|
|
break;
|
|
|
|
case IMN_GUIDELINE:
|
|
|
|
printf("IMN_GUIDELINE\n");
|
|
|
|
break;
|
|
|
|
case IMN_OPENCANDIDATE:
|
|
|
|
printf("IMN_OPENCANDIDATE %x\n", aData);
|
|
|
|
break;
|
|
|
|
case IMN_OPENSTATUSWINDOW:
|
|
|
|
printf("IMN_OPENSTATUSWINDOW\n");
|
|
|
|
break;
|
|
|
|
case IMN_SETCANDIDATEPOS:
|
|
|
|
printf("IMN_SETCANDIDATEPOS %x\n", aData);
|
|
|
|
break;
|
|
|
|
case IMN_SETCOMPOSITIONFONT:
|
|
|
|
printf("IMN_SETCOMPOSITIONFONT\n");
|
|
|
|
break;
|
|
|
|
case IMN_SETCOMPOSITIONWINDOW:
|
|
|
|
printf("IMN_SETCOMPOSITIONWINDOW\n");
|
|
|
|
break;
|
|
|
|
case IMN_SETCONVERSIONMODE:
|
|
|
|
printf("IMN_SETCONVERSIONMODE\n");
|
|
|
|
break;
|
|
|
|
case IMN_SETOPENSTATUS:
|
|
|
|
printf("IMN_SETOPENSTATUS\n");
|
|
|
|
break;
|
|
|
|
case IMN_SETSENTENCEMODE:
|
|
|
|
printf("IMN_SETSENTENCEMODE\n");
|
|
|
|
break;
|
|
|
|
case IMN_SETSTATUSWINDOWPOS:
|
|
|
|
printf("IMN_SETSTATUSWINDOWPOS\n");
|
|
|
|
break;
|
|
|
|
case IMN_PRIVATE:
|
|
|
|
printf("IMN_PRIVATE\n");
|
|
|
|
break;
|
|
|
|
};
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
|
|
|
|
2000-03-04 00:27:16 +00:00
|
|
|
// add hacky code here
|
2004-04-18 11:03:51 +00:00
|
|
|
if (IS_VK_DOWN(NS_VK_ALT)) {
|
|
|
|
mIsShiftDown = PR_FALSE;
|
|
|
|
mIsControlDown = PR_FALSE;
|
|
|
|
mIsAltDown = PR_TRUE;
|
|
|
|
|
|
|
|
DispatchKeyEvent(NS_KEY_PRESS, 0, 192, 0); // XXX hack hack hack
|
|
|
|
if (aIMN == IMN_SETOPENSTATUS)
|
2004-09-08 19:30:22 +00:00
|
|
|
sIMEIsStatusChanged = PR_TRUE;
|
2000-03-04 00:27:16 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
// not implemented yet
|
2004-04-18 11:03:51 +00:00
|
|
|
return PR_FALSE;
|
1999-11-11 22:28:52 +00:00
|
|
|
}
|
|
|
|
//==========================================================================
|
2006-04-04 20:57:13 +00:00
|
|
|
BOOL nsWindow::OnIMERequest(WPARAM aIMR, LPARAM aData, LRESULT *oResult)
|
1999-11-11 22:28:52 +00:00
|
|
|
{
|
2000-08-04 21:43:29 +00:00
|
|
|
#ifdef DEBUG_IME
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("OnIMERequest\n");
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
2000-08-04 21:43:29 +00:00
|
|
|
PRBool result = PR_FALSE;
|
2004-09-03 08:44:23 +00:00
|
|
|
|
|
|
|
switch (aIMR) {
|
2000-08-04 21:43:29 +00:00
|
|
|
case IMR_RECONVERTSTRING:
|
2006-04-04 20:57:13 +00:00
|
|
|
result = OnIMEReconvert(aData, oResult);
|
2000-08-04 21:43:29 +00:00
|
|
|
break;
|
2005-02-01 19:24:59 +00:00
|
|
|
case IMR_QUERYCHARPOSITION:
|
2006-04-04 20:57:13 +00:00
|
|
|
result = OnIMEQueryCharPosition(aData, oResult);
|
2005-02-01 19:24:59 +00:00
|
|
|
break;
|
2000-08-04 21:43:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
2006-04-04 20:57:13 +00:00
|
|
|
PRBool nsWindow::OnIMEReconvert(LPARAM aData, LRESULT *oResult)
|
2000-08-04 21:43:29 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG_IME
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("OnIMEReconvert\n");
|
2000-08-04 21:43:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
RECONVERTSTRING* pReconv = (RECONVERTSTRING*) aData;
|
|
|
|
int len = 0;
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
if (!pReconv) {
|
2000-08-04 21:43:29 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// When reconvert, it must return need size to reconvert.
|
|
|
|
//
|
2004-09-08 19:30:22 +00:00
|
|
|
if (sIMEReconvertUnicode) {
|
|
|
|
nsMemory::Free(sIMEReconvertUnicode);
|
|
|
|
sIMEReconvertUnicode = NULL;
|
2000-08-04 21:43:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get reconversion string
|
2005-04-28 23:48:28 +00:00
|
|
|
nsReconversionEvent event(PR_TRUE, NS_RECONVERSION_QUERY, this);
|
2004-01-12 08:25:18 +00:00
|
|
|
nsPoint point(0, 0);
|
2000-08-04 21:43:29 +00:00
|
|
|
|
2004-01-12 08:25:18 +00:00
|
|
|
InitEvent(event, &point);
|
2000-08-04 21:43:29 +00:00
|
|
|
event.theReply.mReconversionString = NULL;
|
|
|
|
DispatchWindowEvent(&event);
|
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
sIMEReconvertUnicode = event.theReply.mReconversionString;
|
2000-08-04 21:43:29 +00:00
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
|
|
|
|
// Return need size
|
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
if (sIMEReconvertUnicode) {
|
2006-04-04 20:57:13 +00:00
|
|
|
len = nsCRT::strlen(sIMEReconvertUnicode);
|
|
|
|
*oResult = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR);
|
2000-08-04 21:43:29 +00:00
|
|
|
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//
|
|
|
|
// Fill reconvert struct
|
|
|
|
//
|
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
len = nsCRT::strlen(sIMEReconvertUnicode);
|
|
|
|
*oResult = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR);
|
2000-08-04 21:43:29 +00:00
|
|
|
|
2005-05-05 07:16:26 +00:00
|
|
|
if (pReconv->dwSize < *oResult) {
|
|
|
|
*oResult = 0;
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD tmpSize = pReconv->dwSize;
|
|
|
|
::ZeroMemory(pReconv, tmpSize);
|
|
|
|
pReconv->dwSize = tmpSize;
|
2000-08-04 21:43:29 +00:00
|
|
|
pReconv->dwVersion = 0;
|
|
|
|
pReconv->dwStrLen = len;
|
|
|
|
pReconv->dwStrOffset = sizeof(RECONVERTSTRING);
|
|
|
|
pReconv->dwCompStrLen = len;
|
|
|
|
pReconv->dwCompStrOffset = 0;
|
|
|
|
pReconv->dwTargetStrLen = len;
|
|
|
|
pReconv->dwTargetStrOffset = 0;
|
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
::CopyMemory((LPVOID) (aData + sizeof(RECONVERTSTRING)),
|
|
|
|
sIMEReconvertUnicode, len * sizeof(WCHAR));
|
2000-08-04 21:43:29 +00:00
|
|
|
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
1999-11-11 22:28:52 +00:00
|
|
|
}
|
2000-08-04 21:43:29 +00:00
|
|
|
|
2005-02-01 19:24:59 +00:00
|
|
|
//==========================================================================
|
2006-04-04 20:57:13 +00:00
|
|
|
PRBool nsWindow::OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult)
|
2005-02-01 19:24:59 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG_IME
|
|
|
|
printf("OnIMEQueryCharPosition\n");
|
|
|
|
#endif
|
|
|
|
IMECHARPOSITION* pCharPosition = (IMECHARPOSITION*)aData;
|
|
|
|
if (!pCharPosition ||
|
|
|
|
pCharPosition->dwSize < sizeof(IMECHARPOSITION) ||
|
|
|
|
::GetFocus() != mWnd) {
|
|
|
|
*oResult = FALSE;
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sIMEIsComposing) { // Including |!sIMECompUnicode| and |!sIMECompUnicode->IsEmpty|.
|
|
|
|
if (pCharPosition->dwCharPos != 0) {
|
|
|
|
*oResult = FALSE;
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
nsPoint point(0, 0);
|
2005-04-28 23:48:28 +00:00
|
|
|
nsQueryCaretRectEvent event(PR_TRUE, NS_QUERYCARETRECT, this);
|
2005-02-01 19:24:59 +00:00
|
|
|
InitEvent(event, &point);
|
|
|
|
DispatchWindowEvent(&event);
|
2005-03-18 06:17:59 +00:00
|
|
|
// The active widget doesn't support this event.
|
|
|
|
if (!event.theReply.mRectIsValid) {
|
|
|
|
*oResult = FALSE;
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2005-02-01 19:24:59 +00:00
|
|
|
NS_RELEASE(event.widget);
|
|
|
|
|
2005-11-18 05:29:52 +00:00
|
|
|
nsRect screenRect;
|
|
|
|
ResolveIMECaretPos(nsnull, event.theReply.mCaretRect, screenRect);
|
2005-02-01 19:24:59 +00:00
|
|
|
pCharPosition->pt.x = screenRect.x;
|
|
|
|
pCharPosition->pt.y = screenRect.y;
|
|
|
|
|
|
|
|
pCharPosition->cLineHeight = event.theReply.mCaretRect.height;
|
|
|
|
|
|
|
|
::GetWindowRect(mWnd, &pCharPosition->rcDocument);
|
|
|
|
|
|
|
|
*oResult = TRUE;
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2005-03-18 06:17:59 +00:00
|
|
|
// If the char positions are not cached, we should not return the values by LPARAM.
|
|
|
|
// Because in this case, the active widget is not editor.
|
|
|
|
if (!sIMECompCharPos) {
|
|
|
|
*oResult = FALSE;
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2005-02-01 19:24:59 +00:00
|
|
|
long charPosition;
|
2006-04-04 20:57:13 +00:00
|
|
|
if (pCharPosition->dwCharPos > sIMECompUnicode->Length()) {
|
|
|
|
*oResult = FALSE;
|
|
|
|
return PR_FALSE;
|
2005-02-01 19:24:59 +00:00
|
|
|
}
|
2006-04-04 20:57:13 +00:00
|
|
|
charPosition = pCharPosition->dwCharPos;
|
|
|
|
|
2005-02-01 19:24:59 +00:00
|
|
|
// We only support insertion at the cursor position or at the leftmost position.
|
|
|
|
// Because sIMECompCharPos may be broken by user converting the string.
|
|
|
|
// But leftmost position and cursor position is always correctly.
|
|
|
|
if ((charPosition != 0 && charPosition != sIMECursorPosition) ||
|
|
|
|
charPosition > IME_MAX_CHAR_POS) {
|
|
|
|
*oResult = FALSE;
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
POINT pt;
|
|
|
|
pt.x = sIMECompCharPos[charPosition].left;
|
|
|
|
pt.y = sIMECompCharPos[charPosition].top;
|
|
|
|
::ClientToScreen(mWnd, &pt);
|
|
|
|
pCharPosition->pt = pt;
|
|
|
|
|
|
|
|
pCharPosition->cLineHeight = sIMECaretHeight;
|
|
|
|
|
|
|
|
::GetWindowRect(mWnd, &pCharPosition->rcDocument);
|
|
|
|
|
|
|
|
*oResult = TRUE;
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2005-11-18 05:29:52 +00:00
|
|
|
//==========================================================================
|
|
|
|
void
|
|
|
|
nsWindow::ResolveIMECaretPos(nsWindow* aClient,
|
|
|
|
nsRect& aEventResult,
|
|
|
|
nsRect& aResult)
|
|
|
|
{
|
|
|
|
// RootView coordinates -> Screen coordinates
|
2007-06-29 17:21:55 +00:00
|
|
|
GetTopLevelWindow()->WidgetToScreen(aEventResult, aResult);
|
2005-11-18 05:29:52 +00:00
|
|
|
// if aClient is nsnull, returns screen coordinates
|
|
|
|
if (!aClient)
|
|
|
|
return;
|
|
|
|
// screen coordinates -> client coordinates
|
|
|
|
aClient->ScreenToWidget(aResult, aResult);
|
|
|
|
}
|
|
|
|
|
1999-11-11 22:28:52 +00:00
|
|
|
//==========================================================================
|
2004-09-03 08:44:23 +00:00
|
|
|
BOOL nsWindow::OnIMESelect(BOOL aSelected, WORD aLangID)
|
1999-11-11 22:28:52 +00:00
|
|
|
{
|
1999-11-30 22:09:28 +00:00
|
|
|
#ifdef DEBUG_IME2
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("OnIMESelect\n");
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// not implement yet
|
|
|
|
return PR_FALSE;
|
1999-11-11 22:28:52 +00:00
|
|
|
}
|
|
|
|
//==========================================================================
|
2004-09-03 08:44:23 +00:00
|
|
|
BOOL nsWindow::OnIMESetContext(BOOL aActive, LPARAM& aISC)
|
1999-11-11 22:28:52 +00:00
|
|
|
{
|
1999-11-30 22:09:28 +00:00
|
|
|
#ifdef DEBUG_IME2
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("OnIMESetContext %x %s %s %s Candidate[%s%s%s%s]\n", this,
|
|
|
|
(aActive ? "Active" : "Deactiv"),
|
|
|
|
((aISC & ISC_SHOWUICOMPOSITIONWINDOW) ? "[Comp]" : ""),
|
|
|
|
((aISC & ISC_SHOWUIGUIDELINE) ? "[GUID]" : ""),
|
|
|
|
((aISC & ISC_SHOWUICANDIDATEWINDOW) ? "0" : ""),
|
|
|
|
((aISC & (ISC_SHOWUICANDIDATEWINDOW<<1)) ? "1" : ""),
|
|
|
|
((aISC & (ISC_SHOWUICANDIDATEWINDOW<<2)) ? "2" : ""),
|
|
|
|
((aISC & (ISC_SHOWUICANDIDATEWINDOW<<3)) ? "3" : ""));
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
if (! aActive)
|
|
|
|
ResetInputState();
|
1999-11-11 22:28:52 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
aISC &= ~ISC_SHOWUICOMPOSITIONWINDOW;
|
2002-05-23 22:03:49 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// We still return false here because we need to pass the
|
|
|
|
// aISC w/ ISC_SHOWUICOMPOSITIONWINDOW clear to the default
|
|
|
|
// window proc so it will draw the candidcate window for us...
|
|
|
|
return PR_FALSE;
|
1999-11-11 22:28:52 +00:00
|
|
|
}
|
|
|
|
//==========================================================================
|
|
|
|
BOOL nsWindow::OnIMEStartComposition()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_IME
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("OnIMEStartComposition\n");
|
1999-11-11 22:28:52 +00:00
|
|
|
#endif
|
2004-09-03 08:44:23 +00:00
|
|
|
HIMC hIMEContext;
|
1999-11-11 22:28:52 +00:00
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
if (sIMEProperty & (IME_PROP_SPECIAL_UI | IME_PROP_AT_CARET))
|
2004-09-03 08:44:23 +00:00
|
|
|
return PR_FALSE;
|
1999-11-11 22:28:52 +00:00
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
hIMEContext = ::ImmGetContext(mWnd);
|
2004-09-03 08:44:23 +00:00
|
|
|
if (hIMEContext == NULL)
|
|
|
|
return PR_TRUE;
|
1999-11-11 22:28:52 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
PRBool rtn = HandleStartComposition(hIMEContext);
|
2006-04-04 20:57:13 +00:00
|
|
|
::ImmReleaseContext(mWnd, hIMEContext);
|
2004-09-03 08:44:23 +00:00
|
|
|
return rtn;
|
1999-11-11 22:28:52 +00:00
|
|
|
}
|
1999-11-15 20:57:41 +00:00
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
NS_IMETHODIMP nsWindow::ResetInputState()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_KBSTATE
|
2004-09-03 08:44:23 +00:00
|
|
|
printf("ResetInputState\n");
|
|
|
|
#endif
|
2006-04-04 20:57:13 +00:00
|
|
|
HIMC hIMC = ::ImmGetContext(mWnd);
|
2004-09-03 08:44:23 +00:00
|
|
|
if (hIMC) {
|
|
|
|
BOOL ret = FALSE;
|
2006-04-04 20:57:13 +00:00
|
|
|
ret = ::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, NULL);
|
|
|
|
ret = ::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, NULL);
|
2004-09-03 08:44:23 +00:00
|
|
|
//NS_ASSERTION(ret, "ImmNotify failed");
|
2006-04-04 20:57:13 +00:00
|
|
|
::ImmReleaseContext(mWnd, hIMC);
|
2004-09-08 19:30:22 +00:00
|
|
|
}
|
2004-09-03 08:44:23 +00:00
|
|
|
return NS_OK;
|
1999-11-15 20:57:41 +00:00
|
|
|
}
|
2000-08-04 21:43:29 +00:00
|
|
|
|
2004-09-12 05:00:57 +00:00
|
|
|
//==========================================================================
|
|
|
|
NS_IMETHODIMP nsWindow::SetIMEOpenState(PRBool aState)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_KBSTATE
|
2004-11-13 11:27:09 +00:00
|
|
|
printf("SetIMEOpenState %s\n", (aState ? "Open" : "Close"));
|
2004-09-12 05:00:57 +00:00
|
|
|
#endif
|
2006-04-04 20:57:13 +00:00
|
|
|
HIMC hIMC = ::ImmGetContext(mWnd);
|
2004-09-12 05:00:57 +00:00
|
|
|
if (hIMC) {
|
2006-04-04 20:57:13 +00:00
|
|
|
::ImmSetOpenStatus(hIMC, aState ? TRUE : FALSE);
|
|
|
|
::ImmReleaseContext(mWnd, hIMC);
|
2004-09-12 05:00:57 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
NS_IMETHODIMP nsWindow::GetIMEOpenState(PRBool* aState)
|
|
|
|
{
|
2006-04-04 20:57:13 +00:00
|
|
|
HIMC hIMC = ::ImmGetContext(mWnd);
|
2004-09-12 05:00:57 +00:00
|
|
|
if (hIMC) {
|
2006-04-04 20:57:13 +00:00
|
|
|
BOOL isOpen = ::ImmGetOpenStatus(hIMC);
|
2004-09-12 05:00:57 +00:00
|
|
|
*aState = isOpen ? PR_TRUE : PR_FALSE;
|
2006-04-04 20:57:13 +00:00
|
|
|
::ImmReleaseContext(mWnd, hIMC);
|
2004-09-12 05:00:57 +00:00
|
|
|
} else
|
|
|
|
*aState = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-08-23 14:32:09 +00:00
|
|
|
//==========================================================================
|
2007-04-15 13:43:55 +00:00
|
|
|
NS_IMETHODIMP nsWindow::SetIMEEnabled(PRUint32 aState)
|
2005-08-23 14:32:09 +00:00
|
|
|
{
|
|
|
|
if (sIMEIsComposing)
|
|
|
|
ResetInputState();
|
2007-04-15 13:43:55 +00:00
|
|
|
mIMEEnabled = aState;
|
|
|
|
PRBool enable = (aState == nsIKBStateControl::IME_STATUS_ENABLED);
|
|
|
|
if (!enable != !mOldIMC)
|
2005-11-17 16:33:57 +00:00
|
|
|
return NS_OK;
|
2007-04-15 13:43:55 +00:00
|
|
|
mOldIMC = ::ImmAssociateContext(mWnd, enable ? mOldIMC : NULL);
|
|
|
|
NS_ASSERTION(!enable || !mOldIMC, "Another IMC was associated");
|
2005-08-23 14:32:09 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
2007-04-15 13:43:55 +00:00
|
|
|
NS_IMETHODIMP nsWindow::GetIMEEnabled(PRUint32* aState)
|
2005-08-23 14:32:09 +00:00
|
|
|
{
|
2007-04-15 13:43:55 +00:00
|
|
|
*aState = mIMEEnabled;
|
2005-08-23 14:32:09 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-11-13 11:27:09 +00:00
|
|
|
//==========================================================================
|
|
|
|
NS_IMETHODIMP nsWindow::CancelIMEComposition()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_KBSTATE
|
|
|
|
printf("CancelIMEComposition\n");
|
|
|
|
#endif
|
2006-04-04 20:57:13 +00:00
|
|
|
HIMC hIMC = ::ImmGetContext(mWnd);
|
2004-11-13 11:27:09 +00:00
|
|
|
if (hIMC) {
|
|
|
|
BOOL ret = FALSE;
|
2006-04-04 20:57:13 +00:00
|
|
|
ret = ::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, NULL);
|
|
|
|
::ImmReleaseContext(mWnd, hIMC);
|
2004-11-13 11:27:09 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-06-16 19:19:46 +00:00
|
|
|
//==========================================================================
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::GetToggledKeyState(PRUint32 aKeyCode, PRBool* aLEDState)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_KBSTATE
|
|
|
|
printf("GetToggledKeyState\n");
|
|
|
|
#endif
|
|
|
|
NS_ENSURE_ARG_POINTER(aLEDState);
|
|
|
|
*aLEDState = (::GetKeyState(aKeyCode) & 1) != 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-08-04 21:43:29 +00:00
|
|
|
|
2002-10-01 02:47:41 +00:00
|
|
|
#define PT_IN_RECT(pt, rc) ((pt).x>(rc).left && (pt).x <(rc).right && (pt).y>(rc).top && (pt).y<(rc).bottom)
|
|
|
|
|
2000-08-04 21:43:29 +00:00
|
|
|
// Mouse operation of IME
|
2004-09-03 08:44:23 +00:00
|
|
|
PRBool
|
2006-11-16 21:35:39 +00:00
|
|
|
nsWindow::IMEMouseHandling(PRInt32 aAction, LPARAM lParam)
|
2002-10-01 02:47:41 +00:00
|
|
|
{
|
2006-04-18 18:31:26 +00:00
|
|
|
#ifndef WINCE
|
2002-10-01 02:47:41 +00:00
|
|
|
POINT ptPos;
|
|
|
|
ptPos.x = (short)LOWORD(lParam);
|
|
|
|
ptPos.y = (short)HIWORD(lParam);
|
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
if (sIMEIsComposing && nsWindow::uWM_MSIME_MOUSE) {
|
2006-11-16 21:35:39 +00:00
|
|
|
if (IMECompositionHitTest(&ptPos))
|
2002-10-01 02:47:41 +00:00
|
|
|
if (HandleMouseActionOfIME(aAction, &ptPos))
|
|
|
|
return PR_TRUE;
|
|
|
|
} else {
|
|
|
|
HWND parentWnd = ::GetParent(mWnd);
|
|
|
|
if (parentWnd) {
|
|
|
|
nsWindow* parentWidget = GetNSWindowPtr(parentWnd);
|
2004-09-08 19:30:22 +00:00
|
|
|
if (parentWidget && parentWidget->sIMEIsComposing && nsWindow::uWM_MSIME_MOUSE) {
|
2006-11-16 21:35:39 +00:00
|
|
|
if (parentWidget->IMECompositionHitTest(&ptPos))
|
2002-10-01 02:47:41 +00:00
|
|
|
if (parentWidget->HandleMouseActionOfIME(aAction, &ptPos))
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-18 18:31:26 +00:00
|
|
|
#endif
|
2002-10-01 02:47:41 +00:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-04 21:43:29 +00:00
|
|
|
PRBool
|
2002-10-01 02:47:41 +00:00
|
|
|
nsWindow::HandleMouseActionOfIME(int aAction, POINT *ptPos)
|
2000-08-04 21:43:29 +00:00
|
|
|
{
|
|
|
|
PRBool IsHandle = PR_FALSE;
|
|
|
|
|
2000-09-22 01:06:51 +00:00
|
|
|
if (mWnd) {
|
2006-04-04 20:57:13 +00:00
|
|
|
HIMC hIMC = ::ImmGetContext(mWnd);
|
2000-08-04 21:43:29 +00:00
|
|
|
if (hIMC) {
|
|
|
|
int positioning = 0;
|
|
|
|
int offset = 0;
|
|
|
|
|
|
|
|
// calcurate positioning and offset
|
2002-10-01 02:47:41 +00:00
|
|
|
// char : JCH1|JCH2|JCH3
|
|
|
|
// offset: 0011 1122 2233
|
|
|
|
// positioning: 2301 2301 2301
|
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
// Note: hitText has been done, so no check of sIMECompCharPos
|
2002-10-01 02:47:41 +00:00
|
|
|
// and composing char maximum limit is necessary.
|
2004-04-18 11:03:51 +00:00
|
|
|
PRUint32 i = 0;
|
2004-09-08 19:30:22 +00:00
|
|
|
for (i = 0; i < sIMECompUnicode->Length(); i++) {
|
|
|
|
if (PT_IN_RECT(*ptPos, sIMECompCharPos[i]))
|
2002-10-01 02:47:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
offset = i;
|
2004-09-08 19:30:22 +00:00
|
|
|
if (ptPos->x - sIMECompCharPos[i].left > sIMECompCharPos[i].right - ptPos->x)
|
2002-10-01 02:47:41 +00:00
|
|
|
offset++;
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
positioning = (ptPos->x - sIMECompCharPos[i].left) * 4 /
|
|
|
|
(sIMECompCharPos[i].right - sIMECompCharPos[i].left);
|
2002-10-01 02:47:41 +00:00
|
|
|
positioning = (positioning + 2) % 4;
|
2000-08-04 21:43:29 +00:00
|
|
|
|
|
|
|
// send MS_MSIME_MOUSE message to default IME window.
|
2006-04-04 20:57:13 +00:00
|
|
|
HWND imeWnd = ::ImmGetDefaultIMEWnd(mWnd);
|
|
|
|
if (::SendMessageW(imeWnd, nsWindow::uWM_MSIME_MOUSE,
|
|
|
|
MAKELONG(MAKEWORD(aAction, positioning), offset),
|
|
|
|
(LPARAM) hIMC) == 1)
|
2000-08-04 21:43:29 +00:00
|
|
|
IsHandle = PR_TRUE;
|
2004-09-03 08:44:23 +00:00
|
|
|
}
|
2006-04-04 20:57:13 +00:00
|
|
|
::ImmReleaseContext(mWnd, hIMC);
|
2000-08-04 21:43:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return IsHandle;
|
|
|
|
}
|
2000-09-22 01:06:51 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
//The coordinate is relative to the upper-left corner of the client area.
|
2006-11-16 21:35:39 +00:00
|
|
|
PRBool nsWindow::IMECompositionHitTest(POINT * ptPos)
|
2000-09-22 01:06:51 +00:00
|
|
|
{
|
|
|
|
PRBool IsHit = PR_FALSE;
|
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
if (sIMECompCharPos){
|
2004-09-03 08:44:23 +00:00
|
|
|
// figure out how many char in composing string,
|
2002-10-01 02:47:41 +00:00
|
|
|
// but keep it below the limit we can handle
|
2004-09-08 19:30:22 +00:00
|
|
|
PRInt32 len = sIMECompUnicode->Length();
|
2002-10-01 02:47:41 +00:00
|
|
|
if (len > IME_MAX_CHAR_POS)
|
|
|
|
len = IME_MAX_CHAR_POS;
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2002-10-01 02:47:41 +00:00
|
|
|
PRInt32 i;
|
|
|
|
PRInt32 aveWidth = 0;
|
|
|
|
// found per char width
|
|
|
|
for (i = 0; i < len; i++) {
|
2004-09-08 19:30:22 +00:00
|
|
|
if (sIMECompCharPos[i].left >= 0 && sIMECompCharPos[i].right > 0) {
|
|
|
|
aveWidth = sIMECompCharPos[i].right - sIMECompCharPos[i].left;
|
2002-10-01 02:47:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// validate each rect and test
|
|
|
|
for (i = 0; i < len; i++) {
|
2004-09-08 19:30:22 +00:00
|
|
|
if (sIMECompCharPos[i].left < 0) {
|
|
|
|
if (i != 0 && sIMECompCharPos[i-1].top == sIMECompCharPos[i].top)
|
|
|
|
sIMECompCharPos[i].left = sIMECompCharPos[i-1].right;
|
2004-09-03 08:44:23 +00:00
|
|
|
else
|
2004-09-08 19:30:22 +00:00
|
|
|
sIMECompCharPos[i].left = sIMECompCharPos[i].right - aveWidth;
|
2002-10-01 02:47:41 +00:00
|
|
|
}
|
2004-09-08 19:30:22 +00:00
|
|
|
if (sIMECompCharPos[i].right < 0)
|
|
|
|
sIMECompCharPos[i].right = sIMECompCharPos[i].left + aveWidth;
|
|
|
|
if (sIMECompCharPos[i].top < 0) {
|
|
|
|
sIMECompCharPos[i].top = sIMECompCharPos[i-1].top;
|
|
|
|
sIMECompCharPos[i].bottom = sIMECompCharPos[i-1].bottom;
|
2002-10-01 02:47:41 +00:00
|
|
|
}
|
|
|
|
|
2004-09-08 19:30:22 +00:00
|
|
|
if (PT_IN_RECT(*ptPos, sIMECompCharPos[i])) {
|
2002-10-01 02:47:41 +00:00
|
|
|
IsHit = PR_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-09-22 01:06:51 +00:00
|
|
|
|
|
|
|
return IsHit;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsWindow::GetCompositionWindowPos(HIMC hIMC, PRUint32 aEventType, COMPOSITIONFORM *cpForm)
|
|
|
|
{
|
2005-04-28 23:48:28 +00:00
|
|
|
nsTextEvent event(PR_TRUE, 0, this);
|
2000-09-22 01:06:51 +00:00
|
|
|
POINT point;
|
|
|
|
point.x = 0;
|
|
|
|
point.y = 0;
|
|
|
|
DWORD pos = ::GetMessagePos();
|
|
|
|
|
2004-05-13 23:13:35 +00:00
|
|
|
point.x = GET_X_LPARAM(pos);
|
|
|
|
point.y = GET_Y_LPARAM(pos);
|
2000-09-22 01:06:51 +00:00
|
|
|
|
|
|
|
if (mWnd != NULL) {
|
|
|
|
::ScreenToClient(mWnd, &point);
|
2005-08-23 03:57:07 +00:00
|
|
|
event.refPoint.x = point.x;
|
|
|
|
event.refPoint.y = point.y;
|
2000-09-22 01:06:51 +00:00
|
|
|
} else {
|
2005-08-23 03:57:07 +00:00
|
|
|
event.refPoint.x = 0;
|
|
|
|
event.refPoint.y = 0;
|
2000-09-22 01:06:51 +00:00
|
|
|
}
|
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
::ImmGetCompositionWindow(hIMC, cpForm);
|
2000-09-22 01:06:51 +00:00
|
|
|
|
|
|
|
cpForm->ptCurrentPos.x = event.theReply.mCursorPosition.x + IME_X_OFFSET;
|
2004-09-03 08:44:23 +00:00
|
|
|
cpForm->ptCurrentPos.y = event.theReply.mCursorPosition.y + IME_Y_OFFSET +
|
|
|
|
event.theReply.mCursorPosition.height;
|
|
|
|
cpForm->rcArea.left = cpForm->ptCurrentPos.x;
|
|
|
|
cpForm->rcArea.top = cpForm->ptCurrentPos.y;
|
|
|
|
cpForm->rcArea.right = cpForm->ptCurrentPos.x + event.theReply.mCursorPosition.width;
|
|
|
|
cpForm->rcArea.bottom = cpForm->ptCurrentPos.y + event.theReply.mCursorPosition.height;
|
2000-09-22 01:06:51 +00:00
|
|
|
}
|
|
|
|
|
1999-12-10 07:20:51 +00:00
|
|
|
// This function is called on a timer to do the flashing. It simply toggles the flash
|
|
|
|
// status until the window comes to the foreground.
|
2004-09-03 08:44:23 +00:00
|
|
|
static VOID CALLBACK nsGetAttentionTimerFunc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
|
|
|
|
{
|
2001-11-16 01:58:17 +00:00
|
|
|
// flash the window until we're in the foreground.
|
|
|
|
if (::GetForegroundWindow() != hwnd)
|
2002-06-29 12:31:15 +00:00
|
|
|
{
|
|
|
|
// flash the outermost owner
|
|
|
|
HWND flashwnd = gAttentionTimerMonitor->GetFlashWindowFor(hwnd);
|
2004-09-03 08:44:23 +00:00
|
|
|
|
2004-02-11 03:46:30 +00:00
|
|
|
PRInt32 maxFlashCount = gAttentionTimerMonitor->GetMaxFlashCount(hwnd);
|
|
|
|
PRInt32 flashCount = gAttentionTimerMonitor->GetFlashCount(hwnd);
|
|
|
|
if (maxFlashCount > 0) {
|
|
|
|
// We have a max flash count, if we haven't met it yet, flash again.
|
|
|
|
if (flashCount < maxFlashCount) {
|
|
|
|
::FlashWindow(flashwnd, TRUE);
|
|
|
|
gAttentionTimerMonitor->IncrementFlashCount(hwnd);
|
|
|
|
}
|
|
|
|
else
|
2004-09-03 08:44:23 +00:00
|
|
|
gAttentionTimerMonitor->KillTimer(hwnd);
|
2004-02-11 03:46:30 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// The caller didn't specify a flash count.
|
|
|
|
::FlashWindow(flashwnd, TRUE);
|
|
|
|
}
|
|
|
|
|
2002-06-29 12:31:15 +00:00
|
|
|
gAttentionTimerMonitor->SetFlashed(hwnd);
|
|
|
|
}
|
2001-11-16 01:58:17 +00:00
|
|
|
else
|
|
|
|
gAttentionTimerMonitor->KillTimer(hwnd);
|
1999-12-10 07:20:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Draw user's attention to this window until it comes to foreground.
|
|
|
|
NS_IMETHODIMP
|
2004-09-03 08:44:23 +00:00
|
|
|
nsWindow::GetAttention(PRInt32 aCycleCount)
|
|
|
|
{
|
2001-11-16 01:58:17 +00:00
|
|
|
// Got window?
|
|
|
|
if (!mWnd)
|
|
|
|
return NS_ERROR_NOT_INITIALIZED;
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// Don't flash if the flash count is 0.
|
2004-02-11 03:46:30 +00:00
|
|
|
if (aCycleCount == 0)
|
|
|
|
return NS_OK;
|
|
|
|
|
2001-11-16 01:58:17 +00:00
|
|
|
// timer is on the parentmost window; window to flash is its ownermost
|
2004-09-03 08:44:23 +00:00
|
|
|
HWND timerwnd = GetTopLevelHWND(mWnd);
|
|
|
|
HWND flashwnd = timerwnd;
|
|
|
|
HWND nextwnd;
|
2001-11-16 01:58:17 +00:00
|
|
|
while ((nextwnd = ::GetWindow(flashwnd, GW_OWNER)) != 0)
|
|
|
|
flashwnd = nextwnd;
|
|
|
|
|
|
|
|
// If window is in foreground, no notification is necessary.
|
|
|
|
if (::GetForegroundWindow() != timerwnd) {
|
|
|
|
// kick off a timer that does single flash until the window comes to the foreground
|
|
|
|
if (!gAttentionTimerMonitor)
|
|
|
|
gAttentionTimerMonitor = new nsAttentionTimerMonitor;
|
|
|
|
if (gAttentionTimerMonitor) {
|
2004-02-11 03:46:30 +00:00
|
|
|
gAttentionTimerMonitor->AddTimer(timerwnd, flashwnd, aCycleCount, NS_FLASH_TIMER_ID);
|
2001-11-16 01:58:17 +00:00
|
|
|
::SetTimer(timerwnd, NS_FLASH_TIMER_ID, GetCaretBlinkTime(), (TIMERPROC)nsGetAttentionTimerFunc);
|
1999-12-10 07:20:51 +00:00
|
|
|
}
|
2001-11-16 01:58:17 +00:00
|
|
|
}
|
1999-12-10 07:20:51 +00:00
|
|
|
|
2001-11-16 01:58:17 +00:00
|
|
|
return NS_OK;
|
1999-12-10 07:20:51 +00:00
|
|
|
}
|
2001-05-25 10:53:32 +00:00
|
|
|
|
2002-10-01 03:04:22 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindow::GetLastInputEventTime(PRUint32& aTime)
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
WORD qstatus = HIWORD(GetQueueStatus(QS_INPUT));
|
2002-10-01 03:04:22 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
// If there is pending input or the user is currently
|
|
|
|
// moving the window then return the current time.
|
|
|
|
// Note: When the user is moving the window WIN32 spins
|
|
|
|
// a separate event loop and input events are not
|
|
|
|
// reported to the application.
|
|
|
|
nsToolkit* toolkit = (nsToolkit *)mToolkit;
|
|
|
|
if (qstatus || (toolkit && toolkit->UserIsMovingWindow())) {
|
|
|
|
gLastInputEventTime = PR_IntervalToMicroseconds(PR_IntervalNow());
|
|
|
|
}
|
2002-10-01 03:04:22 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
aTime = gLastInputEventTime;
|
2002-10-01 03:04:22 +00:00
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
return NS_OK;
|
2002-10-01 03:04:22 +00:00
|
|
|
}
|
|
|
|
|
2001-05-25 10:53:32 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//-------------------------------------------------------------------------
|
2004-09-03 08:44:23 +00:00
|
|
|
//-- NOTE!!! These hook functions can be removed when we migrate to
|
2001-05-25 10:53:32 +00:00
|
|
|
//-- XBL-Form Controls
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//#define DISPLAY_NOISY_MSGF_MSG
|
|
|
|
|
|
|
|
#ifdef DISPLAY_NOISY_MSGF_MSG
|
|
|
|
typedef struct {
|
|
|
|
char * mStr;
|
|
|
|
int mId;
|
|
|
|
} MSGFEventMsgInfo;
|
|
|
|
|
|
|
|
MSGFEventMsgInfo gMSGFEvents[] = {
|
|
|
|
"MSGF_DIALOGBOX", 0,
|
|
|
|
"MSGF_MESSAGEBOX", 1,
|
|
|
|
"MSGF_MENU", 2,
|
|
|
|
"MSGF_SCROLLBAR", 5,
|
|
|
|
"MSGF_NEXTWINDOW", 6,
|
|
|
|
"MSGF_MAX", 8,
|
2004-09-03 08:44:23 +00:00
|
|
|
"MSGF_USER", 4096,
|
2001-05-25 10:53:32 +00:00
|
|
|
NULL, 0};
|
|
|
|
|
|
|
|
void PrintEvent(UINT msg, PRBool aShowAllEvents, PRBool aShowMouseMoves);
|
|
|
|
int gLastMsgCode = 0;
|
|
|
|
|
|
|
|
#define DISPLAY_NMM_PRT(_arg) printf((_arg));
|
|
|
|
#else
|
2004-09-03 08:44:23 +00:00
|
|
|
#define DISPLAY_NMM_PRT(_arg)
|
2001-05-25 10:53:32 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2005-02-23 07:07:51 +00:00
|
|
|
|
|
|
|
#ifndef WINCE
|
|
|
|
|
2001-06-14 02:08:39 +00:00
|
|
|
//-------------------------------------------------------------------------
|
2004-09-03 08:44:23 +00:00
|
|
|
// Schedules a timer for a window, so we can rollup after processing the hook event
|
2001-06-14 02:08:39 +00:00
|
|
|
void nsWindow::ScheduleHookTimer(HWND aWnd, UINT aMsgId)
|
|
|
|
{
|
2004-09-03 08:44:23 +00:00
|
|
|
// In some cases multiple hooks may be scheduled
|
2001-06-14 02:08:39 +00:00
|
|
|
// so ignore any other requests once one timer is scheduled
|
|
|
|
if (gHookTimerId == 0) {
|
2005-01-14 19:23:06 +00:00
|
|
|
// Remember the window handle and the message ID to be used later
|
2001-06-14 02:08:39 +00:00
|
|
|
gRollupMsgId = aMsgId;
|
2005-01-14 19:23:06 +00:00
|
|
|
gRollupMsgWnd = aWnd;
|
2004-09-03 08:44:23 +00:00
|
|
|
// Schedule native timer for doing the rollup after
|
2001-06-14 02:08:39 +00:00
|
|
|
// this event is done being processed
|
2004-09-03 08:44:23 +00:00
|
|
|
gHookTimerId = ::SetTimer(NULL, 0, 0, (TIMERPROC)HookTimerForPopups);
|
2001-06-14 02:08:39 +00:00
|
|
|
NS_ASSERTION(gHookTimerId, "Timer couldn't be created.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-25 10:53:32 +00:00
|
|
|
//-------------------------------------------------------------------------
|
2004-09-03 08:44:23 +00:00
|
|
|
// Process Menu messages
|
2001-05-25 10:53:32 +00:00
|
|
|
// Rollup when when is clicked
|
2005-02-23 07:07:51 +00:00
|
|
|
|
2001-05-25 10:53:32 +00:00
|
|
|
LRESULT CALLBACK nsWindow::MozSpecialMsgFilter(int code, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
#ifdef DISPLAY_NOISY_MSGF_MSG
|
|
|
|
if (gProcessHook) {
|
|
|
|
MSG* pMsg = (MSG*)lParam;
|
|
|
|
|
|
|
|
int inx = 0;
|
|
|
|
while (gMSGFEvents[inx].mId != code && gMSGFEvents[inx].mStr != NULL) {
|
|
|
|
inx++;
|
|
|
|
}
|
|
|
|
if (code != gLastMsgCode) {
|
|
|
|
if (gMSGFEvents[inx].mId == code) {
|
2001-06-20 05:48:45 +00:00
|
|
|
#ifdef DEBUG
|
2001-05-25 10:53:32 +00:00
|
|
|
printf("MozSpecialMessageProc - code: 0x%X - %s hw: %p\n", code, gMSGFEvents[inx].mStr, pMsg->hwnd);
|
2001-06-20 05:48:45 +00:00
|
|
|
#endif
|
2001-05-25 10:53:32 +00:00
|
|
|
} else {
|
2001-06-20 05:48:45 +00:00
|
|
|
#ifdef DEBUG
|
2001-05-25 10:53:32 +00:00
|
|
|
printf("MozSpecialMessageProc - code: 0x%X - %d hw: %p\n", code, gMSGFEvents[inx].mId, pMsg->hwnd);
|
2001-06-20 05:48:45 +00:00
|
|
|
#endif
|
2001-05-25 10:53:32 +00:00
|
|
|
}
|
|
|
|
gLastMsgCode = code;
|
|
|
|
}
|
|
|
|
PrintEvent(pMsg->message, FALSE, FALSE);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (gProcessHook && code == MSGF_MENU) {
|
|
|
|
MSG* pMsg = (MSG*)lParam;
|
2001-06-14 02:08:39 +00:00
|
|
|
ScheduleHookTimer( pMsg->hwnd, pMsg->message);
|
2001-05-25 10:53:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ::CallNextHookEx(gMsgFilterHook, code, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Process all mouse messages
|
|
|
|
// Roll up when a click is in a native window that doesn't have an nsIWidget
|
|
|
|
LRESULT CALLBACK nsWindow::MozSpecialMouseProc(int code, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
if (gProcessHook) {
|
|
|
|
MOUSEHOOKSTRUCT* ms = (MOUSEHOOKSTRUCT*)lParam;
|
|
|
|
if (wParam == WM_LBUTTONDOWN) {
|
|
|
|
nsIWidget* mozWin = (nsIWidget*)GetNSWindowPtr(ms->hwnd);
|
|
|
|
if (mozWin == NULL) {
|
2004-09-03 08:44:23 +00:00
|
|
|
ScheduleHookTimer(ms->hwnd, (UINT)wParam);
|
2001-05-25 10:53:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ::CallNextHookEx(gCallMouseHook, code, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Process all messages
|
|
|
|
// Roll up when the window is moving, or is resizing or when maximized or mininized
|
|
|
|
LRESULT CALLBACK nsWindow::MozSpecialWndProc(int code, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
#ifdef DISPLAY_NOISY_MSGF_MSG
|
2004-09-03 08:44:23 +00:00
|
|
|
if (gProcessHook) {
|
2001-05-25 10:53:32 +00:00
|
|
|
CWPSTRUCT* cwpt = (CWPSTRUCT*)lParam;
|
|
|
|
PrintEvent(cwpt->message, FALSE, FALSE);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (gProcessHook) {
|
|
|
|
CWPSTRUCT* cwpt = (CWPSTRUCT*)lParam;
|
2004-09-03 08:44:23 +00:00
|
|
|
if (cwpt->message == WM_MOVING ||
|
|
|
|
cwpt->message == WM_SIZING ||
|
2001-05-25 10:53:32 +00:00
|
|
|
cwpt->message == WM_GETMINMAXINFO) {
|
2004-09-03 08:44:23 +00:00
|
|
|
ScheduleHookTimer(cwpt->hwnd, (UINT)cwpt->message);
|
2001-05-25 10:53:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ::CallNextHookEx(gCallProcHook, code, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Register the special "hooks" for dropdown processing
|
2005-02-23 07:07:51 +00:00
|
|
|
|
2001-05-25 10:53:32 +00:00
|
|
|
void nsWindow::RegisterSpecialDropdownHooks()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!gMsgFilterHook, "gMsgFilterHook must be NULL!");
|
|
|
|
NS_ASSERTION(!gCallProcHook, "gCallProcHook must be NULL!");
|
|
|
|
|
|
|
|
DISPLAY_NMM_PRT("***************** Installing Msg Hooks ***************\n");
|
|
|
|
|
|
|
|
//HMODULE hMod = GetModuleHandle("gkwidget.dll");
|
|
|
|
|
|
|
|
// Install msg hook for moving the window and resizing
|
|
|
|
if (!gMsgFilterHook) {
|
|
|
|
DISPLAY_NMM_PRT("***** Hooking gMsgFilterHook!\n");
|
|
|
|
gMsgFilterHook = SetWindowsHookEx(WH_MSGFILTER, MozSpecialMsgFilter, NULL, GetCurrentThreadId());
|
|
|
|
#ifdef DISPLAY_NOISY_MSGF_MSG
|
|
|
|
if (!gMsgFilterHook) {
|
|
|
|
printf("***** SetWindowsHookEx is NOT installed for WH_MSGFILTER!\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// Install msg hook for menus
|
|
|
|
if (!gCallProcHook) {
|
|
|
|
DISPLAY_NMM_PRT("***** Hooking gCallProcHook!\n");
|
|
|
|
gCallProcHook = SetWindowsHookEx(WH_CALLWNDPROC, MozSpecialWndProc, NULL, GetCurrentThreadId());
|
|
|
|
#ifdef DISPLAY_NOISY_MSGF_MSG
|
|
|
|
if (!gCallProcHook) {
|
|
|
|
printf("***** SetWindowsHookEx is NOT installed for WH_CALLWNDPROC!\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// Install msg hook for the mouse
|
|
|
|
if (!gCallMouseHook) {
|
|
|
|
DISPLAY_NMM_PRT("***** Hooking gCallMouseHook!\n");
|
|
|
|
gCallMouseHook = SetWindowsHookEx(WH_MOUSE, MozSpecialMouseProc, NULL, GetCurrentThreadId());
|
|
|
|
#ifdef DISPLAY_NOISY_MSGF_MSG
|
|
|
|
if (!gCallMouseHook) {
|
|
|
|
printf("***** SetWindowsHookEx is NOT installed for WH_MOUSE!\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Unhook special message hooks for dropdowns
|
2005-02-23 07:07:51 +00:00
|
|
|
|
2001-05-25 10:53:32 +00:00
|
|
|
void nsWindow::UnregisterSpecialDropdownHooks()
|
|
|
|
{
|
|
|
|
DISPLAY_NMM_PRT("***************** De-installing Msg Hooks ***************\n");
|
|
|
|
|
|
|
|
if (gCallProcHook) {
|
|
|
|
DISPLAY_NMM_PRT("***** Unhooking gCallProcHook!\n");
|
|
|
|
if (!::UnhookWindowsHookEx(gCallProcHook)) {
|
|
|
|
DISPLAY_NMM_PRT("***** UnhookWindowsHookEx failed for gCallProcHook!\n");
|
|
|
|
}
|
|
|
|
gCallProcHook = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gMsgFilterHook) {
|
|
|
|
DISPLAY_NMM_PRT("***** Unhooking gMsgFilterHook!\n");
|
|
|
|
if (!::UnhookWindowsHookEx(gMsgFilterHook)) {
|
|
|
|
DISPLAY_NMM_PRT("***** UnhookWindowsHookEx failed for gMsgFilterHook!\n");
|
|
|
|
}
|
|
|
|
gMsgFilterHook = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gCallMouseHook) {
|
|
|
|
DISPLAY_NMM_PRT("***** Unhooking gCallMouseHook!\n");
|
|
|
|
if (!::UnhookWindowsHookEx(gCallMouseHook)) {
|
|
|
|
DISPLAY_NMM_PRT("***** UnhookWindowsHookEx failed for gCallMouseHook!\n");
|
|
|
|
}
|
|
|
|
gCallMouseHook = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-23 07:07:51 +00:00
|
|
|
|
2001-06-14 02:08:39 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// This timer is designed to only fire one time at most each time a "hook" function
|
|
|
|
// is used to rollup the dropdown
|
2004-09-03 08:44:23 +00:00
|
|
|
// In some cases, the timer may be scheduled from the hook, but that hook event or
|
2001-06-14 02:08:39 +00:00
|
|
|
// a subsequent event may roll up the dropdown before this timer function is executed.
|
|
|
|
//
|
|
|
|
// For example, if an MFC control takes focus, the combobox will lose focus and rollup
|
|
|
|
// before this function fires.
|
|
|
|
//
|
2004-09-03 08:44:23 +00:00
|
|
|
VOID CALLBACK nsWindow::HookTimerForPopups(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
|
2001-06-14 02:08:39 +00:00
|
|
|
{
|
|
|
|
if (gHookTimerId != 0) {
|
|
|
|
// if the window is NULL then we need to use the ID to kill the timer
|
|
|
|
BOOL status = ::KillTimer(NULL, gHookTimerId);
|
|
|
|
NS_ASSERTION(status, "Hook Timer was not killed.");
|
|
|
|
gHookTimerId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gRollupMsgId != 0) {
|
2004-09-03 08:44:23 +00:00
|
|
|
// Note: DealWithPopups does the check to make sure that
|
2001-06-14 02:08:39 +00:00
|
|
|
// gRollupListener and gRollupWidget are not NULL
|
|
|
|
LRESULT popupHandlingResult;
|
2005-01-14 19:23:06 +00:00
|
|
|
DealWithPopups(gRollupMsgWnd, gRollupMsgId, 0, 0, &popupHandlingResult);
|
2001-06-14 02:08:39 +00:00
|
|
|
gRollupMsgId = 0;
|
2005-01-14 19:23:06 +00:00
|
|
|
gRollupMsgWnd = NULL;
|
2001-06-14 02:08:39 +00:00
|
|
|
}
|
|
|
|
}
|
2005-06-29 18:52:08 +00:00
|
|
|
#endif // WinCE
|
|
|
|
|
2005-06-08 16:48:44 +00:00
|
|
|
//
|
|
|
|
// DealWithPopups
|
|
|
|
//
|
|
|
|
// Handle events that may cause a popup (combobox, XPMenu, etc) to need to rollup.
|
|
|
|
//
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
nsWindow :: DealWithPopups ( HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inLParam, LRESULT* outResult )
|
|
|
|
{
|
2005-08-16 19:15:06 +00:00
|
|
|
if (gRollupListener && gRollupWidget && ::IsWindowVisible(inWnd)) {
|
2005-06-08 16:48:44 +00:00
|
|
|
|
2005-08-16 19:15:06 +00:00
|
|
|
if (inMsg == WM_LBUTTONDOWN || inMsg == WM_RBUTTONDOWN || inMsg == WM_MBUTTONDOWN ||
|
2006-09-08 06:04:44 +00:00
|
|
|
inMsg == WM_MOUSEWHEEL || inMsg == WM_MOUSEHWHEEL || inMsg == WM_ACTIVATE
|
2005-06-29 18:52:08 +00:00
|
|
|
#ifndef WINCE
|
2005-06-08 16:48:44 +00:00
|
|
|
||
|
|
|
|
inMsg == WM_NCRBUTTONDOWN ||
|
|
|
|
inMsg == WM_MOVING ||
|
|
|
|
inMsg == WM_SIZING ||
|
|
|
|
inMsg == WM_GETMINMAXINFO ||
|
|
|
|
inMsg == WM_NCLBUTTONDOWN ||
|
|
|
|
inMsg == WM_NCMBUTTONDOWN ||
|
|
|
|
inMsg == WM_MOUSEACTIVATE ||
|
|
|
|
inMsg == WM_ACTIVATEAPP ||
|
|
|
|
inMsg == WM_MENUSELECT ||
|
|
|
|
(inMsg == WM_GETMINMAXINFO && !::GetParent(inWnd))
|
2005-06-29 18:52:08 +00:00
|
|
|
#endif
|
2005-06-08 16:48:44 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
// Rollup if the event is outside the popup.
|
|
|
|
PRBool rollup = !nsWindow::EventIsInsideWindow(inMsg, (nsWindow*)gRollupWidget);
|
|
|
|
|
2006-09-08 06:04:44 +00:00
|
|
|
if (rollup && (inMsg == WM_MOUSEWHEEL || inMsg == WM_MOUSEHWHEEL))
|
2005-06-08 16:48:44 +00:00
|
|
|
{
|
|
|
|
gRollupListener->ShouldRollupOnMouseWheelEvent(&rollup);
|
|
|
|
*outResult = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we're dealing with menus, we probably have submenus and we don't
|
|
|
|
// want to rollup if the click is in a parent menu of the current submenu.
|
|
|
|
if (rollup) {
|
|
|
|
nsCOMPtr<nsIMenuRollup> menuRollup ( do_QueryInterface(gRollupListener) );
|
|
|
|
if ( menuRollup ) {
|
|
|
|
nsCOMPtr<nsISupportsArray> widgetChain;
|
|
|
|
menuRollup->GetSubmenuWidgetChain ( getter_AddRefs(widgetChain) );
|
|
|
|
if ( widgetChain ) {
|
|
|
|
PRUint32 count = 0;
|
|
|
|
widgetChain->Count(&count);
|
|
|
|
for ( PRUint32 i = 0; i < count; ++i ) {
|
|
|
|
nsCOMPtr<nsISupports> genericWidget;
|
|
|
|
widgetChain->GetElementAt ( i, getter_AddRefs(genericWidget) );
|
|
|
|
nsCOMPtr<nsIWidget> widget ( do_QueryInterface(genericWidget) );
|
|
|
|
if ( widget ) {
|
|
|
|
nsIWidget* temp = widget.get();
|
|
|
|
if ( nsWindow::EventIsInsideWindow(inMsg, (nsWindow*)temp) ) {
|
|
|
|
rollup = PR_FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // foreach parent menu widget
|
|
|
|
}
|
|
|
|
} // if rollup listener knows about menus
|
|
|
|
}
|
|
|
|
|
2006-07-25 18:53:38 +00:00
|
|
|
#ifndef WINCE
|
2005-06-08 16:48:44 +00:00
|
|
|
if (inMsg == WM_MOUSEACTIVATE) {
|
|
|
|
// Prevent the click inside the popup from causing a change in window
|
|
|
|
// activation. Since the popup is shown non-activated, we need to eat
|
|
|
|
// any requests to activate the window while it is displayed. Windows
|
|
|
|
// will automatically activate the popup on the mousedown otherwise.
|
|
|
|
if (!rollup) {
|
|
|
|
*outResult = MA_NOACTIVATE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UINT uMsg = HIWORD(inLParam);
|
|
|
|
if (uMsg == WM_MOUSEMOVE)
|
|
|
|
{
|
|
|
|
// WM_MOUSEACTIVATE cause by moving the mouse - X-mouse (eg. TweakUI)
|
|
|
|
// must be enabled in Windows.
|
|
|
|
gRollupListener->ShouldRollupOnMouseActivate(&rollup);
|
|
|
|
if (!rollup)
|
|
|
|
{
|
|
|
|
*outResult = MA_NOACTIVATE;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if we've still determined that we should still rollup everything, do it.
|
2006-07-25 18:53:38 +00:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if ( rollup ) {
|
2005-06-08 16:48:44 +00:00
|
|
|
gRollupListener->Rollup();
|
|
|
|
|
|
|
|
// Tell hook to stop processing messages
|
|
|
|
gProcessHook = PR_FALSE;
|
|
|
|
gRollupMsgId = 0;
|
|
|
|
gRollupMsgWnd = NULL;
|
|
|
|
|
|
|
|
// return TRUE tells Windows that the event is consumed,
|
|
|
|
// false allows the event to be dispatched
|
|
|
|
//
|
|
|
|
// So if we are NOT supposed to be consuming events, let it go through
|
|
|
|
if (gRollupConsumeRollupEvent && inMsg != WM_RBUTTONDOWN) {
|
|
|
|
*outResult = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // if event that might trigger a popup to rollup
|
|
|
|
} // if rollup listeners registered
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
} // DealWithPopups
|
|
|
|
|
2001-09-25 08:34:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
2006-04-18 19:08:34 +00:00
|
|
|
already_AddRefed<nsIAccessible> nsWindow::GetRootAccessible()
|
2001-09-25 08:34:42 +00:00
|
|
|
{
|
2004-05-25 14:33:50 +00:00
|
|
|
nsWindow::gIsAccessibilityOn = TRUE;
|
|
|
|
|
|
|
|
if (mIsDestroying || mOnDestroyCalled || mWindowType == eWindowType_invisible) {
|
2005-07-15 02:35:19 +00:00
|
|
|
return nsnull;
|
2004-05-25 14:33:50 +00:00
|
|
|
}
|
|
|
|
|
2005-07-15 02:35:19 +00:00
|
|
|
nsIAccessible *rootAccessible = nsnull;
|
|
|
|
|
|
|
|
// If accessibility is turned on, we create this even before it is requested
|
|
|
|
// when the window gets focused. We need it to be created early so it can
|
|
|
|
// generate accessibility events right away
|
|
|
|
nsWindow* accessibleWindow = nsnull;
|
|
|
|
if (mContentType != eContentTypeInherit) {
|
|
|
|
// We're on a MozillaContentWindowClass or MozillaUIWindowClass window.
|
|
|
|
// Search for the correct visible child window to get an accessible
|
|
|
|
// document from. Make sure to use an active child window
|
|
|
|
HWND accessibleWnd = ::GetTopWindow(mWnd);
|
|
|
|
while (accessibleWnd) {
|
|
|
|
// Loop through windows and find the first one with accessibility info
|
|
|
|
accessibleWindow = GetNSWindowPtr(accessibleWnd);
|
|
|
|
if (accessibleWindow) {
|
|
|
|
accessibleWindow->DispatchAccessibleEvent(NS_GETACCESSIBLE, &rootAccessible);
|
|
|
|
if (rootAccessible) {
|
|
|
|
break; // Success, one of the child windows was active
|
2004-05-25 14:33:50 +00:00
|
|
|
}
|
|
|
|
}
|
2005-07-15 02:35:19 +00:00
|
|
|
accessibleWnd = ::GetNextWindow(accessibleWnd, GW_HWNDNEXT);
|
2004-05-25 14:33:50 +00:00
|
|
|
}
|
|
|
|
}
|
2005-07-15 02:35:19 +00:00
|
|
|
else {
|
|
|
|
DispatchAccessibleEvent(NS_GETACCESSIBLE, &rootAccessible);
|
2001-09-25 08:34:42 +00:00
|
|
|
}
|
2005-07-15 02:35:19 +00:00
|
|
|
return rootAccessible;
|
2001-09-25 08:34:42 +00:00
|
|
|
}
|
2003-04-01 20:02:51 +00:00
|
|
|
|
|
|
|
HINSTANCE nsWindow::gmAccLib = 0;
|
|
|
|
LPFNLRESULTFROMOBJECT nsWindow::gmLresultFromObject = 0;
|
|
|
|
|
2004-09-03 08:44:23 +00:00
|
|
|
STDMETHODIMP_(LRESULT) nsWindow::LresultFromObject(REFIID riid, WPARAM wParam, LPUNKNOWN pAcc)
|
2003-04-01 20:02:51 +00:00
|
|
|
{
|
|
|
|
// open the dll dynamically
|
2004-09-03 08:44:23 +00:00
|
|
|
if (!gmAccLib)
|
|
|
|
gmAccLib =::LoadLibrary("OLEACC.DLL");
|
2003-04-01 20:02:51 +00:00
|
|
|
|
|
|
|
if (gmAccLib) {
|
|
|
|
if (!gmLresultFromObject)
|
|
|
|
gmLresultFromObject = (LPFNLRESULTFROMOBJECT)GetProcAddress(gmAccLib,"LresultFromObject");
|
|
|
|
|
|
|
|
if (gmLresultFromObject)
|
|
|
|
return gmLresultFromObject(riid,wParam,pAcc);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2001-09-25 08:34:42 +00:00
|
|
|
#endif
|
2004-07-27 19:14:44 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_XUL
|
|
|
|
|
2007-06-29 17:21:55 +00:00
|
|
|
nsWindow* nsWindow::GetTopLevelWindow()
|
2004-07-27 19:14:44 +00:00
|
|
|
{
|
2004-12-09 17:56:46 +00:00
|
|
|
nsWindow* curWindow = this;
|
2004-07-27 19:14:44 +00:00
|
|
|
|
|
|
|
while (PR_TRUE)
|
|
|
|
{
|
2004-12-09 17:56:46 +00:00
|
|
|
nsWindow* parentWindow = curWindow->GetParent(PR_TRUE);
|
2004-07-27 19:14:44 +00:00
|
|
|
|
2004-12-09 17:56:46 +00:00
|
|
|
if (parentWindow)
|
|
|
|
curWindow = parentWindow;
|
2006-03-22 18:00:28 +00:00
|
|
|
else
|
2004-12-09 17:56:46 +00:00
|
|
|
return curWindow;
|
2004-07-27 19:14:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-31 01:04:41 +00:00
|
|
|
#ifdef MOZ_CAIRO_GFX
|
|
|
|
gfxASurface *nsWindow::GetThebesSurface()
|
|
|
|
{
|
|
|
|
if (mPaintDC)
|
|
|
|
return (new gfxWindowsSurface(mPaintDC));
|
|
|
|
|
|
|
|
return (new gfxWindowsSurface(mWnd));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-02-15 23:35:53 +00:00
|
|
|
void nsWindow::ResizeTranslucentWindow(PRInt32 aNewWidth, PRInt32 aNewHeight, PRBool force)
|
2004-07-27 19:14:44 +00:00
|
|
|
{
|
2006-02-15 23:35:53 +00:00
|
|
|
if (!force && aNewWidth == mBounds.width && aNewHeight == mBounds.height)
|
2004-07-27 19:14:44 +00:00
|
|
|
return;
|
|
|
|
|
2007-04-02 18:53:43 +00:00
|
|
|
#ifdef MOZ_CAIRO_GFX
|
|
|
|
mTranslucentSurface = new gfxWindowsSurface(gfxIntSize(aNewWidth, aNewHeight), gfxASurface::ImageFormatARGB32);
|
|
|
|
mMemoryDC = mTranslucentSurface->GetDC();
|
|
|
|
mMemoryBitmap = NULL;
|
|
|
|
#else
|
2004-07-27 19:14:44 +00:00
|
|
|
// resize the alpha mask
|
|
|
|
PRUint8* pBits;
|
|
|
|
|
|
|
|
if (aNewWidth > 0 && aNewHeight > 0)
|
|
|
|
{
|
|
|
|
pBits = new PRUint8 [aNewWidth * aNewHeight];
|
|
|
|
|
2006-02-15 23:35:53 +00:00
|
|
|
if (pBits && mAlphaMask)
|
2004-07-27 19:14:44 +00:00
|
|
|
{
|
|
|
|
PRInt32 copyWidth, copyHeight;
|
|
|
|
PRInt32 growWidth, growHeight;
|
|
|
|
|
|
|
|
if (aNewWidth > mBounds.width)
|
|
|
|
{
|
|
|
|
copyWidth = mBounds.width;
|
|
|
|
growWidth = aNewWidth - mBounds.width;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
copyWidth = aNewWidth;
|
|
|
|
growWidth = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aNewHeight > mBounds.height)
|
|
|
|
{
|
|
|
|
copyHeight = mBounds.height;
|
|
|
|
growHeight = aNewHeight - mBounds.height;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
copyHeight = aNewHeight;
|
|
|
|
growHeight = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint8* pSrc = mAlphaMask;
|
|
|
|
PRUint8* pDest = pBits;
|
|
|
|
|
|
|
|
for (PRInt32 cy = 0 ; cy < copyHeight ; cy++)
|
|
|
|
{
|
2004-12-09 17:56:46 +00:00
|
|
|
memcpy(pDest, pSrc, copyWidth);
|
|
|
|
memset(pDest + copyWidth, 255, growWidth);
|
2004-07-27 19:14:44 +00:00
|
|
|
pSrc += mBounds.width;
|
|
|
|
pDest += aNewWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (PRInt32 gy = 0 ; gy < growHeight ; gy++)
|
|
|
|
{
|
2004-12-09 17:56:46 +00:00
|
|
|
memset(pDest, 255, aNewWidth);
|
2004-07-27 19:14:44 +00:00
|
|
|
pDest += aNewWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
pBits = nsnull;
|
|
|
|
|
|
|
|
delete [] mAlphaMask;
|
|
|
|
mAlphaMask = pBits;
|
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
if (!mMemoryDC)
|
|
|
|
mMemoryDC = ::CreateCompatibleDC(NULL);
|
2006-02-15 23:35:53 +00:00
|
|
|
|
2007-04-02 18:53:43 +00:00
|
|
|
// Always use at least 24-bit bitmaps regardless of the device context.
|
2006-04-04 20:57:13 +00:00
|
|
|
int depth = ::GetDeviceCaps(mMemoryDC, BITSPIXEL);
|
|
|
|
if (depth < 24)
|
|
|
|
depth = 24;
|
2006-02-15 23:35:53 +00:00
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
// resize the memory bitmap
|
|
|
|
BITMAPINFO bi = { 0 };
|
|
|
|
bi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
|
|
|
|
bi.bmiHeader.biWidth = aNewWidth;
|
|
|
|
bi.bmiHeader.biHeight = -aNewHeight;
|
|
|
|
bi.bmiHeader.biPlanes = 1;
|
|
|
|
bi.bmiHeader.biBitCount = depth;
|
|
|
|
bi.bmiHeader.biCompression = BI_RGB;
|
2005-08-22 15:17:53 +00:00
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
mMemoryBitmap = ::CreateDIBSection(mMemoryDC, &bi, DIB_RGB_COLORS, (void**)&mMemoryBits, NULL, 0);
|
2004-12-09 17:56:46 +00:00
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
if (mMemoryBitmap)
|
|
|
|
{
|
|
|
|
HGDIOBJ oldBitmap = ::SelectObject(mMemoryDC, mMemoryBitmap);
|
|
|
|
::DeleteObject(oldBitmap);
|
2004-12-09 17:56:46 +00:00
|
|
|
}
|
2007-04-02 18:53:43 +00:00
|
|
|
#endif
|
2004-07-27 19:14:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWindow::GetWindowTranslucency(PRBool& aTranslucent)
|
|
|
|
{
|
2007-06-29 17:21:55 +00:00
|
|
|
aTranslucent = GetTopLevelWindow()->GetWindowTranslucencyInner();
|
2004-07-27 19:14:44 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWindow::SetWindowTranslucency(PRBool aTranslucent)
|
|
|
|
{
|
2007-06-29 17:21:55 +00:00
|
|
|
nsresult rv = GetTopLevelWindow()->SetWindowTranslucencyInner(aTranslucent);
|
2004-07-27 19:14:44 +00:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsWindow::UpdateTranslucentWindowAlpha(const nsRect& aRect, PRUint8* aAlphas)
|
|
|
|
{
|
2007-06-29 17:21:55 +00:00
|
|
|
GetTopLevelWindow()->UpdateTranslucentWindowAlphaInner(aRect, aAlphas);
|
2004-07-27 19:14:44 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsWindow::SetWindowTranslucencyInner(PRBool aTranslucent)
|
|
|
|
{
|
|
|
|
if (aTranslucent == mIsTranslucent)
|
|
|
|
return NS_OK;
|
|
|
|
|
2005-08-12 03:29:18 +00:00
|
|
|
HWND hWnd = GetTopLevelHWND(mWnd, PR_TRUE);
|
2004-12-09 17:56:46 +00:00
|
|
|
nsWindow* topWindow = GetNSWindowPtr(hWnd);
|
2004-08-02 20:08:43 +00:00
|
|
|
|
2004-12-09 17:56:46 +00:00
|
|
|
if (!topWindow)
|
2004-08-02 20:08:43 +00:00
|
|
|
{
|
|
|
|
NS_WARNING("Trying to use transparent chrome in an embedded context");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
LONG style, exStyle;
|
|
|
|
|
2004-07-27 19:14:44 +00:00
|
|
|
if (aTranslucent)
|
|
|
|
{
|
2006-04-04 20:57:13 +00:00
|
|
|
style = ::GetWindowLongW(hWnd, GWL_STYLE) &
|
2004-08-02 20:08:43 +00:00
|
|
|
~(WS_CAPTION | WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
|
2006-04-04 20:57:13 +00:00
|
|
|
exStyle = ::GetWindowLongW(hWnd, GWL_EXSTYLE) &
|
2005-10-27 16:22:01 +00:00
|
|
|
~(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
|
2004-12-09 17:56:46 +00:00
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
exStyle |= WS_EX_LAYERED;
|
2004-07-27 19:14:44 +00:00
|
|
|
} else
|
|
|
|
{
|
|
|
|
style = WindowStyle();
|
2004-08-02 20:08:43 +00:00
|
|
|
exStyle = WindowExStyle();
|
2004-07-27 19:14:44 +00:00
|
|
|
}
|
2006-04-04 20:57:13 +00:00
|
|
|
::SetWindowLongW(hWnd, GWL_STYLE, style);
|
|
|
|
::SetWindowLongW(hWnd, GWL_EXSTYLE, exStyle);
|
2004-07-27 19:14:44 +00:00
|
|
|
|
|
|
|
mIsTranslucent = aTranslucent;
|
2004-12-09 17:56:46 +00:00
|
|
|
topWindow->mIsTopTranslucent = aTranslucent;
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
2006-04-04 20:57:13 +00:00
|
|
|
|
|
|
|
rv = SetupTranslucentWindowMemoryBitmap(aTranslucent);
|
2004-12-09 17:56:46 +00:00
|
|
|
|
|
|
|
if (aTranslucent)
|
|
|
|
{
|
|
|
|
if (!mBounds.IsEmpty())
|
|
|
|
{
|
|
|
|
PRInt32 alphaBytes = mBounds.width * mBounds.height;
|
|
|
|
mAlphaMask = new PRUint8 [alphaBytes];
|
|
|
|
|
|
|
|
if (mAlphaMask)
|
|
|
|
memset(mAlphaMask, 255, alphaBytes);
|
|
|
|
else
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
} else
|
|
|
|
mAlphaMask = nsnull;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
delete [] mAlphaMask;
|
|
|
|
mAlphaMask = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsWindow::SetupTranslucentWindowMemoryBitmap(PRBool aTranslucent)
|
|
|
|
{
|
2006-02-15 23:35:53 +00:00
|
|
|
if (aTranslucent) {
|
|
|
|
ResizeTranslucentWindow(mBounds.width, mBounds.height, PR_TRUE);
|
|
|
|
} else {
|
2007-04-02 18:53:43 +00:00
|
|
|
#ifdef MOZ_CAIRO_GFX
|
|
|
|
mTranslucentSurface = nsnull;
|
|
|
|
#else
|
2006-04-04 20:57:13 +00:00
|
|
|
if (mMemoryDC)
|
|
|
|
::DeleteDC(mMemoryDC);
|
|
|
|
if (mMemoryBitmap)
|
|
|
|
::DeleteObject(mMemoryBitmap);
|
2007-04-02 18:53:43 +00:00
|
|
|
#endif
|
2004-07-27 19:14:44 +00:00
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
mMemoryDC = NULL;
|
|
|
|
mMemoryBitmap = NULL;
|
2004-07-27 19:14:44 +00:00
|
|
|
}
|
|
|
|
|
2006-02-15 23:35:53 +00:00
|
|
|
return NS_OK;
|
2004-07-27 19:14:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsWindow::UpdateTranslucentWindowAlphaInner(const nsRect& aRect, PRUint8* aAlphas)
|
|
|
|
{
|
2006-02-15 23:35:53 +00:00
|
|
|
#ifdef MOZ_CAIRO_GFX
|
|
|
|
NS_ERROR("nsWindow::UpdateTranslucentWindowAlphaInner called, when it sholdn't be!");
|
|
|
|
#else
|
2004-07-27 19:14:44 +00:00
|
|
|
NS_ASSERTION(mIsTranslucent, "Window is not transparent");
|
|
|
|
NS_ASSERTION(aRect.x >= 0 && aRect.y >= 0 &&
|
|
|
|
aRect.XMost() <= mBounds.width && aRect.YMost() <= mBounds.height,
|
|
|
|
"Rect is out of window bounds");
|
|
|
|
|
2004-12-09 17:56:46 +00:00
|
|
|
PRBool transparencyMaskChanged = PR_FALSE;
|
|
|
|
|
2004-07-27 19:14:44 +00:00
|
|
|
if (!aRect.IsEmpty())
|
|
|
|
{
|
2004-12-09 17:56:46 +00:00
|
|
|
PRUint8* pSrcRow = aAlphas;
|
|
|
|
PRUint8* pDestRow = mAlphaMask + aRect.y * mBounds.width + aRect.x;
|
2004-07-27 19:14:44 +00:00
|
|
|
|
|
|
|
for (PRInt32 y = 0 ; y < aRect.height ; y++)
|
|
|
|
{
|
2006-04-04 20:57:13 +00:00
|
|
|
memcpy(pDestRow, pSrcRow, aRect.width);
|
2004-12-09 17:56:46 +00:00
|
|
|
|
|
|
|
pSrcRow += aRect.width;
|
|
|
|
pDestRow += mBounds.width;
|
2004-07-27 19:14:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
// Windows 2000 and newer versions support layered windows which allow to implement
|
|
|
|
// full 256 level alpha translucency.
|
|
|
|
// The real screen update is performed in OnPaint() handler only after rendered
|
|
|
|
// bits from offscreen drawing surface are copied back to memory bitmap.
|
2006-02-15 23:35:53 +00:00
|
|
|
#endif
|
2004-07-27 19:14:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsWindow::UpdateTranslucentWindow()
|
|
|
|
{
|
|
|
|
if (mBounds.IsEmpty())
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
|
2005-08-22 15:17:53 +00:00
|
|
|
::GdiFlush();
|
|
|
|
|
2006-02-15 23:35:53 +00:00
|
|
|
HDC hMemoryDC;
|
|
|
|
PRBool needConversion;
|
|
|
|
|
|
|
|
#ifdef MOZ_CAIRO_GFX
|
|
|
|
|
2006-04-04 20:57:13 +00:00
|
|
|
hMemoryDC = mMemoryDC;
|
2006-02-15 23:35:53 +00:00
|
|
|
needConversion = PR_FALSE;
|
|
|
|
|
|
|
|
rv = NS_OK;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2007-04-02 18:53:43 +00:00
|
|
|
HBITMAP hAlphaBitmap;
|
2006-04-04 20:57:13 +00:00
|
|
|
int depth = ::GetDeviceCaps(mMemoryDC, BITSPIXEL);
|
2005-08-22 15:17:53 +00:00
|
|
|
if (depth < 24)
|
|
|
|
depth = 24;
|
2004-07-27 19:14:44 +00:00
|
|
|
|
2006-02-15 23:35:53 +00:00
|
|
|
needConversion = (depth == 24);
|
2005-08-22 15:17:53 +00:00
|
|
|
|
|
|
|
if (needConversion)
|
2004-07-27 19:14:44 +00:00
|
|
|
{
|
2005-08-22 15:17:53 +00:00
|
|
|
hMemoryDC = ::CreateCompatibleDC(NULL);
|
2004-07-27 19:14:44 +00:00
|
|
|
|
2005-08-22 15:17:53 +00:00
|
|
|
if (hMemoryDC)
|
2004-07-27 19:14:44 +00:00
|
|
|
{
|
2005-08-22 15:17:53 +00:00
|
|
|
// Memory bitmap with alpha channel
|
2004-07-27 19:14:44 +00:00
|
|
|
BITMAPINFO bi = { 0 };
|
|
|
|
bi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
|
|
|
|
bi.bmiHeader.biWidth = mBounds.width;
|
|
|
|
bi.bmiHeader.biHeight = -mBounds.height;
|
|
|
|
bi.bmiHeader.biPlanes = 1;
|
|
|
|
bi.bmiHeader.biBitCount = 32;
|
|
|
|
bi.bmiHeader.biCompression = BI_RGB;
|
|
|
|
|
2005-08-22 15:17:53 +00:00
|
|
|
PRUint8* pBits32 = nsnull;
|
|
|
|
hAlphaBitmap = ::CreateDIBSection(hMemoryDC, &bi, DIB_RGB_COLORS, (void**)&pBits32, NULL, 0);
|
|
|
|
|
|
|
|
if (hAlphaBitmap)
|
2004-07-27 19:14:44 +00:00
|
|
|
{
|
2005-08-22 15:17:53 +00:00
|
|
|
HGDIOBJ oldBitmap = ::SelectObject(hMemoryDC, hAlphaBitmap);
|
2004-07-27 19:14:44 +00:00
|
|
|
|
2005-08-22 15:17:53 +00:00
|
|
|
PRUint8* pPixel32 = pBits32;
|
|
|
|
PRUint8* pAlpha = mAlphaMask;
|
2005-11-01 20:46:52 +00:00
|
|
|
PRUint32 rasWidth = RASWIDTH(mBounds.width, 24);
|
2005-08-22 15:17:53 +00:00
|
|
|
|
|
|
|
for (PRInt32 y = 0 ; y < mBounds.height ; y++)
|
2004-07-27 19:14:44 +00:00
|
|
|
{
|
2006-04-04 20:57:13 +00:00
|
|
|
PRUint8* pPixel = mMemoryBits + y * rasWidth;
|
2004-07-27 19:14:44 +00:00
|
|
|
|
2005-08-22 15:17:53 +00:00
|
|
|
for (PRInt32 x = 0 ; x < mBounds.width ; x++)
|
2004-07-27 19:14:44 +00:00
|
|
|
{
|
2005-11-01 20:46:52 +00:00
|
|
|
*pPixel32++ = *pPixel++;
|
|
|
|
*pPixel32++ = *pPixel++;
|
|
|
|
*pPixel32++ = *pPixel++;
|
|
|
|
*pPixel32++ = *pAlpha++;
|
2004-07-27 19:14:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-22 15:17:53 +00:00
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
{
|
2006-04-04 20:57:13 +00:00
|
|
|
hMemoryDC = mMemoryDC;
|
2004-07-27 19:14:44 +00:00
|
|
|
|
2005-08-22 15:17:53 +00:00
|
|
|
if (hMemoryDC)
|
|
|
|
{
|
2006-04-04 20:57:13 +00:00
|
|
|
PRUint8* pPixel = mMemoryBits + 3; // Point to alpha component of pixel
|
2005-08-22 15:17:53 +00:00
|
|
|
PRUint8* pAlpha = mAlphaMask;
|
|
|
|
PRInt32 pixels = mBounds.width * mBounds.height;
|
|
|
|
|
|
|
|
for (PRInt32 cnt = 0 ; cnt < pixels ; cnt++)
|
|
|
|
{
|
2005-11-01 20:46:52 +00:00
|
|
|
*pPixel = *pAlpha++;
|
2005-08-22 15:17:53 +00:00
|
|
|
pPixel += 4;
|
|
|
|
}
|
2004-07-27 19:14:44 +00:00
|
|
|
|
2005-08-22 15:17:53 +00:00
|
|
|
rv = NS_OK;
|
2004-07-27 19:14:44 +00:00
|
|
|
}
|
2005-08-22 15:17:53 +00:00
|
|
|
}
|
2006-02-15 23:35:53 +00:00
|
|
|
#endif /* MOZ_CAIRO_GFX */
|
2005-08-22 15:17:53 +00:00
|
|
|
|
|
|
|
if (rv == NS_OK)
|
|
|
|
{
|
|
|
|
BLENDFUNCTION bf = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
|
|
|
|
SIZE winSize = { mBounds.width, mBounds.height };
|
|
|
|
POINT srcPos = { 0, 0 };
|
|
|
|
HWND hWnd = GetTopLevelHWND(mWnd, PR_TRUE);
|
|
|
|
RECT winRect;
|
|
|
|
::GetWindowRect(hWnd, &winRect);
|
|
|
|
|
|
|
|
// perform the alpha blend
|
2006-06-16 02:27:37 +00:00
|
|
|
if (!::UpdateLayeredWindow(hWnd, NULL, (POINT*)&winRect, &winSize, hMemoryDC, &srcPos, 0, &bf, ULW_ALPHA))
|
2005-08-22 15:17:53 +00:00
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (needConversion)
|
|
|
|
{
|
2006-04-04 20:57:13 +00:00
|
|
|
#ifndef MOZ_CAIRO_GFX
|
2005-08-22 15:17:53 +00:00
|
|
|
::DeleteObject(hAlphaBitmap);
|
2006-04-04 20:57:13 +00:00
|
|
|
#endif
|
2004-07-27 19:14:44 +00:00
|
|
|
::DeleteDC(hMemoryDC);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|